Jump to content
  • 0

Need Help ! Giving Item to All players


skyroofficial

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/16/17
  • Last Seen:  

// usage :
// [npc:Sample]map#512#10
// [npc:Sample]all#512#123


-	script	Sample	-1,{
OnWhisperGlobal:
if( getgmlevel() >= 99 ){
	// check map
	if( @whispervar0$ == "all" ) set .@type$,"";
	else if( @whispervar0$ == "map" ) set .@type$,strcharinfo(3);
	else {
		dispbottom "Error, pick 'map' or 'all' ";
		end;
	}
	
	// check item
	set .@itemid,atoi( @whispervar1$ );
	set .@amount,atoi( @whispervar2$ );
	if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
		dispbottom "Enter valid item id and amount.";
	}
	
	set .@self_id,getcharid(3);
	query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
	while( .@count < .@total ){
		query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
		set .@i,0;
		set .@size,getarraysize( .@aid );
		while( .@i < .@size ){
			if( .@aid[.@i] != .@self_id ){
				if( .@type$ != "" ){
					getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
					if( .@map$ == .@type$ ){
						getitem .@itemid,.@amount,.@aid[.@i];
						set .@gave,.@gave + 1;
					}
				}else{
					getitem .@itemid,.@amount,.@aid[.@i];
					set .@gave,.@gave + 1;
				}
			}
			set .@count,.@count + 1;
			set .@i,.@i + 1;
		}
		set .@offset,.@offset + .@size;
		deletearray .@aid,.@size;
		deletearray .@name$,.@size;
	}
	dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
}
end;
}

So i use this script to give all players items . But this script give rewards to all players online ( include afk , vending, idle, or create chat room )

how to exclude the AFK , Vending, Idle , or Creating Chat Room ( which is still considered afk ) to not get the rewards ?

 

Thank you for the helps !

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   79
  • Joined:  06/13/13
  • Last Seen:  

try this

// usage :
// [npc:Sample]map#512#10
// [npc:Sample]all#512#123


-	script	Sample	-1,{
OnWhisperGlobal:
	if( getgmlevel() >= 99 ){
		// check map
		if( @whispervar0$ == "all" ) addrid 0;
		else if( @whispervar0$ == "map" ) addrid 1;
		else {
			dispbottom "Error, pick 'map' or 'all'";
			end;
		}
		
		// check item
		set .@itemid,atoi( @whispervar1$ );
		set .@amount,atoi( @whispervar2$ );
		if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
			dispbottom "Enter valid item id and amount.";
		}
		if(checkvending() || checkchatting() || checkidle() >= 60 ) end;
		.@gave = .@gave + 1;
		getitem .@itemid,.@amount;
		dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
	}
	end;
}

 

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   127
  • Joined:  04/04/16
  • Last Seen:  

Try adding this:

.@name$ = rid2name(.@aid[.@i]); if(checkvending(.@name$) || checkchatting(.@name$) || checkidle(.@name$) >= 60 ) continue;

after this line:

while( .@i < .@size ) {

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/16/17
  • Last Seen:  

Hi @Technoken . Sorry for the late response..

 

I do as your say, but its not working . i get this error when i tried to sent an item to all users 

304e3703dc1e423e9151143a69bfbf4e.png

Any helps? :D

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   127
  • Joined:  04/04/16
  • Last Seen:  

@skyroofficial you can use @Litro Endemic script. It's sexier lol /heh 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   0
  • Joined:  04/16/17
  • Last Seen:  

20 hours ago, Litro Endemic said:

try this


// usage :
// [npc:Sample]map#512#10
// [npc:Sample]all#512#123


-	script	Sample	-1,{
OnWhisperGlobal:
	if( getgmlevel() >= 99 ){
		// check map
		if( @whispervar0$ == "all" ) addrid 0;
		else if( @whispervar0$ == "map" ) addrid 1;
		else {
			dispbottom "Error, pick 'map' or 'all'";
			end;
		}
		
		// check item
		set .@itemid,atoi( @whispervar1$ );
		set .@amount,atoi( @whispervar2$ );
		if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
			dispbottom "Enter valid item id and amount.";
		}
		if(checkvending() || checkchatting() || checkidle() >= 60 ) end;
		.@gave = .@gave + 1;
		getitem .@itemid,.@amount;
		dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
	}
	end;
}

 

@Litro Endemic Thanks alot ! XD its dem sexy /lv 

18 hours ago, Technoken said:

@skyroofficial you can use @Litro Endemic script. It's sexier lol /heh 

ikr .. ! anyways thanks @Technoken

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...