WhiteEagle 6 Posted July 10, 2015 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; } Quote Share this post Link to post Share on other sites
0 Kuya Jeo 120 Posted July 11, 2015 @@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); Quote Share this post Link to post Share on other sites
0 Winterfox 83 Posted July 11, 2015 (edited) 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 July 11, 2015 by Winterfox Quote Share this post Link to post Share on other sites
0 WhiteEagle 6 Posted July 11, 2015 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 Quote Share this post Link to post Share on other sites
0 Winterfox 83 Posted July 11, 2015 (edited) 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 July 11, 2015 by Winterfox Quote Share this post Link to post Share on other sites
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);
Share this post
Link to post
Share on other sites