30.10.2014, 01:15
I've been trying to make an admin level 5 command to do /carcolor, or /cc [color1] [color2] but, it hasn't seemed to have been working properly, it has messed up other commands. I do not use sscanf or the others, and I don't really intend to.
Here is what I've done so far:
Here is what I've done so far:
Код:
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;
}


