command get id of player help
#1

i need a command

/getid <partialname>

Allows you to supply a name or part of a players name, if a match is found their id will be returned.
Reply
#2

Use sscanf specifier "u"
pawn Код:
//Example
CMD:get(playerid, params[])
{
      new target, Float:X, Float:Y, Float:Z;
      new string[120];
      if(sscanf(params,"u", target)) return SendClientMessage(playerid, RED,"[USAGE]: /get [ID/Name/PartOfName]");
      if(IsPlayerConnected(target))
      {
         GetPlayerPos(playerid, X, Y, Z);
         new interior = GetPlayerInterior(playerid);
         new world = GetPlayerVirtualWorld(playerid);
         SetPlayerInterior(target, interior);
         SetPlayerPos(target, X, Y, Z);
         SetPlayerVirtualWorld(target, world);
      }
   return 1;
}
Reply
#3

this is the wrong command.. this is not what i want
Reply
#4

Ehm, so you're waiting for us to ask you want do you want?
Better start explaining properly if you want people to help you properly.
Reply
#5

pawn Код:
if(!strcmp("/getid", cmd, true))
    {
        new string[256],tmp[256];
        new cud = 0;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "( ! ) /getid <name>");
        scm(playerid,COLOR_WHITE,"( ! ) ------------------------------");
        scm(playerid,COLOR_WHITE,"( ! ) ---------List of Players------");
        scm(playerid,COLOR_WHITE,"( ! ) ------------------------------");
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
            {
                if(strfind(PlayerName(i), tmp, true) != -1)
                {
                    format(string,256,"( ! ) %s ID:%d",PlayerName(i),i);
                    scm(playerid,COLOR_YELLOW,string);
                    cud++;
                }
            }
        }
        if(cud == 0)
        {
            scm(playerid,COLOR_RED,"( ! ) Not found a player with that name !");
        }
        scm(playerid,COLOR_WHITE,"( ! ) ------------------------------");
        return 1;
    }
in strcmp, if you'll ask me I'll make in ZCMD
Reply
#6

Quote:
Originally Posted by mineralo
Посмотреть сообщение
in strcmp, if you'll ask me I'll make in ZCMD
I wish if only had same time as you...
Reply
#7

pawn Код:
CMD:getid(playerid, params[])
{
    new name[24];
    if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /getid [name/id]");
    new Count = 0;
    new fstr[150];
    for(new i = 0; i < MAX_PLAYERS; i++) //foreach would be the better option...
    {
        if(IsPlayerConnected(i))
        {
            new playersname[24];
            GetPlayerName(i, playersname, 24);
            if(strfind(name, playersname, true) != -1)
            {
                format(fstr, sizeof(fstr), "%s (ID: %i)", playersname, i);
                SendClientMessage(playerid, 0xFFFF00FF, fstr);
                Count++;
                continue;
            }
        }
    }
    if(Count == 0) return SendClientMessage(playerid, 0xFF0000FF, "There were no matches found.");
    format(fstr, sizeof(fstr), "There was a total of %i potential matches found.", Count);
    SendClientMessage(playerid, 0x00FF00FF, fstr);
    return 1;
}
Hopefully this works for you, I haven't really used it before.
Reply
#8

Hi

you want like this ?
http://pastebin.com/1kCZ0EDz
Reply
#9

pawn Код:
CMD:getid(playerid, params[])
{
if(sscanf(params, "u", params[0]))
{
new string[64];
format(string, 64, "%s - %d", PlayerName(params[0]), PlayerName(params[0]));
SendClientMessage(playerid, -1, string);
}
return 1;
}
Search for the "PlayerName" stock in ****** or in the wiki of SA-MP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)