Jump to content
  • 0

Get Map Player List


Question

7 answers to this question

Recommended Posts

Posted

Could you give an example of how that is used? Say for example, to give an apple to a random player on that specific map?

 

prontera,150,150,5	script	Give Item	100,{
	set(.player,getcharid(3));
	deletearray(.players[0],128); addrid(1);
	set(.players[getarraysize(.players)],getcharid(3));
	detachrid; attachrid(.player);
	getitem(512,1,set(.@a,.players[rand(getarraysize(.players))]));
	npctalk rid2name(.@a)+" got a Apple!";
	end;
}

 

This is untested by me O_O and might not work because it will all happen at once.

 

Tested working perfectly.

Posted

doc/script_commands.txt#L3535

*addrid(<type>{,<flag>{,<parameters>}});

This command will attach other RIDs to the current script without detaching the
invoking RID. It returns 1 if successful and 0 upon failure.

<type> determines what RIDs are attached:
 0: All players in the server.
 1: All players in the map of the invoking player, or the invoking NPC if no player is attached.
 2: Party members of a specified party ID.
    [ Parameters: <party id> ]
 3: Guild members of a specified guild ID.
    [ Parameters: <guild id> ]
 4: All players in a specified area of the map of the invoking player (or NPC).
    [ Parameters: <x0>,<y0>,<x1>,<y1> ]
 Account ID: The specified account ID.

<flag> can prevent certain players from being attached:
 0: Players are always attached. (default)
 1: Players currently running another script will not be attached.

  • Upvote 1
Posted
-	script	ijnoo	-1,{
OnWhisperGlobal:
	deletearray .aid, .size_aid;
	deletearray .cid, .size_aid;
	deletearray .name$, .size_aid;
	.size_aid = 0;
	.@myaid = playerattached();
	addrid(1);// attach all player on your map to the script
	if ( .size_aid < 128 && playerattached() != .@myaid ) {
		.aid[ .size_aid ] = playerattached();
		.cid[ .size_aid ] = getcharid(0);
		.name$[ .size_aid ] = strcharinfo(0);
		.size_aid++;
	}
	if ( playerattached() != .@myaid ) end;
	while( .@i < .size_aid ) {
		.@menu$ = .@menu$ + .name$[.@i] +":";
		.@i++;
	}
	mes "Select a player you want to give a reward.";
	next;
	.@s = select( .@menu$ ) -1;
	callsub L_check, .@s;
	mes "Item id";
	input .@atoi_id;
	if ( getiteminfo( .@atoi_id,0 ) == -1 ) {
		mes "This item doesn't exist";
		close;
	}
	mes "amount?";
	input .@amount;
	if ( .@amount < 1 ) {
		mes "You can't send "+ .@amount +" item.";
		close;
	}
	next;
	mes "Give a ^ff0000"+ getitemname( .@atoi_id ) +" ("+ .@atoi_id +")^000000 x"+ .@amount +" to "+ .name$[.@s] +" ?";
	next;
	if ( select( "Yes", "No" ) == 2 ) close;
	callsub L_check, .@s;
	getitem .@atoi_id, .@amount, .aid[.@s];
	mes "The player get the reward.";
	close;
L_check:
	.@s = getarg(0);
	if ( !isloggedin( .aid[.@s], .cid[.@s] ) ) {
		mes "this player is not online.";
		close;
	}
	else if ( !getmapxy( .@map$, .@x, .@y, 0, .name$[.@s] ) && .@map$ != strcharinfo(3) ) {
		mes "this player is no more on the same map of you.";
		close;
	}
	return;
}

whisper the npc ijnoo to give a reward to a player on your map

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