Jump to content
  • 0

Get Map Player List


rootKid

Question


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  83
  • Reputation:   11
  • Joined:  11/28/11
  • Last Seen:  

How would I go about fetching the list of players on a certain map, in order to give one of the players an item?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

Reference : http://rathena.org/wiki/Getusers

getusers(0);
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  83
  • Reputation:   11
  • Joined:  11/28/11
  • Last Seen:  

I don't want a count of the players on the map. I want a list of players which then I can attach a rid to in order to do what I want with the player after

Link to comment
Share on other sites


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

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


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  83
  • Reputation:   11
  • Joined:  11/28/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

-	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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  24
  • Topics Per Day:  0.01
  • Content Count:  83
  • Reputation:   11
  • Joined:  11/28/11
  • Last Seen:  

Thank you very much.

Edited by kou
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...