getid dialog
#5

pawn Код:
new gDialogPos[MAX_PLAYERS] = {-1, ...};

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[512];//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%s (ID: %i)\n", fstr, playersname, i);
                //SendClientMessage(playerid, 0xFFFF00FF, fstr);

                gDialogPos[Count] = i;

                Count++;
                //continue;
            }
        }
    }

    if(Count == 0) SendClientMessage(playerid, 0xFF0000FF, "There were no matches found.");
    else
    {
        new str[128];
        format(str, sizeof(str), "There was a total of %i potential matches found.", Count);
        SendClientMessage(playerid, 0x00FF00FF, str);

        ShowPlayerDialog(playerid, YOUR_DIALOG_ID, DIALOG_STYLE_LIST, "Players", fstr, "Goto", "Close");
    }
    return 1;
}

//On Dialog Response
    switch(dialogid)
    {
        case YOUR_DIALOG_ID:
        {
            if(response)
            {
                new pID = gDialogPos[listitem], Float: pos[3];
           
                GetPlayerPos(pID, pos[0], pos[1], pos[2]);
           
                SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            }
        }
    }
Try that.
Edit: Check the new code to be able to teleport to that player
Reply


Messages In This Thread
getid dialog - by gotwarzone - 25.10.2013, 20:25
Re: getid dialog - by DanishHaq - 25.10.2013, 20:35
Re: getid dialog - by gotwarzone - 25.10.2013, 20:41
Re: getid dialog - by gotwarzone - 28.10.2013, 16:54
Re: getid dialog - by -Prodigy- - 28.10.2013, 17:41
Re: getid dialog - by kbalor - 28.10.2013, 18:11
AW: Re: getid dialog - by Nero_3D - 28.10.2013, 19:17
Re: AW: Re: getid dialog - by gotwarzone - 28.10.2013, 19:26
AW: Re: AW: Re: getid dialog - by Nero_3D - 28.10.2013, 19:29
Re: AW: Re: getid dialog - by -Prodigy- - 28.10.2013, 20:10

Forum Jump:


Users browsing this thread: 3 Guest(s)