how to make breakcuff command?
#1

Hi guys I'm just wondering how to make a breakcuff CMD. I wanna make it random, 50% success 50% fail. The suspect must wait 30 seconds before attempting to breakcuff again.

This is my cuff command
pawn Код:
dcmd_cuff(playerid,params[])
{
    new string[128];
    new ID;
    if(sscanf(params, "u", ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /cuff (Player Name/ID)");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != FBI && gTeam[playerid] != ARMY)
    {
        SendClientMessage(playerid,COLOR_ERROR,"Only law enforcement can place cuffs on suspects.");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot cuff them",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 4)
    {
        format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to place cuffs on him.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(gTeam[ID] == COP || gTeam[ID] == SWAT || gTeam[ID] == FBI || gTeam[ID] == ARMY)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot place other Law Enforcement officer in cuffs. You might lose your job for that ..");
        return 1;
    }
    if(IsCuffed[ID] == 1)
    {
        format(string,sizeof(string),"%s(%d) is already cuffed. You don't want to waste a second pair of cuffs on them.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while in a vehicle. Exit the vehicle first.");
        return 1;
    }
    if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while they are in a vehicle. Get them to exit the vehicle first.");
        return 1;
    }
    if(playerid == ID)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot put cuffs on yourself, it wouldn't be a good idea with rapists around.");
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"%s(%d) is not spawned. You cannot place cuffs on dead people ..",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
     if(GetDistanceBetweenPlayers(playerid,ID) <= 4)
        {
        SendClientMessage(playerid,COLOR_WHITE,"[[_Suspect Cuffed_]]");
        format(string,sizeof(string),"You have placed cuffs on %s(%d)! They can no longer move.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        SendClientMessage(ID,COLOR_LIGHTBLUE,"[[_Placed in handcuffs_]]");
        format(string,sizeof(string),"Law enforcement officer %s(%d) has placed you in handcuffs!",PlayerName(playerid),playerid);
        SendClientMessage(ID,COLOR_LIGHTBLUE,string);
        TogglePlayerControllable(ID,0);
        ApplyAnimation(ID, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
        IsCuffed[ID] =1;
        return 1;
    }
    return 1;
}
Hope you guys can give me some tips, advices, etc.
Reply
#2

It's quite simple, as you can see you got a variable IsCuffed[ID] = 1 on the cuff thing.
What you'll do next is:
pawn Код:
//Same shit about distances, or if player isn't cuffed, etc..

if(IsCuffed[ID] == 0)
{
format(string, sizeof(string), "%s ain't cuffed nigga.", PlayerName(ID));
SendClientMessage(playerid, -1, string);
}


//Then let's uncuff him, with you CMD, you will put the following:

IsCuffed[ID] = 0; // Not cuffed
TogglePlayerControllable(ID,1); //Controllable
ClearAnimations(ID); //Removing the animation off the player
Reply
#3

Yes, but I'm trying to make a timer like, ''You are breaking the cuffs! Please wait 10 seconds'' ''The cuffs is now broken'' if SUCCESS.
If fail, you have to wait 30 seconds again.

EDIT: the suspect breaking his cuffs himself. (ik it doesnt sound realistic :P)
Reply
#4

Hmmm, all you do is a timer for braking the cuffs...
Kill that timer if another cop approaches him(I guess that's what you want?)..

Also:
pawn Код:
if(IsCuffed[playerid] == 0) return SendClientMessage(playerid, -1, "You are not even cuffed!");
It's a bit simple, just use a timer, kill that timer if the operation has stopped.
Inside that timer, you will put:
pawn Код:
IsCuffed[playerid] = 0; // Not cuffed
TogglePlayerControllable(playerid,1); //Controllable
ClearAnimations(playerid); //Removing the animation off the player
SendClientMessage(playerid, -1, "You have broken out of your cuffs!");
Hope this helps you realize how to create the command.
Reply
#5

''Kill that timer if another cop approaches him(I guess that's what you want?)..'' Yeah I like that idea too!

I never make a timer. But I'll try, will reply soon!
Reply
#6

it is realistic, you're requesting something long.. okay,
pawn Код:
new CuffTimer[MAX_PLAYERS];
new CuffBreakFailed[MAX_PLAYERS];
//OnGameModeInIt
    SetTimer("PlayerOneSecondVariables",1000,1);
   
forward PlayerOneSecondVariables();
public PlayerOneSecondVariables()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(CuffTimer[i] >= 1)
        {
           CuffTimer[i] --;
        }
        if(CuffTimer[i] == 0)
        {
           new frand =random(10);
           if(frand < 6)
           {
              SendClientMessage(i, -1,"You've succefully broken your cuffs!");
              IsCuffed[i] =0;
              ClearAnimations(i);
           }
           if(frand > 5)
           {
              SendClienrMessage(i, -1,"You've failed to break your cuffs!");
              CuffBreakFailed[i] =30;
           }
        }
        if(CuffBreakFailed[i] >= 1)
        {
           CuffBreakFailed[i] --;
        }
     }
     return 1;
}

dcmd_breakcuff(playerid,params[])
{
    #pragma unused params
    new string[128];
    new ID;
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(IsCuffed[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You're not currently cuffed.");
        return 1;
    }
    if(CuffBreakFailed[i] > 1)
    {
        SendClientMessage(playerid, COLOR_RED, "You've recently tried but failed, please wait.");
        return 1;
    }
    CuffTimer[playerid] =10;
    SendClientMessage(playerid, -1,"You are breaking cuffs, please wait 10 seconds.");
    return 1;
}
Reply
#7

ahh thats so easy does that help?
Код:
dcmd_breakcuff(playerid,params[])
{
	new string[128];
	new ID;
	if(sscanf(params, "u", ID))
	{
	    return 1;
	}
    if(IsSpawned[playerid] != 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
	if(IsFrozen[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
	    return 1;
	}
 if(IsCuffed[ID] == 0)
{
format(string, sizeof(string), "%s ain't cuffed nigga.", PlayerName(ID));
SendClientMessage(playerid, -1, string);
}


//Then let's uncuff him, with you CMD, you will put the following:

        IsCuffed[ID] = 0; // Not cuffed
        TogglePlayerControllable(ID,1); //Controllable
        ClearAnimations(ID); //Removing the animation off the player
	    format(string,sizeof(string),"%s(%d) is already cuffed. You don't want to waste a second pair of cuffs on them.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(AttemptedToCuffRecently[playerid] >= 1)
	{
		SendClientMessage(playerid,COLOR_ERROR,"Please Wait Before Breaking cuffs Again");
		return 1;
	}
	new crand = random(100);
	if(crand <= 30)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"Fail HAHAHAHAHA");
		AttemptedToCuffRecently[playerid] =25;
		return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 30)
	{
	    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Suspect Cuffed_]]");
	    format(string,sizeof(string),"Cuff Broked!.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
	    SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Placed in handcuffs_]]")
		SendClientMessage(ID,COLOR_LIGHTBLUE,string);
		TogglePlayerControllable(ID,0);
	    LoopingAnim(ID, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
	    IsCuffed[ID] =1;
	    CuffTime[ID] =30;
	    return 1;
	}
	return 1;
}
that /uncuff will





or simply put this :
(this one i'll put it make ability to other players to uncuff theyre friends maybe just do /puncuff
Код:
dcmd_puncuff(playerid,params[])
{
	new string[128];
	new ID;
	if(sscanf(params, "u", ID))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"USAGE: /puncuff (Player Name/ID)");
	    return 1;
	}
    if(IsSpawned[playerid] != 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}
	if(IsFrozen[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
	    return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
	if(InAdminMode[ID] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot uncuff them",ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) > 4)
	{
	    format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to remove cuffs from him.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(IsCuffed[ID] == 0)
	{
	    format(string,sizeof(string),"%s(%d) is not cuffed. You cannot uncuff them.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You cannot remove a suspect's cuffs while in a vehicle. Exit the vehicle first.");
	    return 1;
	}
	if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You cannot remove a suspect's cuffs while they are in a vehicle. Get them to exit the vehicle first.");
	    return 1;
	}
	if(playerid == ID)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You cannot remove cuffs from yourself.");
	    return 1;
	}
	if(IsSpawned[ID] != 1)
	{
	    format(string,sizeof(string),"%s(%d) is not spawned. You cannot remove cuffs from dead people ..",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(IsFrozen[ID] == 1)
	{
	    format(string,sizeof(string),"%s(%d) is frozen by a Server Administrator. You cannot remove cuffs from them.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) <= 4)
	{
	    format(string,sizeof(string),"You have removed %s(%d)'s cuffs. They can now move again.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    format(string,sizeof(string),"%s(%d) has removed your cuffs! You can now move again!",PlayerName(playerid),playerid);
		SendClientMessage(ID,COLOR_ERROR,string);
		TogglePlayerControllable(ID,1);
	    IsCuffed[ID] =0;
	    StopLoopingAnim(ID);
	    CuffTime[ID] =0;
	    return 1;
	}
	return 1;
}
Reply
#8

enough stealing steve's script.
Reply
#9

Quote:
Originally Posted by Vanter
Посмотреть сообщение
it is realistic, you're requesting something long.. okay,
pawn Код:
new CuffTimer[MAX_PLAYERS];
new CuffBreakFailed[MAX_PLAYERS];
//OnGameModeInIt
    SetTimer("PlayerOneSecondVariables",1000,1);
   
forward PlayerOneSecondVariables();
public PlayerOneSecondVariables()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(CuffTimer[i] >= 1)
        {
           CuffTimer[i] --;
        }
        if(CuffTimer[i] == 0)
        {
           new frand =random(10);
           if(frand < 6)
           {
              SendClientMessage(i, -1,"You've succefully broken your cuffs!");
              IsCuffed[i] =0;
              ClearAnimations(i);
           }
           if(frand > 5)
           {
              SendClienrMessage(i, -1,"You've failed to break your cuffs!");
              CuffBreakFailed[i] =30;
           }
        }
        if(CuffBreakFailed[i] >= 1)
        {
           CuffBreakFailed[i] --;
        }
     }
     return 1;
}

dcmd_breakcuff(playerid,params[])
{
    #pragma unused params
    new string[128];
    new ID;
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(IsCuffed[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You're not currently cuffed.");
        return 1;
    }
    if(CuffBreakFailed[i] > 1)
    {
        SendClientMessage(playerid, COLOR_RED, "You've recently tried but failed, please wait.");
        return 1;
    }
    CuffTimer[playerid] =10;
    SendClientMessage(playerid, -1,"You are breaking cuffs, please wait 10 seconds.");
    return 1;
}
Wtf it keeps spamming ''You've succesfully break your cuffs'' you failed to break your cuffs etc. Now what?
Reply
#10

see does it work with changing this:
Код:
if(frand < 6)
           {
              SendClientMessage(i, -1,"You've succefully broken your cuffs!");
              IsCuffed[i] =0;
              ClearAnimations(i);
              continue;
           }
           if(frand > 5)
           {
              SendClienrMessage(i, -1,"You've failed to break your cuffs!");
              CuffBreakFailed[i] =30;
              continue;
           }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)