//============================================================================== stock GetPlayerIdFromName(playername[]) { for(new i = 0; i <= MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { new playername2[MAX_PLAYER_NAME]; GetPlayerName(i, playername2, sizeof(playername2)); if(strcmp(playername2, playername, true, strlen(playername)) == 0) { return i; } } } return INVALID_PLAYER_ID; }
CMD:myid(playerid, params[]) { new str3[80], GPID, name[MAX_PLAYER_NAME]; GPID=GetPlayerIdFromName(name); format(str3, sizeof(str3), "Your Id Is:%i", GPID); SCM(playerid, -1, str3); }
CMD:myid(playerid, params[])
{
new str3[80], GPID, name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GPID=GetPlayerIdFromName(name);
format(str3, sizeof(str3), "Your Id Is:%i", GPID);
SCM(playerid, -1, str3);
return 1;
}
that's wrong, you don't understand the function osama, you need to do something like this:
new RDZ = GetPlayerIdFromName(''RogueDrifter''); this will return the id of the player called RogueDrifter and save it in the variable called RDZ. So your code should look like this: PHP код:
|
stock GetPlayerID(pName[])
{
new playerid = INVALID_PLAYER_ID;
sscanf(pName,"u",playerid);
return playerid;
}
CMD:myid(playerid, params[])
{
new string[32];
format(string, sizeof(string), "Your ID is: %d", playerid);
SendClientMessage(playerid, -1, string);
return true;
}
CMD:id(playerid, params[])
{
new target;
if (sscanf(params, "u", target)) return SendClientMessage(playerid, -1, "USAGE: /id [player]");
if (!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "ERROR: The player is not online.");
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(target, pName, sizeof(pName));
format(string, sizeof(string), "%s's ID is %d", pName, target);
SendClientMessage(playerid, -1, string);
return true;
}