Command Help.
#4

Use strtok, a lot easier.

pawn Код:
//OnPlayerCommandText
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);

    if(!strcmp("/playername", cmd)) {
        new tmp[128];
        tmp = strtok(cmdtext, idx);
        if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid player.");
        new name[MAX_PLAYER_NAME];
        GetPlayerName(strval(tmp), name, sizeof(name));
        new message[128];
        format(message, sizeof(message), "RESPONSE: ID: %i | Player Name: %s", strval(tmp), name);
        SendClientMessage(playerid, COLOR_GREEN, message);
        return 1;
    }
Try that, if you get errors about not having strtok, put this at the bottom of your script:

pawn Код:
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
Command Help. - by CSMajor - 28.07.2010, 15:59
Re: Command Help. - by Kar - 28.07.2010, 16:02
Re: Command Help. - by Vince - 28.07.2010, 16:04
Re: Command Help. - by Conroy - 28.07.2010, 16:06
Re: Command Help. - by iggy1 - 28.07.2010, 16:24
Re: Command Help. - by CSMajor - 28.07.2010, 16:47
Re: Command Help. - by iggy1 - 28.07.2010, 16:53
Re: Command Help. - by CSMajor - 28.07.2010, 17:04

Forum Jump:


Users browsing this thread: 1 Guest(s)