This command returns the name of player id 0
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

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

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

'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)
Reply
#7

Thank you guys
Reply
#8

Код:
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)
Reply
#9

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.
Reply
#10

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)