AsuraBro Posted December 26, 2015 Group: Members Topic Count: 19 Topics Per Day: 0.00 Content Count: 74 Reputation: 3 Joined: 07/12/14 Last Seen: June 28, 2016 Share Posted December 26, 2015 (edited) Hello, can someone please show me what is wrong with this script, i have modified this script, https://rathena.org/board/topic/83371-send-to-all-online-players/?p=202884 do { set .@size, query_sql( "SELECT `account_id`, `name` from `char` where `online` = '1' and `char_id` != "+ getcharid(0) +" order by `account_id` desc limit "+ ( .@loop *128 ) +", 128", .@account_id, .@name$ ); for( set .@i, 0; .@i < .@size; set .@i, .@i +1 ) { if ( checkvending( .@name$[.@i] ) || checkchatting( .@name$[.@i] ) ) continue; set .@randomplayer, .@account_id[.@i[rand(getarraysize(.@account_id))]]; } explain for this, it will give an item from my input to a random player that isn't shopping / chatting. but the problem is it will always give the same player, i tried a lot of methods to fix it but none worked. what is wrong with it. thank you! Edited December 27, 2015 by AsuraBro Quote Link to comment Share on other sites More sharing options...
0 Stolao Posted December 27, 2015 Group: Developer Topic Count: 48 Topics Per Day: 0.01 Content Count: 1443 Reputation: 344 Joined: 10/17/12 Last Seen: Sunday at 01:58 PM Share Posted December 27, 2015 order by `account_id` desc limit Change the order 1 Quote Link to comment Share on other sites More sharing options...
0 AsuraBro Posted December 27, 2015 Group: Members Topic Count: 19 Topics Per Day: 0.00 Content Count: 74 Reputation: 3 Joined: 07/12/14 Last Seen: June 28, 2016 Author Share Posted December 27, 2015 (edited) order by `account_id` desc limit Change the order and how should it be i really don't have that much of idea on it. should it look like this? set .@size, query_sql( "SELECT `account_id`, `name` from `char` where `online` = '1' and `char_id` != "+ getcharid(0) +" order by RAND(`account_id`) desc limit "+ ( .@loop *128 ) +", 128", .@account_id, .@name$ ); Edited December 27, 2015 by AsuraBro Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted December 27, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted December 27, 2015 do{ .@result = query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY RAND() LIMIT 1",.@aid,.@name$ ); } while( .@result && ( checkvending( .@name$ ) || checkchatting( .@name$ ) ) ); if ( .@result ) { getitem 512,1,.@aid; getitem 512,2,.@aid; getitem 512,3,.@aid; } 1 Quote Link to comment Share on other sites More sharing options...
0 Stolao Posted December 27, 2015 Group: Developer Topic Count: 48 Topics Per Day: 0.01 Content Count: 1443 Reputation: 344 Joined: 10/17/12 Last Seen: Sunday at 01:58 PM Share Posted December 27, 2015 do{ .@result = query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY RAND() LIMIT 1",.@aid,.@name$ ); } while( .@result && ( checkvending( .@name$ ) || checkchatting( .@name$ ) ) ); if ( .@result ) { getitem 512,1,.@aid; getitem 512,2,.@aid; getitem 512,3,.@aid; } Ty emistry 1 Quote Link to comment Share on other sites More sharing options...
0 AsuraBro Posted December 27, 2015 Group: Members Topic Count: 19 Topics Per Day: 0.00 Content Count: 74 Reputation: 3 Joined: 07/12/14 Last Seen: June 28, 2016 Author Share Posted December 27, 2015 do{ .@result = query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY RAND() LIMIT 1",.@aid,.@name$ ); } while( .@result && ( checkvending( .@name$ ) || checkchatting( .@name$ ) ) ); if ( .@result ) { getitem 512,1,.@aid; getitem 512,2,.@aid; getitem 512,3,.@aid; } ty, emistry. but what if i wanted to exclude player with gm level ? Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted December 27, 2015 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted December 27, 2015 .@result = query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 AND `account_id` NOT IN ( SELECT `account_id` FROM `login` WHERE `group_id` > 0 ) ORDER BY RAND() LIMIT 1",.@aid,.@name$ ); 1 Quote Link to comment Share on other sites More sharing options...
Question
AsuraBro
Hello,
can someone please show me what is wrong with this script, i have modified this script, https://rathena.org/board/topic/83371-send-to-all-online-players/?p=202884
explain for this, it will give an item from my input to a random player that isn't shopping / chatting.
but the problem is it will always give the same player, i tried a lot of methods to fix it but none worked.
what is wrong with it.
thank you!
Edited by AsuraBroLink 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.