carcolor script problem
#27

Not that hard. this code works (I used/tested in my own server.)

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
   
    if(!strcmp(cmd, "/carcolor", true))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new color1, color2;
            new tmp[256];
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
            color1 = strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
            color2 = strval(tmp);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000FF, "Your Not in any Vehicle!");
        }
        return 1;
    }
    return 0;
}

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;
}
and if you can't even get that right, heres the actual file!
Reply


Messages In This Thread
carcolor script problem - by Freght - 07.07.2010, 11:48
Re: carcolor script problem - by CAR - 07.07.2010, 11:51
Re: carcolor script problem - by DeathOnaStick - 07.07.2010, 11:52
Re: carcolor script problem - by Freght - 07.07.2010, 12:11
Re: carcolor script problem - by CAR - 07.07.2010, 12:13
Re: carcolor script problem - by Freght - 07.07.2010, 12:21
Re: carcolor script problem - by Kotomi - 07.07.2010, 12:23
Re: carcolor script problem - by CAR - 07.07.2010, 12:35
Re: carcolor script problem - by Freght - 07.07.2010, 12:36
Re: carcolor script problem - by Hiddos - 07.07.2010, 12:43
Re: carcolor script problem - by Freght - 07.07.2010, 12:55
Re: carcolor script problem - by Hiddos - 07.07.2010, 12:57
Re: carcolor script problem - by Freght - 07.07.2010, 13:00
Re: carcolor script problem - by Freght - 07.07.2010, 13:02
Re: carcolor script problem - by The_Prince - 07.07.2010, 13:02
Re: carcolor script problem - by Hiddos - 07.07.2010, 13:03
Re: carcolor script problem - by [L3th4l] - 07.07.2010, 13:17
Re: carcolor script problem - by Hiddos - 07.07.2010, 13:21
Re: carcolor script problem - by Kotomi - 07.07.2010, 13:41
Re: carcolor script problem - by Hiddos - 07.07.2010, 13:59
Re: carcolor script problem - by Freght - 07.07.2010, 14:06
Re: carcolor script problem - by Freght - 07.07.2010, 14:09
Re: carcolor script problem - by Hiddos - 07.07.2010, 14:10
Re: carcolor script problem - by Freght - 07.07.2010, 14:23
Re: carcolor script problem - by Freght - 07.07.2010, 14:28
Re: carcolor script problem - by Freght - 07.07.2010, 14:49
Re: carcolor script problem - by Toni - 07.07.2010, 16:22
Re: carcolor script problem - by [L3th4l] - 07.07.2010, 16:26
Re: carcolor script problem - by Freght - 08.07.2010, 01:17
Re: carcolor script problem - by Toni - 08.07.2010, 01:52

Forum Jump:


Users browsing this thread: 5 Guest(s)