if (IsPlayerAdmin(playerid) || adlvl[playerid] == 5) { if (strcmp(string, "/acolor1", true) == 0) return SendClientMessage2(playerid, COLOR_RED, "Server: Unknown command."); if (pvehicle[playerid][0] == 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You must own a car to change its color!"); tmp = strtok(cmdtext, idx); if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_ORANGE, "Usage: /acolor1 [color]"); giveplayerid = strval(tmp); if (giveplayerid < 0 || giveplayerid > 255 || !isNumeric(tmp)) SendClientMessage2(playerid, COLOR_RED, "Invalid color id! (0 - 255)"); vehcol[pvehicle[playerid][0]][0] = giveplayerid; ChangeVehicleColor(pvehicle[playerid][0], giveplayerid, vehcol[pvehicle[playerid][0]][1]); format(string, 128, "You have changed your vehicles first color to %d.", giveplayerid); SendClientMessage2(playerid, COLOR_WHITE, string); return 1; } if (IsPlayerAdmin(playerid) || adlvl[playerid] == 5) { if (strcmp(string, "/acolor2", true) == 0) return SendClientMessage2(playerid, COLOR_RED, "Server: Unknown command."); if (pvehicle[playerid][0] == 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You must own a car to change its color!"); tmp = strtok(cmdtext, idx); if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_ORANGE, "Usage: /acolor2 [color]"); giveplayerid = strval(tmp); if (giveplayerid < 0 || giveplayerid > 255 || !isNumeric(tmp)) SendClientMessage2(playerid, COLOR_RED, "Invalid color id! (0 - 255)"); vehcol[pvehicle[playerid][0]][1] = giveplayerid; ChangeVehicleColor(pvehicle[playerid][0], vehcol[pvehicle[playerid][0]][0], giveplayerid); format(string, 128, "You have changed your vehicles second color to %d.", giveplayerid); SendClientMessage2(playerid, COLOR_WHITE, string); return 1; }
I do not use sscanf or the others, and I don't really intend to.
|
CMD:carcolor(playerid, params[])
{
new val[2];
if(adminlevel[playerid] < 5) return false;
if(sscanf(params, "ii", val[0], val[1])) return SendClientMessage(playerid, 0xff0000aa, "/carcolor [color 1] [color 2]");
if(val[0] < 0 || val[0] > 255 || val[1] < 0 || val[1] > 255) return SendClientMessage(playerid, 0xff0000aa, "Invalid color id! (0 - 255)");
if(pvehicle[playerid][0] == 0) return SendClientMessage(playerid, 0xff0000aa, "You don't own a car!");
new str[56];
format(str, sizeof(str), "You have changed your car color(s) to %d and %d.", val[0], val[1]);
SendClientMessage(playerid, 0xffff00aa, str);
for(new i; i < 2; i ++)
{
vehcol[pvehicle[playerid][0]][i] = val[i];
}
ChangeVehicleColor(pvehicle[playerid][0], val[0], val[1]);
return true;
}