help with car colour
#1

hey im new to scripting and i want something that when i do /cc [id] [id] inside the game it changes your vehicles car colour could someone please help me with how i can do this?
Reply
#2

pawn Код:
if(strcmp(cmd, "/cc", true)== 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;

            new vid = GetPlayerVehicleID(playerid);
            if(strval(result) && strval(result[2]) >126 || strval(result) && strval(result[2]) <0) return SendClientMessage(playerid, COLOR_RED, "Invalid color id!");
            ChangeVehicleColor(vid, strval(result), strval(result[2]));
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
        }
        return 1;
    }
I didn't test this, so tell me if there are any errors.
Reply
#3

can you put that in pastebin.com please
Reply
#4

Here you go.

http://pastebin.com/0MqWzQQd
Reply
#5

Better do it with ZCMD and SSCANF2

pawn Код:
CMD:cc(playerid, params[])
{
    new ColorID, ColorID2, vehicleid, str[75];
    if(sscanf(params, "dd", ColorID,ColorID2)) return SendClientMessage(playerid, COLOR, "USAGE: /carcolor [1/126] [1/126]");
    else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR, "You are not in a vehicle!");
    else if(ColorID < 0 && ColorID > 126) return SendClientMessage(playerid, COLOR, "CarColor cannot be above 126 or below 0!");
    else if(ColorID2 < 0 && ColorID2 > 126) return SendClientMessage(playerid, COLOR, "CarColor2 cannot be above 126 or below 0!");
    else
    {
        vehicleid = GetPlayerVehicleID(playerid);
        ChangeVehicleColor(vehicleid, ColorID, ColorID2);
        format(str, sizeof(str),">> CarColor 1 changed to %d and CarColor 2 changed to %d  <<",ColorID, ColorID2);
        SendClientMessage(playerid, COLOR, str);
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Better do it with ZCMD and SSCANF2

pawn Код:
CMD:cc(playerid, params[])
{
    new ColorID, ColorID2, vehicleid, str[75];
    if(sscanf(params, "dd", ColorID,ColorID2)) return SendClientMessage(playerid, COLOR, "USAGE: /carcolor [1/126] [1/126]");
    else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR, "You are not in a vehicle!");
    else if(ColorID < 0 && ColorID > 126) return SendClientMessage(playerid, COLOR, "CarColor cannot be above 126 or below 0!");
    else if(ColorID2 < 0 && ColorID2 > 126) return SendClientMessage(playerid, COLOR, "CarColor2 cannot be above 126 or below 0!");
    else
    {
        vehicleid = GetPlayerVehicleID(playerid);
        ChangeVehicleColor(vehicleid, ColorID, ColorID2);
        format(str, sizeof(str),">> CarColor 1 changed to %d and CarColor 2 changed to %d  <<",ColorID, ColorID2);
        SendClientMessage(playerid, COLOR, str);
    }
    return 1;
}
I figured a new scripter wouldn't know much of zcmd and sscanf.
Reply
#7

Well it's easyer... But it requires some downloading
Reply
#8

autin i got these errors

C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(542) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(544) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(544) : warning 215: expression has no effect
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(546) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(54 : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(550) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(551) : error 017: undefined symbol "idx"
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(551) : warning 215: expression has no effect
C:\Users\Amanpreet Singh\Desktop\its a server\gamemodes\elitedrift.pwn(553) : error 017: undefined symbol "idx"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


7 Errors.
Reply
#9

pawn Код:
new idx = 0;
Reply
#10

hey just wanted to say that i used autins /cc script that he put up their but when i do /cc 1 1 the car colour isnt white or /cc 3 3 its not red it only when i do /cc the car colour turns black.

sorry if im a bit annoying lol but could someone help me on that aswell?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)