aymeness81 Posted July 13, 2014 Share Posted July 13, 2014 Hello, I have a problem with an arresting script, Made by TAPL, Its a public one, But, I wanted to add somethiing and it didnt work.. The script is based all , on a team ("Police") , I wanted to make the script works with Military Team, SWAT Team, and Police Team. Server Side : ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------ ------ ------|Arrest System|------ ------ ------ ------ ------- ------- ------- ------- ------- ------- ------- ------- ------- local Display = textCreateDisplay() local Text1 = textCreateTextItem("Press H to jail the Arrested.", 0.5, 0.35, "high", 255, 255, 0, 255, 2, "center", "center", 255) textDisplayAddText(Display, Text1) local ArrestTimer = {} addEvent("setWantLevel", true) addEventHandler("setWantLevel", root, function(wL) local LegalStatus = getElementData(source, "LegalStatus") if LegalStatus ~= "Jailed" then setPlayerWantedLevel(source, wL) end end) addEvent("takeMoney", true) addEventHandler("takeMoney", root, function(amount) takePlayerMoney(source, amount) end) addEvent("warpPosAndIntAndDim", true) addEventHandler("warpPosAndIntAndDim", root, function(type, value, x, y ,z) local Cop = getElementData(source, "ArresterCop") if isElement(Cop) and not isPedInVehicle(source) then if type == "INT" then setElementInterior(source, value) elseif type == "DIM" then setElementDimension(source, value) end setElementPosition(source, x, y ,z) end end) addEvent("backMeToJail", true) addEventHandler("backMeToJail", root, function() local gDoors = gDoors[math.random(1, #gDoors-3)] local x, y, z, r = gDoors["JPosX"], gDoors["JPosY"], gDoors["JPosZ"], gDoors["JRot"] setElementPosition(source, x, y, z) setPedRotation(source, r) setElementInterior(source, 6) end) addEventHandler("onPlayerDamage", root, function(attacker, wp) if wp == 41 then return end if attacker and attacker ~= source then if getElementInterior(attacker) == 5 and getElementDimension(attacker) == 5 then return end if (getElementData ( source, "isPlayerKidnapped" )) then return end if getElementType(attacker) == "vehicle" then attacker = getVehicleController(attacker) end local attakerTeam = getPlayerTeam(attacker) local damagedTeam = getPlayerTeam(source) if attakerTeam and damagedTeam then if getTeamName(attakerTeam) ~= "Police" or getTeamName(attakerTeam) ~= "Military" then if getTeamName(damagedTeam) ~= "Police" or etTeamName(damagedTeam) ~= "Military" then local wL = getPlayerWantedLevel(attacker) if wL < 3 then for i, player in ipairs(getElementsByType("player")) do local team = getPlayerTeam(player) if team and getTeamName(team) == "Police" or getTeamName(team) == "Military" then local x1, y1, z1 = getElementPosition(attacker) local x2, y2, z2 = getElementPosition(player) local LegalStatus = getElementData(attacker, "LegalStatus") if LegalStatus ~= "Jailed" and getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 15 then setPlayerWantedLevel(attacker, 3) break end end end end else local wL = getPlayerWantedLevel(attacker) local LegalStatus = getElementData(attacker, "LegalStatus") if LegalStatus ~= "Jailed" and wL < 4 then setPlayerWantedLevel(attacker, 4) end end else local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if getTeamName(attakerTeam) == "Police" or getTeamName(attakerTeam) == "Military" and wL >= 3 and wp == 3 and not isPedDead(source) and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then setElementData(source, "ArresterCop", attacker) setElementData(source, "LegalStatus", "Arrested") showCursor(source, true) toggleAllControls(source, false, true, false) ArrestTimer[source] = setTimer(sendToJail, 40000, 1, source) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(source, "HackTime") or 0) > 0 then setElementData(source, "HackTime", false) setElementFrozen(source, false) exports.TopBarChat:sendClientMessage(getPlayerName(source).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end exports.TopBarChat:sendClientMessage("You Arrested "..getPlayerName(source).."!", attacker, 0, 255, 0) exports.TopBarChat:sendClientMessage("You have been Arrested by "..getPlayerName(attacker).."!", source, 255, 255, 0) setPedAnimation(source, "ROB_BANK", "SHP_HandsUp_Scr", false, false) setPedAnimation(attacker, "ped", "ARRESTgun", false, false) setTimer(function(arrested, attacker) setPedAnimation(arrested, false) setPedAnimation(attacker, false) end, 2500, 1, source, attacker) end end end end end) addEventHandler("onPlayerWasted", root, function(_, killer) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(source, "HackTime") or 0) > 0 then setElementData(source, "HackTime", false) exports.TopBarChat:sendClientMessage(getPlayerName(source).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end if killer and killer ~= source then local killerTeam = getPlayerTeam(killer) local killedTeam = getPlayerTeam(source) local wL = getPlayerWantedLevel(killer) local LegalStatus = getElementData(killer, "LegalStatus") if killerTeam and killedTeam then if getTeamName(killerTeam) ~= "Police" or getTeamName(killerTeam) ~= "Military" then if getTeamName(killedTeam) ~= "Police" or getTeamName(killedTeam) ~= "Military" then if LegalStatus ~= "Jailed" and (wL < 4) then setPlayerWantedLevel(killer, 4) end else if LegalStatus ~= "Jailed" and (wL <= 5) and not (wL > 6) then setPlayerWantedLevel(killer, wL+1) end end else local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if wL >= 3 and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then setElementData(source, "ArresterCop", killer) sendToJail(source) end end end end if not killer or killer == source or getElementType(killer) == "vehicle" then local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if wL >= 4 and LegalStatus ~= "Jailed" then for i, player in ipairs(getElementsByType("player")) do local team = getPlayerTeam(player) if team and getTeamName(team) == "Police" or getTeamName(team) == "Military" then local x1, y1, z1 = getElementPosition(source) local x2, y2, z2 = getElementPosition(player) if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 40 then sendToJail(source) break end end end end end for i, player in ipairs(getElementsByType("player")) do if (getElementData(player, "ArresterCop") == source) then freePrisoner(player) exports.TopBarChat:sendClientMessage("You escaped from the cop!", player, 255, 255, 0) end end end) addEventHandler("onPlayerTarget", root, function(player) if getControlState(source, "aim_weapon") and player and getElementType(player) == "player" then local targetTeam = getPlayerTeam(player) local sourceTeam = getPlayerTeam(source) local LegalStatus = getElementData(source, "LegalStatus") local x1, y1, z1 = getElementPosition(source) local x2, y2, z2 = getElementPosition(player) if targetTeam and getTeamName(targetTeam) == "Police" or getTeamName(targetTeam) == "Military" and sourceTeam ~= targetTeam then if LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then local wp = getPedWeapon(source) local wL = getPlayerWantedLevel(source) if wL < 2 and wp ~= 41 then if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 10 then setPlayerWantedLevel(source, 2) end end end end if sourceTeam and getTeamName(sourceTeam) == "Police" or getTeamName(sourceTeam) == "Military" and sourceTeam ~= targetTeam then local LegalStatus = getElementData(player, "LegalStatus") if LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then local wL = getPlayerWantedLevel(player) local currentgun = getPedWeapon(source) if getElementInterior(source) == 5 and getElementDimension(source) == 5 then return end if (getElementData ( player, "isPlayerKidnapped" )) then return end if not isPedDead(player) and (currentgun > 19) and (currentgun < 39) and (wL > 2) and (getElementHealth(player) <= 50) and getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 3 then setElementData(player, "ArresterCop", source) setElementData(player, "LegalStatus", "Arrested") showCursor(player, true) toggleAllControls(player, false, true, false) ArrestTimer[player] = setTimer(sendToJail, 40000, 1, player) exports.TopBarChat:sendClientMessage("You Arrested "..getPlayerName(player).."!", source, 0, 255, 0) exports.TopBarChat:sendClientMessage("You have been Arrested by "..getPlayerName(source).."!", player, 255, 0, 0) setPedAnimation(player, "ROB_BANK", "SHP_HandsUp_Scr", false, false) setPedAnimation(source, "ped", "ARRESTgun", false, false) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(player, "HackTime") or 0) > 0 then setElementData(player, "HackTime", false) setElementFrozen(player, false) exports.TopBarChat:sendClientMessage(getPlayerName(player).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end setTimer(function(arrested, attacker) setPedAnimation(arrested, false) setPedAnimation(attacker, false) end, 3000, 1, player, source) end end end end end) addEventHandler("onPlayerQuit", root, function() if isTimer(ArrestTimer[source]) then killTimer(ArrestTimer[source]) ArrestTimer[source] = nil end if bribeTimer[source] then bribeTimer[source] = nil end local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local LegalStatus = getElementData(source, "LegalStatus") local BailAmount = getElementData(source, "BailAmount") or 0 local JailTime = getElementData(source, "JailTime") or 0 local wL = getPlayerWantedLevel(source) or 0 if LegalStatus == "Free" or LegalStatus == false then setAccountData(account, "LegalStatus", "Free") setAccountData(account, "BailAmount", false) setAccountData(account, "JailTime", false) setAccountData(account, "wL", wL) elseif LegalStatus == "Arrested" then setAccountData(account, "LegalStatus", "Jailed") Link to comment
Max+ Posted July 13, 2014 Share Posted July 13, 2014 ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------ ------ ------|Arrest System|------ ------ ------ ------ ------- ------- ------- ------- ------- ------- ------- ------- ------- local Display = textCreateDisplay() local Text1 = textCreateTextItem("Press H to jail the Arrested.", 0.5, 0.35, "high", 255, 255, 0, 255, 2, "center", "center", 255) textDisplayAddText(Display, Text1) local ArrestTimer = {} addEvent("setWantLevel", true) addEventHandler("setWantLevel", root, function(wL) local LegalStatus = getElementData(source, "LegalStatus") if LegalStatus ~= "Jailed" then setPlayerWantedLevel(source, wL) end end) addEvent("takeMoney", true) addEventHandler("takeMoney", root, function(amount) takePlayerMoney(source, amount) end) addEvent("warpPosAndIntAndDim", true) addEventHandler("warpPosAndIntAndDim", root, function(type, value, x, y ,z) local Cop = getElementData(source, "ArresterCop") if isElement(Cop) and not isPedInVehicle(source) then if type == "INT" then setElementInterior(source, value) elseif type == "DIM" then setElementDimension(source, value) end setElementPosition(source, x, y ,z) end end) addEvent("backMeToJail", true) addEventHandler("backMeToJail", root, function() local gDoors = gDoors[math.random(1, #gDoors-3)] local x, y, z, r = gDoors["JPosX"], gDoors["JPosY"], gDoors["JPosZ"], gDoors["JRot"] setElementPosition(source, x, y, z) setPedRotation(source, r) setElementInterior(source, 6) end) addEventHandler("onPlayerDamage", root, function(attacker, wp) if wp == 41 then return end if attacker and attacker ~= source then if getElementInterior(attacker) == 5 and getElementDimension(attacker) == 5 then return end if (getElementData ( source, "isPlayerKidnapped" )) then return end if getElementType(attacker) == "vehicle" then attacker = getVehicleController(attacker) end local attakerTeam = getPlayerTeam(attacker) local damagedTeam = getPlayerTeam(source) if attakerTeam and damagedTeam then if getTeamName(attakerTeam) ~= "Police" and getTeamName(attakerTeam) ~= "Military" then if getTeamName(damagedTeam) ~= "Police" and getTeamName(damagedTeam) ~= "Military" then local wL = getPlayerWantedLevel(attacker) if wL < 3 then for i, player in ipairs(getElementsByType("player")) do local team = getPlayerTeam(player) if team and getTeamName(team) == "Police" and getTeamName(team) == "Military" then local x1, y1, z1 = getElementPosition(attacker) local x2, y2, z2 = getElementPosition(player) local LegalStatus = getElementData(attacker, "LegalStatus") if LegalStatus ~= "Jailed" and getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 15 then setPlayerWantedLevel(attacker, 3) break end end end end else local wL = getPlayerWantedLevel(attacker) local LegalStatus = getElementData(attacker, "LegalStatus") if LegalStatus ~= "Jailed" and wL < 4 then setPlayerWantedLevel(attacker, 4) end end else local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if getTeamName(attakerTeam) == "Police" and getTeamName(attakerTeam) == "Military" and wL >= 3 and wp == 3 and not isPedDead(source) and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then setElementData(source, "ArresterCop", attacker) setElementData(source, "LegalStatus", "Arrested") showCursor(source, true) toggleAllControls(source, false, true, false) ArrestTimer[source] = setTimer(sendToJail, 40000, 1, source) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(source, "HackTime") or 0) > 0 then setElementData(source, "HackTime", false) setElementFrozen(source, false) exports.TopBarChat:sendClientMessage(getPlayerName(source).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end exports.TopBarChat:sendClientMessage("You Arrested "..getPlayerName(source).."!", attacker, 0, 255, 0) exports.TopBarChat:sendClientMessage("You have been Arrested by "..getPlayerName(attacker).."!", source, 255, 255, 0) setPedAnimation(source, "ROB_BANK", "SHP_HandsUp_Scr", false, false) setPedAnimation(attacker, "ped", "ARRESTgun", false, false) setTimer(function(arrested, attacker) setPedAnimation(arrested, false) setPedAnimation(attacker, false) end, 2500, 1, source, attacker) end end end end end) addEventHandler("onPlayerWasted", root, function(_, killer) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(source, "HackTime") or 0) > 0 then setElementData(source, "HackTime", false) exports.TopBarChat:sendClientMessage(getPlayerName(source).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end if killer and killer ~= source then local killerTeam = getPlayerTeam(killer) local killedTeam = getPlayerTeam(source) local wL = getPlayerWantedLevel(killer) local LegalStatus = getElementData(killer, "LegalStatus") if killerTeam and killedTeam then if getTeamName(killerTeam) ~= "Police" and getTeamName(killerTeam) ~= "Military" then if getTeamName(killedTeam) ~= "Police" and getTeamName(killedTeam) ~= "Military" then if LegalStatus ~= "Jailed" and (wL < 4) then setPlayerWantedLevel(killer, 4) end else if LegalStatus ~= "Jailed" and (wL <= 5) and not (wL > 6) then setPlayerWantedLevel(killer, wL+1) end end else local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if wL >= 3 and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then setElementData(source, "ArresterCop", killer) sendToJail(source) end end end end if not killer or killer == source or getElementType(killer) == "vehicle" then local wL = getPlayerWantedLevel(source) local LegalStatus = getElementData(source, "LegalStatus") if wL >= 4 and LegalStatus ~= "Jailed" then for i, player in ipairs(getElementsByType("player")) do local team = getPlayerTeam(player) if team and getTeamName(team) == "Police" and getTeamName(team) == "Military" then local x1, y1, z1 = getElementPosition(source) local x2, y2, z2 = getElementPosition(player) if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 40 then sendToJail(source) break end end end end end for i, player in ipairs(getElementsByType("player")) do if (getElementData(player, "ArresterCop") == source) then freePrisoner(player) exports.TopBarChat:sendClientMessage("You escaped from the cop!", player, 255, 255, 0) end end end) addEventHandler("onPlayerTarget", root, function(player) if getControlState(source, "aim_weapon") and player and getElementType(player) == "player" then local targetTeam = getPlayerTeam(player) local sourceTeam = getPlayerTeam(source) local LegalStatus = getElementData(source, "LegalStatus") local x1, y1, z1 = getElementPosition(source) local x2, y2, z2 = getElementPosition(player) if targetTeam and getTeamName(targetTeam) == "Police" and getTeamName(targetTeam) == "Military" and sourceTeam ~= targetTeam then if LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then local wp = getPedWeapon(source) local wL = getPlayerWantedLevel(source) if wL < 2 and wp ~= 41 then if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 10 then setPlayerWantedLevel(source, 2) end end end end if sourceTeam and getTeamName(sourceTeam) == "Police" and getTeamName(sourceTeam) == "Military" and sourceTeam ~= targetTeam then local LegalStatus = getElementData(player, "LegalStatus") if LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then local wL = getPlayerWantedLevel(player) local currentgun = getPedWeapon(source) if getElementInterior(source) == 5 and getElementDimension(source) == 5 then return end if (getElementData ( player, "isPlayerKidnapped" )) then return end if not isPedDead(player) and (currentgun > 19) and (currentgun < 39) and (wL > 2) and (getElementHealth(player) <= 50) and getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 3 then setElementData(player, "ArresterCop", source) setElementData(player, "LegalStatus", "Arrested") showCursor(player, true) toggleAllControls(player, false, true, false) ArrestTimer[player] = setTimer(sendToJail, 40000, 1, player) exports.TopBarChat:sendClientMessage("You Arrested "..getPlayerName(player).."!", source, 0, 255, 0) exports.TopBarChat:sendClientMessage("You have been Arrested by "..getPlayerName(source).."!", player, 255, 0, 0) setPedAnimation(player, "ROB_BANK", "SHP_HandsUp_Scr", false, false) setPedAnimation(source, "ped", "ARRESTgun", false, false) if isKeyBound(source, "tab", "down", HackPoliceComputer) then unbindKey(source, "tab", "down", HackPoliceComputer) end if (getElementData(player, "HackTime") or 0) > 0 then setElementData(player, "HackTime", false) setElementFrozen(player, false) exports.TopBarChat:sendClientMessage(getPlayerName(player).." failed to hack the police pc", root, 255, 0, 0) if isTimer(HackTimer) then killTimer(HackTimer) end end setTimer(function(arrested, attacker) setPedAnimation(arrested, false) setPedAnimation(attacker, false) end, 3000, 1, player, source) end end end end end) addEventHandler("onPlayerQuit", root, function() if isTimer(ArrestTimer[source]) then killTimer(ArrestTimer[source]) ArrestTimer[source] = nil end if bribeTimer[source] then bribeTimer[source] = nil end local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local LegalStatus = getElementData(source, "LegalStatus") local BailAmount = getElementData(source, "BailAmount") or 0 local JailTime = getElementData(source, "JailTime") or 0 local wL = getPlayerWantedLevel(source) or 0 if LegalStatus == "Free" or LegalStatus == false then setAccountData(account, "LegalStatus", "Free") setAccountData(account, "BailAmount", false) setAccountData(account, "JailTime", false) setAccountData(account, "wL", wL) elseif LegalStatus == "Arrested" then setAccountData(account, "LegalStatus", "Jailed") Link to comment
aymeness81 Posted July 13, 2014 Author Share Posted July 13, 2014 I thought about working with tables like that, but at same time I thought it will take a lot of time.. Thanks anyway Link to comment
Max+ Posted July 13, 2014 Share Posted July 13, 2014 I thought about working with tables like that, but at same time I thought it will take a lot of time.. Thanks anyway your welcome . Link to comment
ADCX Posted July 13, 2014 Share Posted July 13, 2014 I thought about working with tables like that, but at same time I thought it will take a lot of time.. Thanks anyway your welcome . It is: You're welcome* Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now