[Tutorial] /cuff and /uncuff Tutorial (sscanf)+(ZCMD)
#7

There is some errors plus I don't like at all (it's personal) a code which is interlinked.
PHP Code:
CMD:uncuff(playeridparams[])
{
    if(
gTeam[playerid] != LSPD)
        return 
SendClientMessage(playerid0xFF0000"[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(playerid0xFF00FF"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(playerid0xFF0000"[ERROR]: Invalid ID!");

    new 
// 3 variables to store x, y, z, target's coord. 
        
Float:x,
        
Float:y,
        
Float:z;

    
GetPlayerPos(targetidxyz); // Get these coord'
    
if(!IsPlayerInRangeOfPoint(playerid5xyz)) // Check if the player is in the range of the target.
        
return SendClientMessage(playerid0xFF0000"[ERROR]: That player is too far away from you!");

    if(
gTeam[targetid] == LSPD// if the target is law enforcer
        
return SendClientMessage(playerid0xFF0000"[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(playerid0xFF0000"[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(playeridplayernamesizeof(playername); // Store the player name
    
format(stringsizeof(string), "You have been uncuffed by officer %s"playername)); // Send a formated message which %s is remplaced by player's name
    
SendClientMessage(targetid0x0000FFstring);

    
GetPlayerName(targetidtargetnamesizeof(targetname));
    
format(stringsizeof(string), "You have uncuffed %s "targetname))
    
SendClientMessage(playerid0xCCFF00string));

    if(
IsPlayerAttachedObjectSlotUsed(targetid8)) // If the player have an object (handcuff) » we check it
        
RemovePlayerAttachedObject(targetid8); // So remove the object

    
SetPlayerSpecialAction(targetidSPECIAL_ACTION_NONE); // Remove any special action
    
IsCuffed false;
    
    return 
1;

Reply


Messages In This Thread
/cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Eoussama - 01.10.2016, 14:58
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Kruno88 - 01.10.2016, 15:11
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by SyS - 01.10.2016, 15:14
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by AndySedeyn - 01.10.2016, 15:53
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Eoussama - 01.10.2016, 16:11
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Eoussama - 08.12.2016, 10:24
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Dayrion - 09.12.2016, 00:12
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by XxFiGhteRXx - 31.12.2016, 10:36
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Stinged - 31.12.2016, 10:51
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Triggerz - 22.01.2017, 18:57
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by RyderX - 22.01.2017, 19:29
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by PaRking - 22.01.2017, 19:35
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by RyderX - 22.01.2017, 19:36
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by PaRking - 22.01.2017, 19:38
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by RyderX - 22.01.2017, 19:39
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Eoussama - 22.01.2017, 19:40
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Triggerz - 22.01.2017, 19:43
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Triggerz - 22.01.2017, 19:45
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by RyderX - 22.01.2017, 19:49
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Eoussama - 22.01.2017, 19:50
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by Triggerz - 22.01.2017, 19:54
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by JohnFlores - 24.07.2017, 14:22
Re: /cuff and /uncuff Tutorial (sscanf)+(ZCMD) - by coool - 24.07.2017, 15:16

Forum Jump:


Users browsing this thread: 6 Guest(s)