public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(!PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid)))
{
if(PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid) && PRESSED( KEY_LOOK_BEHIND )))
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128], rangepass = 0;
new Float:targetidpos[3];
if(GetPlayerInterior(targetid) > 0) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players inside an interior.");
if(GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"{FF0000}Error: Please wait 5 seconds before arresting a suspect again.");
if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid, red, "{FF0000}Error: This player is already in jail, you can't arrest them.");
if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"{FF0000}Error: You can't arrest players if they're in a vehicle.");
if(GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players with a wanted level lower than 4. Use /tk to issue a ticket, or press 2.");
if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not wanted, you can't arrest them");
if(playerid == targetid) return SendClientMessage(playerid,red, "{ff0000}Error: {ffffff}You can't arrest yourself.");
if(PlayerHasTakenDamage[playerid] == targetid) return SendClientMessage(playerid, RED, "[WARRING]: YOU CANNOT ARREST THIS PLAYER BECAUSE HE SHOOTED YOU...");
GetPlayerPos(playerid, targetidpos[0], targetidpos[1], targetidpos[2]);
if (!IsPlayerInRangeOfPoint(playerid, 5.0, targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1, "Error: Nobody close enough to arrest.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(IsPlayerConnected(targetid))
{
if(SWAT(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
rangepass++;
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~S.W.A.T AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] S.W.A.T AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(Army(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}A.R.M.Y AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~P~ARMY AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] A.R.M.Y AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(FBII(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}F.B.I AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~F.B.I AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] F.B.I AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(CIA(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}C.I.A AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~C.I.A AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] C.I.A AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(PoliceTeam(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}OFFICERAGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~OFFICER AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] OFFICER AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
}
}
}
return 1;
}
foreach(new targetid : Player)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(targetid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z)
{
//Put your whole arrest code here..
}
else return 0;
}
Instead of getting the position of every player and compare if the cop is in range, do the opposite. Get the cop's position only once before the loop and then check if criminals are in range. Also avoid returning 0.
|
new Float:X, Float:Y, Float:Z;
GetPlayerPos(targetid, X, Y, Z);
foreach(new targetid : Player)
{
if(IsPlayerInRangeOfPoint(targetid, 10, X, Y, Z)
{
//Put your whole arrest code here..
}
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128], rangepass = 0;
new Float:X, Float:Y, Float:Z;
if(PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid) && PRESSED( KEY_LOOK_BEHIND )))
{
if ((newkeys & KEY_LOOK_BEHIND) && IsPlayerInRangeOfPoint(targetid, 5.0, X, Y ,Z))
{
new Float:targetidpos[3];
if(GetPlayerInterior(targetid) > 0) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players inside an interior.");
if(GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"{FF0000}Error: Please wait 5 seconds before arresting a suspect again.");
if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid, red, "{FF0000}Error: This player is already in jail, you can't arrest them.");
if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"{FF0000}Error: You can't arrest players if they're in a vehicle.");
if(GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players with a wanted level lower than 4. Use /tk to issue a ticket, or press 2.");
if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not wanted, you can't arrest them");
if(playerid == targetid) return SendClientMessage(playerid,red, "{ff0000}Error: {ffffff}You can't arrest yourself.");
if(PlayerHasTakenDamage[playerid] == targetid) return SendClientMessage(playerid, RED, "[WARRING]: YOU CANNOT ARREST THIS PLAYER BECAUSE HE SHOOTED YOU...");
GetPlayerPos(playerid, targetidpos[0], targetidpos[1], targetidpos[2]);
if (!IsPlayerInRangeOfPoint(playerid, 5.0, targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1, "Error: Nobody close enough to arrest.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(IsPlayerConnected(targetid))
foreach(targetid : Player)
{
GetPlayerPos(targetid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z))
{
if(SWAT(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
rangepass++;
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~S.W.A.T AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] S.W.A.T AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(Army(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}A.R.M.Y AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~P~ARMY AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] A.R.M.Y AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(FBII(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}F.B.I AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~F.B.I AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] F.B.I AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(CIA(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}C.I.A AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~C.I.A AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] C.I.A AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(PoliceTeam(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}OFFICERAGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~OFFICER AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] OFFICER AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
}
}
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128], rangepass = 0;
if(PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid) && PRESSED( KEY_LOOK_BEHIND )))
{
if ((newkeys & KEY_LOOK_BEHIND))
{
foreach(targetid : Player)
{
GetPlayerPos(targetid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z))
{
new Float:targetidpos[3];
if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players inside an interior.");
if(GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"{FF0000}Error: Please wait 5 seconds before arresting a suspect again.");
if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid, red, "{FF0000}Error: This player is already in jail, you can't arrest them.");
if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"{FF0000}Error: You can't arrest players if they're in a vehicle.");
if(GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players with a wanted level lower than 4. Use /tk to issue a ticket, or press 2.");
if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not wanted, you can't arrest them");
if(playerid == targetid) return SendClientMessage(playerid,red, "{ff0000}Error: {ffffff}You can't arrest yourself.");
if(PlayerHasTakenDamage[playerid] == targetid) return SendClientMessage(playerid, RED, "[WARRING]: YOU CANNOT ARREST THIS PLAYER BECAUSE HE SHOOTED YOU...");
GetPlayerPos(playerid, targetidpos[0], targetidpos[1], targetidpos[2]);
if (!IsPlayerInRangeOfPoint(playerid, 5.0, targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1, "Error: Nobody close enough to arrest.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(IsPlayerConnected(targetid) && SWAT(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
rangepass++;
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~S.W.A.T AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] S.W.A.T AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(Army(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}A.R.M.Y AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~P~ARMY AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] A.R.M.Y AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(FBII(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}F.B.I AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~F.B.I AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] F.B.I AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(CIA(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}C.I.A AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~C.I.A AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] C.I.A AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(PoliceTeam(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}OFFICERAGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~OFFICER AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] OFFICER AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
}
}
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new pName[MAX_PLAYER_NAME],tName[MAX_PLAYER_NAME],targetid,string[128], rangepass = 0;
new Float:X, Float:Y, Float:Z;
if ((newkeys & KEY_LOOK_BEHIND))
{
if(!PoliceTeam(GetPlayerSkin(playerid)) && !SWAT(GetPlayerSkin(playerid)) && !Army(GetPlayerSkin(playerid)) && !FBII(GetPlayerSkin(playerid)) && !CIA(GetPlayerSkin(playerid)))
{
foreach(targetid : Player)
{
GetPlayerPos(targetid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z)) return SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}There are no engouh players to arrest.");
{
new Float:targetidpos[3];
if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players inside an interior.");
if(GetPVarInt(playerid,"ArTime")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"{FF0000}Error: Please wait 5 seconds before arresting a suspect again.");
if(PlayerInfo[targetid][pJailed] == 1) return SendClientMessage(playerid, red, "{FF0000}Error: This player is already in jail, you can't arrest them.");
if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid,red,"{FF0000}Error: You can't arrest players if they're in a vehicle.");
if(GetPlayerWantedLevel(targetid) <= 3) return SendClientMessage(playerid, red, "{FF0000}Error: You can't arrest players with a wanted level lower than 4. Use /tk to issue a ticket, or press 2.");
if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, red, "{FF0000}Error: This player is not wanted, you can't arrest them");
if(playerid == targetid) return SendClientMessage(playerid,red, "{ff0000}Error: {ffffff}You can't arrest yourself.");
if(PlayerHasTakenDamage[playerid] == targetid) return SendClientMessage(playerid, RED, "[WARRING]: YOU CANNOT ARREST THIS PLAYER BECAUSE HE SHOOTED YOU...");
GetPlayerPos(playerid, targetidpos[0], targetidpos[1], targetidpos[2]);
if (!IsPlayerInRangeOfPoint(playerid, 5.0, targetidpos[0], targetidpos[1], targetidpos[2])) return SendClientMessage(playerid, -1, "Error: Nobody close enough to arrest.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, tName, sizeof(tName));
if(IsPlayerConnected(targetid) && Civilian(GetPlayerSkin(targetid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
rangepass++;
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}S.W.A.T AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~S.W.A.T AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] S.W.A.T AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(Army(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}A.R.M.Y AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~P~ARMY AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] A.R.M.Y AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(FBII(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}F.B.I AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~F.B.I AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] F.B.I AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(CIA(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}C.I.A AGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~C.I.A AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] C.I.A AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
if(PoliceTeam(GetPlayerSkin(playerid)))
{
if(GetPlayerWantedLevel(targetid) >= 4 && GetPlayerWantedLevel(targetid) <= 30)
{
SecondsToJail[targetid] = SetTimerEx("JailPlayer",5000,0,"i",targetid);
TryingArrested[playerid] = 1;
ArrestingPlayer[targetid] = playerid;
format(string, sizeof(string), "{0080FF}[BEING ARRESTED]: {FFFFFF}OFFICERAGENT %s(%d) has put {ADFF2F}handcuffs {FFFFFF}on you.", pName, playerid);
SendClientMessage(targetid, red, string);
SetPlayerAttachedObject(targetid, 9, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000);
SetPlayerSpecialAction(targetid, SPECIAL_ACTION_CUFFED);
format(string, sizeof(string), "~W~AN ~B~OFFICER AGENT %s(%d) ~W~HAS CUFFED YOU!!~n~~b~TYPE [/BC] TO ESCAPE FROM THE ~Y~CUFFS", pName, playerid);
GameTextForPlayer(targetid, string, 4000, 5);
format(string, sizeof(string), "{33B5FF}[BEGIN ARREST!!!] OFFICER AGENT %s(%d) is trying to arrest you!! {33B5FF}Use /BC for escape from this arrest!!", pName, playerid);
SendClientMessage(targetid, red, string);
format(string, sizeof(string), "{ffffff}You have placed {0080FF}%s(%d) {FFFFFF}in handcuffs for an arrest. Use {0080FF}/search (id) {FFFFFF}to search them for illegal Drugs.", tName, targetid);
SendClientMessage(playerid, red, string);
SetPVarInt(playerid,"ArTime",GetTickCount()+5000);
return 1;
}
}
}
}
}
}
return 1;
}
Thank you.. BUT When I trying to make only cops can use this command they did it differnet Example: I do only cops can use it but now CIVILIN Who's can use it only :/ idk why HELP ME TO MAKE ONLY COPS CAN USE THIS COMMAND...
|