change vehicle colour
#1

i am using ZCMD. how can i change it to ifPlayerIsAdmin or whatever, then, the player can type /vcolour and change their car color from their car so they dont have to go to the transfenders?

like if player is rcon admin, they type /vcolour [colour 1] [colour 2]
Reply
#2

pawn Code:
CMD:colorcar(playerid, params[])
{
    new color[2];
    if(sscanf(params,"dD",color[0],color[1]))
    {
        return SendClientMessage(playerid, -1, "USAGE: /colorcar [color1] [color2]");
    }
    new
        string[128];
    format(string, sizeof(string), "You have change the vehicle's color 1 to %d and color 2 to %d!",color[0],color[1]);
    SendClientMessage(playerid, -1, string);
    ChangeVehicleColor(GetPlayerVehicleID(playerid),color[0],color[1]);
    return 1;
}
Reply
#3

Best to set vehicle color 2 to what color 1 is if it's left out, plus you don't check if they're actually in a vehicle.

pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(string, sizeof(string), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
Reply
#4

Quote:
Originally Posted by MP2
View Post
Best to set vehicle color 2 to what color 1 is if it's left out, plus you don't check if they're actually in a vehicle.

pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(string, sizeof(string), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
That code is such a fail. For one, you defined szSuccess, not string, so it would be:
pawn Code:
new string[44];
Then
pawn Code:
SendClientMessage(playerid, 0x00FF00FF, string);
Or:
pawn Code:
format(szSuccess, sizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
and, the command is /vcolor, but you have the message saying the command is /colorcar.


.... /facepalm
Reply
#5

First of all get off your high horse and realise I made a small mistake when editing SOMEONE ELSES code (Vincent's), and secondly szSuccess would be a better string name as 'string' 'polluted' the namespace.
It is not 'such a fail' - I made a small mistake in not changing the name of the string parameter in format(). You sir are a failure.

pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(szSuccess, sizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
Reply
#6

Quote:
Originally Posted by MP2
View Post
First of all get off your high horse and realise I made a small mistake when editing SOMEONE ELSES code (Vincent's), and secondly szSuccess would be a better string name as 'string' 'polluted' the namespace.
It is not 'such a fail' - I made a small mistake in not changing the name of the string parameter in format(). You sir are a failure.

pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(szSuccess, sizeof(szSuccess), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
thanks!! and how can i add this in it?
pawn Code:
if(IsPlayerVipMember(playerid))
if they not vip member, they cannot change vehicle color and it will say "you have to be vip member!"
Reply
#7

anyone? ^
Reply
#8

First you need to make Vip levels and then you can make it only for Vip.
Reply
#9

pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    If(IsPlayerVipMember(playerid)) else return SendClientMessage(playerid, -1, "You need to be vip to use this command");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(string, sizeof(string), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
Reply
#10

Quote:
Originally Posted by Rudy_
View Post
pawn Code:
CMD:vcolor(playerid, params[])
{
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, 0xFF0000FF, "You are not driving a vehicle.");
    If(IsPlayerVipMember(playerid)) else return SendClientMessage(playerid, -1, "You need to be vip to use this command");
    new color[2];
    if(sscanf(params, "iI(-1)", color[0], color[1]))
    {
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /colorcar [color1] <color2>");
    }
    if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
    new szSuccess[44];
    format(string, sizeof(string), "Vehicle colors changed to: {FFFFFF}%i and %i.", color[0], color[1]);
    SendClientMessage(playerid, 0x00FF00FF, szSuccess);
    ChangeVehicleColor(GetPlayerVehicleID(playerid), color[0], color[1]);
    return 1;
}
that is no working. idk why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)