Unknown Command
#10

pawn Код:
if(!strcmp(cmd, "/setplayertg", true))
    {
        new tmp[256];
        tmp = strtok(cmdtext, idx);
        new otherplayerid = ReturnUser(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Use /setplayertg [playerid/name]");
        else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "This player is not connected");
            SendClientMessage(otherplayerid,COLOR_LIGHTRED,"You've been set to [Team 2] by an [Admin].");
            setTG[otherplayerid] = 1;
        return 1;
    }

pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21)
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID;
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos]))
    {
        userid = strval(text[pos]);
        if (userid >=0 && userid < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
                userid = INVALID_PLAYER_ID;
            else return userid;
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new pname[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, pname, sizeof (pname));
            if (strcmp(pname, text[pos], true, len) == 0)
            {
                if (len == strlen(pname)) return i;
                else
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count) SendClientMessage(playerid, red, "ERROR: There are multiple users, enter full playername.");
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid;
}
Reply


Messages In This Thread
Unknown Command - by Kudoz - 10.06.2013, 14:10
AW: Unknown Command - by Blackazur - 10.06.2013, 14:12
Re: Unknown Command - by Kudoz - 10.06.2013, 14:16
Re: Unknown Command - by IceBilizard - 10.06.2013, 14:18
Re: Unknown Command - by Kudoz - 10.06.2013, 14:24
Re: Unknown Command - by IceBilizard - 10.06.2013, 14:25
Re: Unknown Command - by Kudoz - 10.06.2013, 14:32
Re: Unknown Command - by IceBilizard - 10.06.2013, 14:40
Re: Unknown Command - by Kudoz - 10.06.2013, 14:47
Re: Unknown Command - by IceBilizard - 10.06.2013, 15:08

Forum Jump:


Users browsing this thread: 2 Guest(s)