GetPlayerID (Useful_Functions)
#1

Код:
CMD:mapp(playerid, params[])
{
	new Float:TY, Float:TX, Float:TZ, targetname[MAX_PLAYER_NAME], IDofName, string[128], realname[MAX_PLAYER_NAME];
	if(sscanf(params,"u",targetname)) return SendClientMessage(playerid,-1, "{FF0000}Usage: /mapp [player name]!");
	
 	IDofName = GetPlayerID(targetname, 1);
	{
	    new shit[128];
	    format(shit, sizeof(shit), "Returned ID: %d", IDofName);
		SendClientMessage(playerid, -1, shit);
	
	    if(!IsPlayerConnected(IDofName))
	    {
	        SendClientMessage(playerid, 0xFF0000FF, "Error: player is not connected.");
	    }
	    else
	    {
			GetPlayerPos(IDofName, TX, TY, TZ);
			GPSMarkeris[playerid] = SetPlayerMapIcon(playerid, 0, TX, TY, TZ, 0, 0xFF0000FF, 1);
			GetPlayerName(IDofName, realname, sizeof(realname));
			format(string, sizeof(string), "{3399FF}[GPS] {5167F0}%s {3399FF}last known location has been marked {FF0000}with a red marker", realname);
			SendClientMessage(playerid, COLOR_HIGHLIGHT, string);
		}
	}


	return 1;
}
Why does this command work when I type in the name or part of name of ID0 only? When I type in the name of ID1 then GetPlayerID returns the value -1. Anyone know a fix to this?


This stuff is to see what value is returned:
Код:
	    new shit[128];
	    format(shit, sizeof(shit), "Returned ID: %d", IDofName);
		SendClientMessage(playerid, -1, shit);
Reply
#2

Use targetname, sscanf will handle that for you.
Reply
#3

pawn Код:
targetname[MAX_PLAYER_NAME]
targetname should be an integer type because sscanf returns the ID not name.
Reply
#4

K thanks
Reply
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
pawn Код:
targetname[MAX_PLAYER_NAME]
targetname should be an integer type because sscanf returns the ID not name.
No targetname should be integer as sscanf will return ID of the player, not name.
Reply
#6

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
No targetname should be integer as sscanf will return ID of the player, not name.
No shit, that's exactly what he said... xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)