SA-MP Forums Archive
id part of name - 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: id part of name (/showthread.php?tid=482315)



id part of name - ScRipTeRi - 20.12.2013

Hello i have create this for find player ID but all work good but have one problem on player id dont find it good so here is script
pawn Код:
dcmd_id(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /id <part of name>");
    new players, Names[MAX_PLAYER_NAME];
    for(new i=0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerName(i, Names, MAX_PLAYER_NAME);
            new len = strlen(Names);
            new bool:searched=false;
            for(new pos=0; pos <= len; pos++)
            {
                if(searched != true)
                {
                    if(strfind(Names,params,true) == pos)
                    {
                        players++;
                        SendClientMessage(playerid, 0xE89B5BBB, "Players found:");
                        format(string,sizeof(string),"> %s (ID:%d)",Names,playerid);
                        SendClientMessage(playerid, COLOR_WHITE ,string);
                        searched = true;
                    }
                }
            }
        }
    }
    if(players == 0)
    SendClientMessage(playerid, 0xFF0000FF, "Player not found.");
    return 1;
}
Thank you


Re: id part of name - HyperZ - 20.12.2013

< Removed >


Re: id part of name - ikey07 - 20.12.2013

Maybe this isnt the issue, but this line

pawn Код:
if(strfind(Names,params,true) == pos)
should be

pawn Код:
if(!strfind(Names,params,true))