Jump to content
  • 0
Sign in to follow this  
WhiteEagle

Only learned recipes showing

Question

Can anyone help me to script a NPC who show only learned recipes and 

give for each "showing" recipe an own selection?

Hope anyone can help me.

 

Example:

 

 

query_sql("SELECT account_id char_id,recept_id,receptname,learned FROM `profession_db`",.@accid,.@charid,.@recept,.@recname$,.@learned);

set .@rezept$,Diablo;
set .@rezept2$,Valkyrie;
mes .@name$;
if(.@learned > 0){
.@size = getarraysize(.@learned);
for(.@i = 0; .@i < .@size; .@i++)
set .@menu$,.@menu$ + .@recname$[.@i]+":";
.@i = select(.@menu$);
next;
if (select(.@rezept$)){
mes "Diablo.";
close;
}
if (select(.@rezept2$)){
mes "Valkyire.";
close;
}
}
mes .@name$;
mes "nothing learned.";
close;
}

 

 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

@@WhiteEagle

 

change this

query_sql("SELECT account_id char_id,recept_id,receptname,learned FROM `profession_db`",.@accid,.@charid,.@recept,.@recname$,.@learned);

to this

query_sql("SELECT `account_id` , `char_id` , `recept_id` , `receptname` , `learned` FROM `profession_db`",.@accid,.@charid,.@recept,.@recname$,.@learned);

Share this post


Link to post
Share on other sites
  • 0
prontera,142,177,3	script	Cooking Chef	730,{		mes( "[Chef]" );		if( !learnedReceipts ) {			mes( "You didn't learn any receipt, go away!" );			close;		} 		for( .@i = 0; .@i < getarraysize( .receiptInfos$ ); .@i++ ) {			if( .@i == 0 )				.@flag = 1;			else				.@flag += .@flag;			if( learnedReceipts & .@flag )				.@menu$ += .receiptInfos$[ .@i ] + ":";		}				mes( "Select a receipt." );		.@selectedReceipt = select(.@menu$) -1;		next;		mes( "[Chef]" );		mes( .receiptInfos$[ .@selectedReceipt ] );		for( .@i = 0; .@i < .ingridientListCount; .@i++ ) {			.@ingridient$ = getd( ".ingriedientList" + ( .@i + 1) + "$[" + .@selectedReceipt + "]" );						if( .@ingridient$ )					.@ingridientMenue$ += .@ingridient$;				else					break;		}				mes( "Select a ingridient." );		.@selectedIngridient = select( .@ingridientMenue$ );		next;		.@ingridient$ = getd( ".ingriedientList" + .@selectedIngridient + "$[" + .@selectedReceipt + "]" );		mes( "[Chef]" );		mes( .@ingridient$ );		close;	end;	OnInit:		setarray( .@receiptNames$, "Diablo", "Valkyrie" );				setarray( .ingriedientList1$, "Cheese", "Bread" );		setarray( .ingriedientList2$, "Fish", "Wine" );		setarray( .ingriedientList3$, "Onion", "Sausage" );				.ingrientListCount = 3;				for( .@i = 0; .@i < getarraysize( .@receiptNames$ ); .@i++ )			.receiptInfos$[ .@i ] = .@receiptNames$[ .@i ];	end;}
Edited by Winterfox

Share this post


Link to post
Share on other sites
  • 0

Thank you so much. 

 

I have questions about your script. How do I add a player now a recipe and how can I add the scripts based on SQL.

All of my profession system running on SQL.

 

My plan is:

The Recipe NPC must display the learned recipes,
for each recipe have their own choice,
for each recipe there is give their own success chance.
For every success in crafting there are points.
 
 
Thanks in advance

Share this post


Link to post
Share on other sites
  • 0

To have success rate and adding crafting points you could do something like this:

...if( rand( 10000 ) <= .receiptSuccessRates[ .@selectedReceipt ] ) {...craftingPoints += .craftingPoints;...}...OnInit:...// Rate : 1 = 0.01%  / 100 = 1% / 1000 = 10%  /  10000 = 100%setarray( .receiptSuccessRates, 100, 100 );.craftingPoints = 5;...
Edited by Winterfox

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.