[HELP] /id Command
#1

I'm trying to create a command called /id which will work like if you type /id and a players name the ID of that player should appear.

For example "/id Matthew_Salinas" = "(ID: 3) Matthew_Salinas".

I'm almost done with it but it's bugged as hell so, I would appreciate if you could help me with a new one.

Thanks
Reply
#2

On top of ur script.
pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(id,2,cmdtext);
    return 0;
}
somewhere in ur script.
pawn Код:
dcmd_id(playerid,params[]) {
    if(!strlen(params)) return SendClientMessage(playerid,0x33FF33AA,"Correct Usage: /id [part of nick]");
    new found, string[128], playername[MAX_PLAYER_NAME];
    format(string,sizeof(string),"Searched for: \"%s\" ",params);
    SendClientMessage(playerid,0x33FF33AA,string);
    for(new i=0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerName(i, playername, MAX_PLAYER_NAME);
            new namelen = strlen(playername);
            new bool:searched=false;
            for(new pos=0; pos <= namelen; pos++)
            {
                if(searched != true)
                {
                    if(strfind(playername,params,true) == pos)
                    {
                        found++;
                        format(string,sizeof(string),"%d. %s (ID %d)",found,playername,i);
                        SendClientMessage(playerid, 0x33FF33AA ,string);
                        searched = true;
                    }
                }
            }
        }
    }
    if(found == 0) SendClientMessage(playerid, 0x33FF33AA, "No players have this in their nick");
    return 1;
}
Reply
#3

click me
Reply
#4

Quote:
Originally Posted by blackwave
Посмотреть сообщение
Are you ok?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)