/cc - CarColour
#1

Right now, I'm busy eliminating the use of filterscripts from my current GM. I'm working on making a /cc [0-255] [0-255] command, to replace the filterscript I have for it. Here's what I've got so far:
pawn Код:
CMD:cc(playerid, params[])
{
    new
        colour1,
        colour2
    ;
    if(sscanf(params, "ii", colour1, colour2)) SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");
    if(!isnull(params))
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);
        else SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");
    }
    return 1;
}
I want this command to do the following (to make it better than the entire filterscript I had for it):
  • To send a message that shows what colour the player selected (e.g. You've selected color [id]) and if it's using the 2nd colour as well, then it would say "You've selected color [id] and [id]".
  • I want it to make both colour1 and colour2 the same if colour1 is the only colour used (in other words, if someone typed /cc 3, then it would make the car solid red [now it makes the car solid red but with black stripes]).
Reply
#2

pawn Код:
CMD:cc(playerid, params[])
{
    new
        colour1,
        colour2
    ;
    if(sscanf(params, "ii", colour1, colour2)) SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");
   SendClientMessage(playerid,-1,You have changed your car color to [%d] and [%d],colour1,colour2);//I added this
    if(!isnull(params))
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);
        else SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");
    }
    return 1;
}
It will not Send Client Message also.
Reply
#3

Quote:
Originally Posted by Dare Devil.....
Посмотреть сообщение
pawn Код:
CMD:cc(playerid, params[])
{
    new
        colour1,
        colour2
    ;
    if(sscanf(params, "ii", colour1, colour2)) SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");
   SendClientMessage(playerid,-1,You have changed your car color to [%d] and [%d],colour1,colour2);//I added this
    if(!isnull(params))
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);
        else SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");
    }
    return 1;
}
It will not Send Client Message also.
I've already tried it but the problem regarding the "solid colour" still remains. If I type /cc 3 it will make the main colour red but it will also leave the black stripes. I wish to set it up so that if the player only types one colour ID, that the vehicle is a solid colour as opposed to that colour and black.
Reply
#4

I have no idea if this will work as I don't have SA-MP installed. Give it a go and we'll talk later.

pawn Код:
CMD:cc(playerid, params[])
{

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");

    new
        colour1,
        colour2
    ;

    if(sscanf(params, "iI", colour1, colour2))

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");

    if(isnull(params[1]))
   
    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour1);

    else

    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);

    return 1;
}
Reply
#5

Quote:
Originally Posted by YouareX
Посмотреть сообщение
I have no idea if this will work as I don't have SA-MP installed. Give it a go and we'll talk later.

pawn Код:
CMD:cc(playerid, params[])
{

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");

    new
        colour1,
        colour2
    ;

    if(sscanf(params, "iI", colour1, colour2))

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");

    if(isnull(params[1]))
   
    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour1);

    else

    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);

    return 1;
}
When I compile, I get an error on this line:
Код:
if(isnull(params[1])) ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour1);
Reply
#6

Shall we try this then?

pawn Код:
CMD:cc(playerid, params[])
{

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");

    new
        colour1,
        colour2 = -1;
    ;

    if(sscanf(params, "iI", colour1, colour2))

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");

    if(colour2 != -1)
   
    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);

    else

    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour1);

    return 1;
}
After this one, I'm useless...
Reply
#7

Wth do you need the !isnull line.. it can work without it:

pawn Код:
CMD:cc(playerid, params[])
{
    new
        colour1,
        colour2
    ;
    if(sscanf(params, "ii", colour1, colour2)) SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);
        else SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");
    }
    return 1;
}
Reply
#8

Here's mine. Works great.
pawn Код:
CMD:color(playerid,params[])
{        
        new col[2],string[128];
        if(sscanf(params, "dd",col[0],col[1])) return SendClientMessage(playerid, COLOR_RED, "Usage: /color [Color 1] [Color 2]");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be in a car!");
        ChangeVehicleColor(GetPlayerVehicleID(playerid), col[0],col[1]);
        format(string,sizeof(string),""COL_GREEN"You changed color on your car to: (%d) (%d)",col[0],col[1]);
        SendClientMessage(playerid,-1,string);
        return 1;
}
Reply
#9

Quote:
Originally Posted by YouareX
Посмотреть сообщение
Shall we try this then?

pawn Код:
CMD:cc(playerid, params[])
{

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {FF0000}ERROR: {FFFFFF}You must be the driver of the vehicle in order to use this command.");

    new
        colour1,
        colour2 = -1;
    ;

    if(sscanf(params, "iI", colour1, colour2))

    return SendClientMessage(playerid, COLOR_CHARTREUSE, "(SERVER) {33CCFF}USAGE: {FFFFFF}/cc [0-255] [0-255]");

    if(colour2 != -1)
   
    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour2);

    else

    ChangeVehicleColor(GetPlayerVehicleID(playerid), colour1, colour1);

    return 1;
}
After this one, I'm useless...
So I've used this, but now, for some odd reason, when I want to make my car (I'm using a Banshee to test) flat white, instead, it makes the main colour white but then the other colour is a darker shade of red.
Reply
#10

Quote:
Originally Posted by mrsamp
Посмотреть сообщение
Here's mine. Works great.
pawn Код:
CMD:color(playerid,params[])
{        
        new col[2],string[128];
        if(sscanf(params, "dd",col[0],col[1])) return SendClientMessage(playerid, COLOR_RED, "Usage: /color [Color 1] [Color 2]");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be in a car!");
        ChangeVehicleColor(GetPlayerVehicleID(playerid), col[0],col[1]);
        format(string,sizeof(string),""COL_GREEN"You changed color on your car to: (%d) (%d)",col[0],col[1]);
        SendClientMessage(playerid,-1,string);
        return 1;
}
Your's does work but the issue is, you have to include both colour ids. What I want to do is make this command like your's, but instead of making 'colour2' a required parameter, I want to make it an optional parameter.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)