/carcolor help
#1

Hi, so I have a car color command here, it's suppose to change the color of the vehicle that the player is stating. The problem is, when I do [/carcolor 1 3 3], it just simply changes to black, same with any other color. Here's the code.

pawn Код:
if(strcmp(cmd, "/carcolor", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pVehicle1] == 0 && PlayerInfo[playerid][pVehicle2] == 0 && PlayerInfo[playerid][pVehicle3] == 0)
            { SendClientMessage(playerid, COLOR_WHITE, "You do not own any vehicles to change the color of."); return 1; }
            if(GetPlayerMoney(playerid) < 500) { SendClientMessage(playerid, COLOR_WHITE, "You need at least $500 to change your vehicle's color."); return 1; }
            new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr)) { SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/carcolor [1-2-3] [color1] [color2]"); return 1; }
            if(strcmp(x_nr,"1",true) == 0)
            {
                if(PlayerInfo[playerid][pVehicle1] != 0)
                {
                    new color1 = strval(tmp);
                    if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, "The first color cannot be below 1 or above 126."); return 1; }
                    new color2 = strval(tmp);
                    if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, "The second color cannot be below 1 or above 126."); return 1; }
                    new car = personalcar1[playerid];
                    format(string, sizeof(string), "You set your vehicle color in slot 1 to %d and %d for $500.", color1, color2);
                    GivePlayerCash(playerid, -500);
                    PlayerInfo[playerid][pVehicle1Color1] = color1;
                    PlayerInfo[playerid][pVehicle1Color2] = color2;
                    ChangeVehicleColor(car, color1, color2);
                    OnPlayerUpdateEx(playerid);
                    return 1;
                } else { SendClientMessage(playerid, COLOR_WHITE, "You don't have a vehicle on slot 1."); return 1; }
            }
        }
        return 1;
    }
If anyone could help me, I'd appreciate it very much.
Reply
#2

Theres a really simple an easy way to do what you want to do but for that you will need to learn ZCMD and Sscanf.

https://sampforum.blast.hk/showthread.php?tid=91354
https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#3

Quote:
Originally Posted by Edix
Посмотреть сообщение
Theres a really simple an easy way to do what you want to do but for that you will need to learn ZCMD and Sscanf.

https://sampforum.blast.hk/showthread.php?tid=91354
https://sampforum.blast.hk/showthread.php?tid=120356
Nope. Thanks anyway for the help. I know it's possible without ZCMD and sscanf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)