Help with strtok and tmp etc.
#9

pawn Code:
if(strcmp(cmd, "/carcolor", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        new car = GetCarIDFromPlayer(playerid);
        new vehid = GetPlayerVehicleID(playerid);
        if(!IsPlayerDriver(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY,"   You're not driving a car !");
            return 1;
        }
        if(vehid != car)
        {
            SendClientMessage(playerid, COLOR_GREY,"   This is not your car !");
            return 1;
        }
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GREY,"   USUAGE: /carcolor [color 1] [color 2]");
            return 1;
        }
        if(PlayerInfo[playerid][pCash] < 499)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You need $500 !");
            return 1;
        }
        tmp = strtok( cmdtext, idx );
        new color = strval( tmp );
        tmp = strtok( cmdtext, idx );
        new color2 = strval( tmp );
        new id = GetCarIDFromPlayer_Enum(playerid);
        CarInfo[id][vColorOne] = color;
        CarInfo[id][vColorTwo] = color2;
        DestroyVehicle(car);
        CarInfo[car][ownedvehicle] = CreateVehicle(CarInfo[id][vModel],CarInfo[id][vLocationx],CarInfo[id][vLocationy],CarInfo[id][vLocationz],CarInfo[id][vAngle],CarInfo[id][vColorOne],CarInfo[id][vColorTwo],300000);
        SendClientMessage(playerid, COLOR_GREY,"   Changed color for $500, color changes on respawn !");
        GivePlayerMoney(playerid, -500);
        PlayerInfo[playerid][pCash] -= 500;
        return 1;
    }
color2 always gets set as 0 no matter what the input is.
Reply


Messages In This Thread
Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 05:43
Re: Help with strtok and tmp etc. - by =WoR=Varth - 25.08.2011, 05:54
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:04
Re: Help with strtok and tmp etc. - by Bakr - 25.08.2011, 06:08
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:13
Re: Help with strtok and tmp etc. - by Bakr - 25.08.2011, 06:19
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:25
Re: Help with strtok and tmp etc. - by Bakr - 25.08.2011, 06:27
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:29
Re: Help with strtok and tmp etc. - by Bakr - 25.08.2011, 06:30
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:36
Re: Help with strtok and tmp etc. - by Bakr - 25.08.2011, 06:45
Re: Help with strtok and tmp etc. - by Jack_Leslie - 25.08.2011, 06:50
Re: Help with strtok and tmp etc. - by Speed - 25.08.2011, 07:17

Forum Jump:


Users browsing this thread: 2 Guest(s)