SA-MP Forums Archive
get the playerid of a certain player - 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: get the playerid of a certain player (/showthread.php?tid=314246)



get the playerid of a certain player - PawnoQ - 29.01.2012

hi,

how could i get the playerID of a certain player with a certain name?
I really need this, please help fast

+rep for help


Re: get the playerid of a certain player - Babul - 29.01.2012

have a look at the sscanf2 plugin. pay attention to the "u" specifier, it converts "babul" to (my) playerid. since the latest update, you can create your own name detection script...


Re: get the playerid of a certain player - PawnoQ - 29.01.2012

thx a lot

would this also work?

pawn Код:
foreach(Player,i)
{
    if(FindPlayerByName(DOMPlayer)!= -1)//if player is online
    {
        new DOMname[24];
        GetPlayerName(i,DOMname,24);
        if(strfind(DOMname,"PawnoQ", true) == 0)//if player is the player with the right name
        {
            SetPlayerScore(i,GetPlayerScore(i)+20);//give only him score
        }
    }
    else
    {
        //if player is not online
    }
}






stock FindPlayerByName(name[])
{
    new Pname[24];
    foreach(Player,i)
    {
        GetPlayerName(i, Pname, 24);
        if(!strcmp(Pname, name, true)) return i;
    }
    return -1;
}



Re: get the playerid of a certain player - Richie - 29.01.2012

Use this:
pawn Код:
CMD:id(playerid, params[])
{
    new ID, str[64];
    if(sscanf(params,"u",ID)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /id [playername]");
   
    format(str, sizeof(str), "%s is ID: %d", pName(ID), ID);
    SendClientMessage(playerid, -1, string);
    return 1;
}



Re: get the playerid of a certain player - jamesbond007 - 29.01.2012

what color is -1 in color argument?


Re: get the playerid of a certain player - Alexander_123 - 29.01.2012

Its white colour.


Re: get the playerid of a certain player - jamesbond007 - 29.01.2012

ok can u do -2 ? what color would that be? anyone can explain why -1 is white ? 0.o


Re: get the playerid of a certain player - Vince - 29.01.2012

Because -1 converts to 0xFFFFFFFF in hex. -2 to -256 would also be white, with a decreasing alpha value.


Re: get the playerid of a certain player - PawnoQ - 30.01.2012

thx for the answers but that was not my question

would this code work?

pawn Код:
foreach(Player,i)
{
    if(FindPlayerByName(DOMPlayer)!= -1)//if player is online
    {
        new DOMname[24];
        GetPlayerName(i,DOMname,24);
        if(strfind(DOMname,"PawnoQ", true) == 0)//if player is the player with the right name
        {
            SetPlayerScore(i,GetPlayerScore(i)+20);//give only him score
        }
    }
    else
    {
        //if player is not online
    }
}



stock FindPlayerByName(name[])
{
    new Pname[24];
    foreach(Player,i)
    {
        GetPlayerName(i, Pname, 24);
        if(!strcmp(Pname, name, true)) return i;
    }
    return -1;
}