Jump to content
  • 0

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


AsuraBro

Question


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  74
  • Reputation:   3
  • Joined:  07/12/14
  • Last Seen:  

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
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


.@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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

order by `account_id` desc limit

Change the order

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  74
  • Reputation:   3
  • Joined:  07/12/14
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  


		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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  74
  • Reputation:   3
  • Joined:  07/12/14
  • Last Seen:  


		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 ? 

Link to comment
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.   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.

×
×
  • Create New...