16.08.2015, 10:46
Quote:
Good Morning Everyone!.
I would like to know why is this script not working? The color doesn't changes properly. Код:
if (strcmp("/vehcolor", cmd, true) == 0) { new Color1[128]; new Color2[128]; new currentveh; Color1 = strtok(cmdtext, idx); Color2 = strrest(cmdtext, idx); currentveh = GetPlayerVehicleID(playerid); if(!IsPlayerInVehicle(playerid, currentveh)) { SendClientMessage(playerid, COLOR_RED,"You must be in a vehicle to do this action!"); return 1; } if (strval(Color1) > 255) { SendClientMessage(playerid, COLOR_RED, "Invalid Color ID"); return 1; } if (strval(Color2) > 255) { SendClientMessage(playerid, COLOR_RED, "Invalid Color ID"); return 1; } else { new string[128]; ChangeVehicleColor(currentveh, strval(Color1), strval(Color2)); format(string,sizeof(string),"Your car color have been changed to (ID: %d) and (ID: %d)", strval(Color1), strval(Color2)); SendClientMessage(playerid, COLOR_GREEN, string); return 1; } } |
Why don't You use zcmd, which is a way more better and easier? And then Your code would look like this:
pawn Код:
COMMAND:vehcolor ( playerid, params[] ) {
if( !IsPlayerInAnyVehicle( playerid ) ) // If player is not in vehicle, then don't do anything.
return true;
new Color[2];
if( sscanf(params, "dd", Color[0], Color[1] ) ) {
SendClientMessage( playerid, -1, "Usage: /vehcolor [0-255] [0-255]");
return true;
}
if( Color[0] < 0 || Color[1] < 0 ||
Color[0] > 255 || Color[1] > 255
) {
SendClientMessage( playerid, -1, "Invalid color pair.");
return true;
}
if( ChangeVehicleColor( GetPlayerVehicleID( playerid ), Color[0], Color[1] ) ) {
new Output[64];
format( Output, 64, "Your car color have been changed to (ID: %d) and (ID: %d)", Color[0], Color[1] );
// Max output length for this one is 59
SendClientMessage( playerid, -1, Output );
} else {
SendClientMessage( playerid, -1, "Failed to change the color. Try again." );
}
return true;
}