31.12.2016, 10:51
Quote:
There is some errors plus I don't like at all (it's personal) a code which is interlinked.
PHP Code:
|
PHP Code:
CMD:uncuff(playerid, params[])
{
if(gTeam[playerid] != LSPD)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: Only cops and use this command!");
new targetid;
if(sscanf(params, "u", targetid))
return SendClientMessage(playerid, 0xFF00FFFF, "USAGE: /uncuff (PlayerID)");
if (targetid == INVALID_PLAYER_ID) // No need to call IsPlayerConnected
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: Invalid ID!");
new
Float:x,
Float:y,
Float:z;
GetPlayerPos(targetid, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: That player is too far away from you!");
if(gTeam[targetid] == LSPD)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: you can't use this on a law enforcer!");
if(IsCuffed[targetid] == false)
return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: This player is not cuffed!");
new
string[59]; // One string is enough, you can just reuse it.
GetPlayerName(playerid, string, 25);
format(string, sizeof (string), "You have been uncuffed by officer %s", string);
SendClientMessage(targetid, 0x0000FFFF, string);
GetPlayerName(targetid, string, 25);
format(string, sizeof (string), "You have uncuffed %s", string);
SendClientMessage(playerid, 0xCCFF00FF, string));
// No need to check if slot8 is used. If it is, it will remove the object, if it's not, the native will fail
RemovePlayerAttachedObject(targetid, 8);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE);
IsCuffed[targetid] = false; // You didn't add [targetid]
return 1;
}
You're not including the alpha (0xRRGGBBAA).
Yes, it's not used for anything in SendClientMessage, but if you don't put something there, 00 will be added to the left. Which makes it a completely different number.
0xFF0000 = 0x00FF0000 = Green
0xFF000000 = Red