Posts: 111
Threads: 10
Joined: Jun 2011
Hello, this is m'y fiesta post !
I Am stripping a GM and i want to make a command witch work like that :
- A player type /id <the name Of the player/part le name>
- The server returns "player not found if he is not
- If he is found, it returns "<Name of the player>'s ID is <ID>".
Is it possible ?
Thank you
Ps: I looked topics about GetPlayerID but it don't work for me ...
Posts: 111
Threads: 10
Joined: Jun 2011
I tryed this, but i don't know how to use it as a command ! The compilation doesn't work ='(
Help please =)
Posts: 111
Threads: 10
Joined: Jun 2011
It now works !
I maked this command
Код:
dcmd_id(playerid, params[])
{
new id, playername[24] ,string[256];
if (sscanf(params, "s", GetName(id), playername))
return SendClientMessage(playerid, 0xFF0000AA, "Utilisation: \"/id <nom du joueur>\"");
else if (!IsPlayerConnected(id))
return SendClientMessage(playerid, 0xFF0000AA, "Joueur non trouve");
else
{
format(string, sizeof(string), "The ID that matches %s is %d.", GetName(id), id);
SendClientMessage(playerid, 0xFFFF00AA, string);
}
return 1;
}
With this stock :
Код HTML:
stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, Name, sizeof(Name));
}
else
{
Name = "Disconnected/Nothing";
}
return Name;
}
And now, when I type /id a player name, it returns his ID !!
Thank you ! =)
Posts: 15,941
Threads: 0
Joined: Jun 2008
If you are using sscanf there is a "u" specifier which does exactly what you want already, you don\'t need to write your own based on "s". Plus, "u" takes either a name OR an ID.
Posts: 111
Threads: 10
Joined: Jun 2011
It don't work ... It only gives the first player ID ... How can I give the player that i give the name's ID ?
Posts: 15,941
Threads: 0
Joined: Jun 2008
Quote:
Originally Posted by ludesert
It don\'t work ... It only gives the first player ID ... How can I give the player that i give the name\'s ID ?
|
Are you using the PAWN or plugin version of sscanf (I\'m guessing the PAWN version given that you didn\'t include an array size after "s"). Anyway, if you\'re not already, use the plugin version.
Russell_: zcmd has nothing to do with the question.
Posts: 111
Threads: 10
Joined: Jun 2011
I don't know ... ^^
But i tryed to use "u" in sscanaf, but it gives me ID 0 for all players ! And even for players who are not connected !
Posts: 15,941
Threads: 0
Joined: Jun 2008
Then you need to find out - I can\'t solve, or even attempt to solve your issue without that information. Or technically I can, but the first step is getting that information.
Posts: 111
Threads: 10
Joined: Jun 2011
Posts: 111
Threads: 10
Joined: Jun 2011