Valcars Posted March 30, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.01 Content Count: 60 Reputation: 0 Joined: 01/03/16 Last Seen: April 15, 2022 Share Posted March 30, 2016 Hi, I wanted to know if you can, take the ID of the monsters from the query: sql, and plug it into an array, and from there take one at random.it is possible, I stopped here !!!! prontera,140,140,4 script mobkk 73,{ .@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ",.@ids,.@iname$ ); for( .@i = 0; .@i < .@sql; .@i++ ) mes "ID : "+.@ids[.@i]+" & Name : "+.@iname$[.@i]; } Quote Link to comment Share on other sites More sharing options...
0 Capuche Posted March 30, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: Thursday at 08:49 PM Share Posted March 30, 2016 http://www.petefreitag.com/item/466.cfm Quote Link to comment Share on other sites More sharing options...
0 Valcars Posted March 31, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.01 Content Count: 60 Reputation: 0 Joined: 01/03/16 Last Seen: April 15, 2022 Author Share Posted March 31, 2016 (edited) thank you Capuche,but I know that I'm doing a little bit of confusion.I tried but I can not, here is the script I tried to write prontera,143,143,4 script mobk 73,{ .@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RANDOM id LIMIT 2",.@id,.@name$ ); for( .@i = 0; .@i < .@sql; .@i++ ) mes "ID : "+.@id[.@i]+" & Name : "+.@name$[.@i]; } here is the error picture Edited March 31, 2016 by Valcars Quote Link to comment Share on other sites More sharing options...
0 Capuche Posted March 31, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: Thursday at 08:49 PM Share Posted March 31, 2016 Here is what you write ORDER BY RANDOM id LIMIT Here is what the doc say ORDER BY RAND() LIMIT Quote Link to comment Share on other sites More sharing options...
0 Valcars Posted April 1, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.01 Content Count: 60 Reputation: 0 Joined: 01/03/16 Last Seen: April 15, 2022 Author Share Posted April 1, 2016 (edited) Hello, Thanks @capuche, but I go out with another problem, in practice I need to store the monster in a variable, and every 24 hours changes monster, if you kill monsters you get a Coin. I do not know if I was clear, I can not go on. if you can help me, even cone of ideas. Thanks again.That's what I did until now. prontera,160,160,4 script mob 857,{ mes .@nameNpc$; mes "Hello "+ strcharinfo(0)+"."; mes "I can give Poring Coin"; mes "in return you have to kill all the monsters that tell you"; next; .@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RAND(ID) LIMIT 500",.@id,.@name$ ); for( .@i = 0; .@i < .@sql; .@i++ ){ copyarray .@mobID[0],.@id[.@i],500; copyarray .@mobName$[0],.@name$,500; setarray .@mobKill[0],100,200,300; set .@ranmob,rand(0,500); set .@rankill,rand(0,2); mes .@nameNpc$; mes "Today you need kill :"+.@mobName$[.@ranmob]+" x "+.@mobkill[.@rankill]; close; } //-----------------------------------------------------------------------// //OnNPCKIllEvent Label //-----------------------------------------------------------------------// OnNPCKillEvent: if(killedrid == .@mobID[.@ranmob]){ mes "You have kill "+.@mobName$[.@ranmob]; close; } end; //-----------------------------------------------------------------------// //OnInit Label //-----------------------------------------------------------------------// OnInit: waitingroom "Kill Mob for Coin",0; set .@nameNpc$,"[Mob Kills]"; } Edited April 1, 2016 by Valcars Quote Link to comment Share on other sites More sharing options...
0 Capuche Posted April 1, 2016 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: Thursday at 08:49 PM Share Posted April 1, 2016 prontera,160,160,4 script mob 857,{ mes .@nameNpc$;// unset (see oninit) mes "Hello "+ strcharinfo(0)+"."; mes "I can give Poring Coin"; mes "in return you have to kill all the monsters that tell you"; next; .@sql = query_sql( "SELECT `ID`,`iName` FROM `mob_db` ORDER BY RAND(ID) LIMIT 500",.@id,.@name$ );// it should be rand() for( .@i = 0; .@i < .@sql; .@i++ ){// unused the loop stop after the close copyarray .@mobID[0],.@id[.@i],500;// you can take 1 random monster with sql (rand() limit 1) copyarray .@mobName$[0],.@name$,500; setarray .@mobKill[0],100,200,300; set .@ranmob,rand(0,500); set .@rankill,rand(0,2); mes .@nameNpc$; mes "Today you need kill :"+.@mobName$[.@ranmob]+" x "+.@mobkill[.@rankill]; close; } //-----------------------------------------------------------------------// //OnNPCKIllEvent Label //-----------------------------------------------------------------------// OnNPCKillEvent: if(killedrid == .@mobID[.@ranmob]){ mes "You have kill "+.@mobName$[.@ranmob]; close; } end; //-----------------------------------------------------------------------// //OnInit Label //-----------------------------------------------------------------------// OnInit: waitingroom "Kill Mob for Coin",0; set .@nameNpc$,"[Mob Kills]";// everytime the script end the .@variables are cleared } I didn't test : prontera,160,160,4 script mob 857,{ .@nameNpc$ = "[Mob Kills]"; mes .@nameNpc$; mes "Hello "+ strcharinfo(0) +"."; mes "I can give Poring Coin"; mes "in return you have to kill all the monsters that tell you."; next; if (date_event != gettime(8)) { mob_count_event = 0; // clear the previous count kill date_event = gettime(8); // save the date rankill_event = rand(1,3) *100; // save the number to kill query_sql( "select `ID` from mob_db where `EXP` > 0 and (`Drop1id` > 0 or `Drop2id` > 0 or `Drop3id` > 0 or `Drop4id` > 0 or `Drop5id` > 0 or `Drop6id` > 0 or `Drop7id` > 0 or `Drop8id` > 0 or "+ "`Drop9id` > 0 or DropCardid > 0 ) ORDER BY RAND() LIMIT 1", mob_id_event );// not an event mob mes .@nameNpc$; mes "Today you need kill: "+ getmonsterinfo( mob_id_event,MOB_NAME ) +" x"+ rankill_event; } else if (mob_count_event < rankill_event) mes "You have killed "+ mob_count_event +"/"+ rankill_event +" "+ getmonsterinfo( mob_id_event,MOB_NAME ); else { mes "Congrat you killed all the monsters."; getitem 501,1; } close; OnNPCKillEvent: if (killedrid == mob_id_event && mob_count_event < rankill_event) { mob_count_event++; message strcharinfo(0), "You have killed "+ mob_count_event +"/"+ rankill_event +" "+ getmonsterinfo( mob_id_event,MOB_NAME ); } end; OnInit: waitingroom "Kill Mob for Coin",0; end; } Quote Link to comment Share on other sites More sharing options...
0 Valcars Posted April 1, 2016 Group: Members Topic Count: 24 Topics Per Day: 0.01 Content Count: 60 Reputation: 0 Joined: 01/03/16 Last Seen: April 15, 2022 Author Share Posted April 1, 2016 capuche thanks, you're a big xD. Quote Link to comment Share on other sites More sharing options...
Question
Valcars
Hi, I wanted to know if you can, take the ID of the monsters from the query: sql, and plug it into an array, and from there take one at random.
it is possible, I stopped here !!!!
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.