Jump to content
  • 0
Sign in to follow this  
wallaby

Getting Charid of the player on a map

Question

2 answers to this question

Recommended Posts

  • 0

Firstly, you would need to set the mapflag 'loadevent' for your map in question.

map_name	mapflag	loadevent
Next, you need to create a script to register the last player on that map using the 'OnPCLoadMapEvent' function.
-	script	Last Player ID	FAKE_NPC,{

OnPCLoadMapEvent:
	if (strcharinfo(3) == "map_name") {
		.@charid = getcharid(3,"" + strcharinfo(0) + "");
		$last_char_name = " + rid2name(.@charid) + ";
		end;
	} else end;

}
The above script asks the following:

.@charid asks for the charid type 3, which is the Account ID.

$last_char_name, converts .@charid into a name using the command 'rid2name'.

Note: rid2name only displays the current online character of that account.

 

Next you need a script which you'll be able to easily access the above value.

For this post, we'll use an atcmd using 'bindatcmd'.

 

All in all, it turns out like this:

-	script	Last Player ID::last_player_id_001	FAKE_NPC,{

OnPCLoadMapEvent:
	if (strcharinfo(3) == "prontera") {
		.@charid = getcharid(3,"" + strcharinfo(0) + "");
		$last_char_id = .@charid;
		end;
	} else end;

OnCommand:
	.@own_id = getcharid(3,"" + strcharinfo(0) + "");
	detachrid;
	attachrid($last_char_id);
	.@pleb_id = strcharinfo(0);
	detachrid;
	attachrid(.@own_id);
	message strcharinfo(0),"The last player to load map prontera was " + .@pleb_id + ".";
	end;
	
OnInit:
	bindatcmd "charid","last_player_id_001::OnCommand",96;
	end;
}

prontera	mapflag	loadevent
With a level 96 GM or above, you can use the command '@charid' to view the last player who loaded prontera.

Not sure if this is what you were after!

Edited by True Zeal

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.