09.12.2016, 00:12
There is some errors plus I don't like at all (it's personal) a code which is interlinked.
PHP Code:
CMD:uncuff(playerid, params[])
{
if(gTeam[playerid] != LSPD)
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: Only cops and use this command!");
new targetid; // To store the player id which is the target.
if(sscanf(params, "u", targetid))
return SendClientMessage(playerid, 0xFF00FF, "USAGE: /uncuff (PlayerID)"); // Store an ID (or INVALID_PLAYER_id if the playerid is wrong)
if(!IsPlayerConnected(targetid)) // The player is NOT ('!' mean NOT) connected so we return an error message
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: Invalid ID!");
new // 3 variables to store x, y, z, target's coord.
Float:x,
Float:y,
Float:z;
GetPlayerPos(targetid, x, y, z); // Get these coord'
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) // Check if the player is in the range of the target.
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: That player is too far away from you!");
if(gTeam[targetid] == LSPD) // if the target is law enforcer
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: you can't use this on a law enforcer!");
if(!IsCuffed[targetid]) // if the player is NOT cuffed so we can't uncuff him
return SendClientMessage(playerid, 0xFF0000, "[ERROR]: This player is not cuffed!");
new
string[35+MAX_PLAYER_NAME], // the string to send a message
targetname[MAX_PLAYER_NAME], // string to store the target's name
playername[MAX_PLAYER_NAME]; // string to store the player's name
GetPlayerName(playerid, playername, sizeof(playername); // Store the player name
format(string, sizeof(string), "You have been uncuffed by officer %s", playername)); // Send a formated message which %s is remplaced by player's name
SendClientMessage(targetid, 0x0000FF, string);
GetPlayerName(targetid, targetname, sizeof(targetname));
format(string, sizeof(string), "You have uncuffed %s ", targetname))
SendClientMessage(playerid, 0xCCFF00, string));
if(IsPlayerAttachedObjectSlotUsed(targetid, 8)) // If the player have an object (handcuff) » we check it
RemovePlayerAttachedObject(targetid, 8); // So remove the object
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_NONE); // Remove any special action
IsCuffed = false;
return 1;
}