SA-MP Forums Archive
This command returns the name of player id 0 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This command returns the name of player id 0 (/showthread.php?tid=385986)



This command returns the name of player id 0 - Face9000 - 18.10.2012

Hello, this command i have it returns the name of the id 0 only.

So if i do /getid 1 i'll get the name of the ID 0 instead of ID 1.

pawn Код:
CMD:getid(playerid, params[])
{
    new string[128], id;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(id,name,sizeof(name));
    if(sscanf(params, "u", id))
    {
        SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
    }
    else
    {
        if(IsPlayerConnected(id))
        {
            format(string, sizeof(string), "The ID that matches %s is %d.", name, id);
           SendClientMessage(playerid, red, string);
        }
        else
        {
            SendClientMessage(playerid, red, "That player is not connected or is not logged in.");
        }
    }
    return 1;
}
Thanks for help.


Re: This command returns the name of player id 0 - RedFusion - 18.10.2012

pawn Код:
CMD:getid(playerid, params[])
{
    new string[128], id;
    new name[MAX_PLAYER_NAME];
    if(isnull(params)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "That player is not connected or is not logged in.");
    GetPlayerName(id,name,sizeof(name));
    format(string, sizeof(string), "Player found: %s (Id:%d)", name, id);
    SendClientMessage(playerid, red, string);
    return 1;
}
pawn Код:
if(sscanf(params, "u", id))
This line sets your variable "ID" to the number you typed in..
pawn Код:
if(IsPlayerConnected(id))
Also, you should put GetPlayerName below this line


Re: This command returns the name of player id 0 - CmZxC - 18.10.2012

Again;
make sure you are up to date with sscanf2 plugin, there was a known bug after SA-MP update that the old plugin will return any playerid to 0.
Just make sure that you have the latest sscanf2 plugin.


Re: This command returns the name of player id 0 - RedJohn - 18.10.2012

https://sampforum.blast.hk/showthread.php?tid=339361


Re: This command returns the name of player id 0 - Mauzen - 18.10.2012

Just as RedFusion already explained, its no problem with sscanf at all, just a wrong function order.


Re: This command returns the name of player id 0 - Kwarde - 18.10.2012

'u' is for the user ID уr name (as explained already maybe, but I didn't understand it so good). Try to use "i" or "d" (integer) instead of "u" (playername/playerid)


Re: This command returns the name of player id 0 - Face9000 - 18.10.2012

Thank you guys


Re: This command returns the name of player id 0 - Djole1337 - 18.10.2012

Код:
CMD:getid(playerid, params[])
{
	new string[128], id;
	new name[MAX_PLAYER_NAME];
	if(isnull(params)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
	if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
     	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "That player is not connected or is not logged in.");
	GetPlayerName(id,name,sizeof(name));
	format(string, sizeof(string), "Player found: %s (Id:%d)", name, id);
 	SendClientMessage(playerid, red, string);
	return 1;
}
You don't need this btw.

OFF TOPIC:
Seriously you have almost 2.500 posts and you can't create simple code. (Nothing personal)


Re: This command returns the name of player id 0 - Kwarde - 18.10.2012

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
Код:
CMD:getid(playerid, params[])
{
	new string[128], id;
	new name[MAX_PLAYER_NAME];
	if(isnull(params)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
	if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/getid <part of name>");
     	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, red, "That player is not connected or is not logged in.");
	GetPlayerName(id,name,sizeof(name));
	format(string, sizeof(string), "Player found: %s (Id:%d)", name, id);
 	SendClientMessage(playerid, red, string);
	return 1;
}
You don't need this btw.

OFF TOPIC:
Seriously you have almost 2.500 posts and you can't create simple code. (Nothing personal)
OFF TOPIC TOO: Ammount of posts has NOTHING to do with scripting skills.


Re: This command returns the name of player id 0 - Face9000 - 18.10.2012

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
Seriously you have almost 2.500 posts and you can't create simple code. (Nothing personal)
Yeah, also i have 500.000$ but i dont own a Ferrari,how bad...