get the playerid of a certain player
#1

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

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

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;
}
Reply
#4

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;
}
Reply
#5

what color is -1 in color argument?
Reply
#6

Its white colour.
Reply
#7

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

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

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)