(UNSOLVED) Basic Command
#11

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmd, "/evento", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new eventid[20], tmp[128];
            tmp = strtok(cmdtext, idx);
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Necesitas ser RCON!");
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, -1, "Usage: /evento motos");
                SendClientMessage(playerid, -1, "Usage: /evento amatar");
                SendClientMessage(playerid, -1, "Usage: /evento autos");
                SendClientMessage(playerid, -1, "Usage: /evento carrera");
                return 1;
            }
            strmid(eventid, tmp, 0, strlen(cmdtext), 255);
            if(strcmp(eventid, "motos", true, strlen(eventid)) == 0)
            {
                // Do your motos code
            }
            else if(strcmp(eventid, "amatar", true, strlen(eventid)) == 0)
            {
                // Do your amatar code
            }
            else if(strcmp(eventid, "autos", true, strlen(eventid)) == 0)
            {
                // Do your autos code
            }
            else if(strcmp(eventid, "carrera", true, strlen(eventid)) == 0)
            {
                // Do your carrera code
            }
            else return SendClientMessage(playerid, -1,"Unkown parameter! [Motos, Amatar, Autos, Carrera]");
        }
        return 1;
    }
    return 0;
}
At the end of your script.
pawn Code:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply


Messages In This Thread
(UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 20:19
Re: (UNSOLVED) Basic Command - by Zonoya - 30.09.2011, 20:24
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 20:26
Re: (UNSOLVED) Basic Command - by Zonoya - 30.09.2011, 20:28
Re: (UNSOLVED) Basic Command - by Jafet_Macario - 30.09.2011, 20:35
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 20:49
Re: (UNSOLVED) Basic Command - by Kingunit - 30.09.2011, 20:51
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 20:54
Re: (UNSOLVED) Basic Command - by Kingunit - 30.09.2011, 20:58
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 21:03
Re: (UNSOLVED) Basic Command - by Kingunit - 30.09.2011, 21:12
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 21:50
Re: (UNSOLVED) Basic Command - by Tigerkiller - 30.09.2011, 21:55
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 22:01
Re: (UNSOLVED) Basic Command - by Kingunit - 30.09.2011, 22:04
Re: (UNSOLVED) Basic Command - by Super_Panda - 30.09.2011, 22:17
Re: (UNSOLVED) Basic Command - by Kingunit - 30.09.2011, 22:20

Forum Jump:


Users browsing this thread: 3 Guest(s)