[Help]Cuffing system -
Riven - 29.06.2013
Hello, can please anybody explain to me or help me in making a small script that when you press Left CTRL near a suspect it places cuffs on him and he can't move? I already have a system but with the command /cuff but I would like it with left CTRL , thanks in advance.
Re: [Help]Cuffing system -
Scenario - 29.06.2013
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
I really wish people would search before posting. This is becoming extremely annoying.
Re: [Help]Cuffing system -
Riven - 29.06.2013
I already searched and got to this Mr. , I would appreciate some help with the 'cuffing' system, not the buttons.
Re: [Help]Cuffing system -
Scenario - 29.06.2013
It's basically the same thing as the /cuff command. If you have to specify an ID in the /cuff command, then it's a LITTLE different. Otherwise, it's basically the same.
Re: [Help]Cuffing system -
Riven - 29.06.2013
Not with inserting a player's id, but being in a specific range of a suspect.
Re: [Help]Cuffing system -
Scenario - 29.06.2013
Then it's the same thing. Port the same code under OnPlayerKeyStateChange.
Re: [Help]Cuffing system -
Riven - 29.06.2013
this is the system currently:
Код:
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(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(InAdminMode[ID] == 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
return 1;
}
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_ARMY && gTeam[playerid] != TEAM_CIA)
{
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] == TEAM_COP || gTeam[ID] == TEAM_ARMY || gTeam[ID] == TEAM_CIA)
{
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(IsFrozen[ID] == 1)
{
format(string,sizeof(string),"%s(%d) is frozen by a Server Administrator. You cannot place cuffs them.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(AttemptedToCuffRecently[playerid] >= 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You're handcuffs are stuck in the lock from your last attempt. Please wait until they get unstuck first.");
return 1;
}
new crand = random(100);
if(crand <= 30)
{
SendClientMessage(playerid,COLOR_ERROR,"Cuff attempt failed. The suspect's arm slipped out of your hands.");
AttemptedToCuffRecently[playerid] =25;
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 30)
{
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_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_DEADCONNECT,"[[_Placed in handcuffs_]]");
format(string,sizeof(string),"Law enforcement officer %s(%d) has placed you in handcuffs! You cannot move! You will be auto uncuffed in 30 seconds.",PlayerName(playerid),playerid);
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;
}
Re: [Help]Cuffing system -
Riven - 29.06.2013
^ Where to use the OnPlayerKeyStateChange ?
Re: [Help]Cuffing system -
Riven - 30.06.2013
Help please?
Re: [Help]Cuffing system -
drichie - 30.06.2013
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
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(InAdminMode[ID] == 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
return 1;
}
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_ARMY && gTeam[playerid] != TEAM_CIA)
{
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] == TEAM_COP || gTeam[ID] == TEAM_ARMY || gTeam[ID] == TEAM_CIA)
{
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(IsFrozen[ID] == 1)
{
format(string,sizeof(string),"%s(%d) is frozen by a Server Administrator. You cannot place cuffs them.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(AttemptedToCuffRecently[playerid] >= 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You're handcuffs are stuck in the lock from your last attempt. Please wait until they get unstuck first.");
return 1;
}
new crand = random(100);
if(crand <= 30)
{
SendClientMessage(playerid,COLOR_ERROR,"Cuff attempt failed. The suspect's arm slipped out of your hands.");
AttemptedToCuffRecently[playerid] =25;
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 30)
{
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_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_DEADCONNECT,"[[_Placed in handcuffs_]]");
format(string,sizeof(string),"Law enforcement officer %s(%d) has placed you in handcuffs! You cannot move! You will be auto uncuffed in 30 seconds.",PlayerName(playerid),playerid);
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;
}
return 1;
}