Jump to content
  • 0

Can someone please show me what is wrong with this script?


Question

Posted (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 by AsuraBro

6 answers to this question

Recommended Posts

  • 0
Posted


.@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$ );

  • Upvote 1
  • 0
Posted (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 by AsuraBro
  • 0
Posted


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;

}

  • Upvote 1
  • 0
Posted

		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

  • Upvote 1
  • 0
Posted

		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 ? 

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...