TheSmart Posted June 30, 2016 Share Posted June 30, 2016 hey guys! i have GTIPolice script but its have some problem that is police cant arrest wanted players..no error in debugscript 3 so anyone can try to fix it? plz meta exports.slua ----------------------------------------->> -- GTI: Grand Theft International -- Date: 29 Jan 2014 -- Resource: GTIpoliceArrest/arrest.slua -- Type: Server Side -- Author: JT Pennington (JTPenn) ----------------------------------------->> LAW_TEAMS = {["Law Enforcement"] = true} ARREST_TIMEOUT = 7500 HITS_TO_ARREST = 2 DISTANCE_FROM_PD_FOR_JAIL = 150 DISTANCE_WATER_ARREST = 1.5 SECONDS_PER_WP = 3 criminals = {} -- Storage of Hits for Arrests arrester = {} -- Storage of Arrester by Criminal arrests = {} -- Storage of Arrests by Cop numberOfArrests = {} -- Number of Arrests by Cop surrendered = {} -- Players that have Surrendered -- Get Nearest Police Station ------------------------------>> policeStations = { {1564.620, -1694.241, 4.891, {["Los Santos"] = true}}, -- Los Santos {-1589.558, 712.194, -6.242, {["San Fierro"] = true, ["Flint County"] = true, ["Whetstone"] = true}}, -- San Fierro {2267.884, 2443.085, 2.273, {["Las Venturas"] = true}}, -- Las Venturas {614.479, -588.599, 16.233, {["Red County"] = true}}, -- Dillimore {-1404.558, 2651.708, 54.688, {["Tierra Robada"] = true}}, -- El Quebrados {-222.686, 992.906, 18.573, {["Bone County"] = true}}, -- Fort Carson } function getNearestPoliceStation(player) if (not player or not isElement(player)) then return end local x,y,z = getElementPosition(player) local closestPD local closestMtrs = 65535 for i,v in ipairs(policeStations) do local zone = getZoneName(x,y,z,true) if (v[4][zone]) then return v[1], v[2], v[3] end local dist = getDistanceBetweenPoints3D(x, y, z, v[1], v[2], v[3]) if (closestMtrs > dist) then closestMtrs = dist closestPD = i end end return policeStations[closestPD][1], policeStations[closestPD][2], policeStations[closestPD][3] end function getDistanceFromPoliceStation(player) local x,y,z = getElementPosition(player) local x2,y2,z2 = getNearestPoliceStation(player) local dist = getDistanceBetweenPoints3D(x,y,z, x2,y2,z2) return dist end -- Exports ----------->> function isPlayerLaw(player) if (not isElement(player) or getElementType(player) ~= "player") then return false end local team = getPlayerTeam(player) local team = getTeamName(team) if (LAW_TEAMS[team]) then return true end return false end function isPlayerArrested(player) if (arrester[player]) then return true end return false end function canPlayerArrest(player) return arrester[player] or false end function getPlayerArrester(player) return arrester[player] or false end function getPlayerArrests(player) return arrests[player] or false end function isPlayerInPoliceCustody(player) return arrester[player] or false end function getPlayerTotalArrests(player) return numberOfArrests[player] or 0 end function didPlayerSurrender(player) return surrendered[player] or false end function getPlayerFromNamePart(name, officer) if (not arrests[officer]) then return false end local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if (not name) then return false end local selectedPlayer, results = nil, 0 for player,_ in pairs(arrests[officer]) do if (isElement(player)) then local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then selectedPlayer = player results = results + 1 end else arrests[officer][player] = nil end end if (results > 1) then return nil end return selectedPlayer end arrest.lua ----------------------------------------->> -- GTI: Grand Theft International -- Date: 28 Jan 2014 -- Resource: GTIpoliceArrest/arrest.lua -- Type: Client Side -- Author: JT Pennington (JTPenn) ----------------------------------------->> addEvent("onClientPlayerArrested", true) addEvent("onClientPlayerReleased", true) local policeMarkers = {} -- Table of Markers local policeBlip -- Police Blip -- Take Player to Jail ----------------------->> function takePlayerToJail(criminal, x, y, z, all) for i,v in ipairs(all) do policeMarkers[i] = createMarker(v[1], v[2], v[3], "cylinder", 4, 30, 155, 255, 175) addEventHandler("onClientMarkerHit", policeMarkers[i], jailPlayer) end policeBlip = createBlip(x, y, z, 30) end addEvent("GTIpoliceArrest.takePlayerToJail", true) addEventHandler("GTIpoliceArrest.takePlayerToJail", root, takePlayerToJail) function jailPlayer(player, dim) if (player ~= localPlayer or not dim) then return end for i,marker in ipairs(policeMarkers) do removeEventHandler("onClientMarkerHit", marker, jailPlayer) destroyElement(marker) end policeMarkers = {} destroyElement(policeBlip) policeBlip = nil triggerServerEvent("GTIpoliceArrest.throwAllPlayersInJail", resourceRoot) end arrest.slua ----------------------------------------->> -- GTI: Grand Theft International -- Date: 29 Jan 2014 -- Resource: GTIpoliceArrest/arrest.slua -- Type: Server Side -- Author: JT Pennington (JTPenn) ----------------------------------------->> addEvent("onPlayerArrested", true) addEvent("onPlayerReleased", true) -- Attempt Arrest ------------------>> function attemptArrest(criminal, officer, weapon) if (not criminal or not officer or not weapon) then return end if (not isPlayerLaw(officer) or weapon ~= 3) then return end if (not exports.GTIpoliceWanted:isPlayerWanted(criminal)) then exports.GTIhud:drawTextOnPlayer(criminal, "Unwanted", officer, 255, 25, 25, 5000) return end if (isPlayerArrested(criminal)) then return end if (didPlayerSurrender(criminal)) then arrestPlayer(criminal, officer) criminals[criminal] = nil end local hits = criminals[criminal] if (not hits) then criminals[criminal] = {} hits = criminals[criminal] end if (not hits[officer] or getTickCount() > hits[officer][2]) then hits[officer] = {0, getTickCount()+ARREST_TIMEOUT} end hits[officer][1] = hits[officer][1] + 1 exports.GTIhud:drawTextOnPlayer(criminal, "[Hits: "..hits[officer][1].."/"..HITS_TO_ARREST.."]", officer, 30, 155, 255, 5000) if (hits[officer][1] == HITS_TO_ARREST) then arrestPlayer(criminal, officer) criminals[criminal] = nil end end addEvent("GTIpoliceArrest.attemptArrest", true) addEventHandler("GTIpoliceArrest.attemptArrest", root, attemptArrest) function arrestPlayer(criminal, officer) arrester[criminal] = officer setElementData(criminal, "arrested", officer) if (not arrests[officer]) then arrests[officer] = {} end local arrestTable = arrests[officer] if (not arrestTable) then arrestTable = {} end arrestTable[criminal] = true if (not numberOfArrests[officer]) then numberOfArrests[officer] = 0 end numberOfArrests[officer] = numberOfArrests[officer] + 1 exports.GTIhud:drawNote("Arrested By", "You have been arrested by #1E9BFF"..getPlayerName(officer), criminal, 255, 255, 255) exports.GTIhud:drawNote("Arrested", "You have taken #AF1919"..getPlayerName(criminal).." #FFFFFFinto custody", officer, 255, 255, 255) exports.GTIhud:drawTextOnPlayer(criminal, "[Arrested]\nBy "..getPlayerName(officer), officer, 30, 155, 255) exports.GTIhud:dm("You have taken "..getPlayerName(criminal).." into custody. Take the detainee to the indicated police station.", officer, 30, 155, 255) setCriminalUnderPoliceControl(criminal, officer) toggleAllControls(criminal, false, true, false) triggerEvent("onPlayerArrested", criminal, officer) triggerClientEvent("onClientPlayerArrested", criminal, officer) local x,y,z = getNearestPoliceStation(officer) local all = policeStations triggerClientEvent("GTIpoliceArrest.takePlayerToJail", resourceRoot, criminal, x, y, z, all) end addEvent("GTIpolice.arrestPlayer", true) addEventHandler("GTIpolice.arrestPlayer", root, arrestPlayer) -- Set Criminal Under Control ------------------------------>> function setCriminalUnderPoliceControl(criminal, officer) if (not isElement(criminal) or not isElement(officer)) then return end if (isPedInVehicle(criminal) or not isPlayerArrested(criminal) or not arrests[officer][criminal]) then return end local copx, copy = getElementPosition(officer) local criminalx, criminaly = getElementPosition(criminal) local copangle = (360 - math.deg(math.atan2((copx - criminalx), (copy - criminaly)))) % 360 setPedRotation(criminal, copangle) setCameraTarget(criminal, criminal) local dist = getDistanceBetweenPoints2D(copx, copy, criminalx, criminaly) if (dist > 16) then local x, y, z = getElementPosition(officer) setElementPosition(criminal, x, y, z) setTimer(setCriminalUnderPoliceControl, 500, 1, criminal, officer) elseif (dist > 12) then setControlState(criminal, "sprint", true) setControlState(criminal, "walk", false) setControlState(criminal, "forwards", true) setTimer(setCriminalUnderPoliceControl, 500, 1, criminal, officer) elseif (dist > 6) then setControlState(criminal, "sprint", false) setControlState(criminal, "walk", false) setControlState(criminal, "forwards", true) setTimer(setCriminalUnderPoliceControl, 500, 1, criminal, officer) elseif (dist > 1.5) then setControlState(criminal, "sprint", false) setControlState(criminal, "walk", true) setControlState(criminal, "forwards", true) setTimer(setCriminalUnderPoliceControl, 500, 1, criminal, officer) elseif (dist <= 1.5) then setControlState(criminal, "sprint", false) setControlState(criminal, "walk", false) setControlState(criminal, "forwards", false) setTimer(setCriminalUnderPoliceControl, 500, 1, criminal, officer) end end function transferCriminalsToVehicle(player, seat, jacked, door) if (not isPlayerLaw(player) or not getPlayerArrests(player)) then return end local maxAllowed = getVehicleMaxPassengers(source) local occupantsTbl = getVehicleOccupants(source) for plr,_ in pairs(getPlayerArrests(player)) do local seat = 1 local done = warpPedIntoVehicle(plr, source, seat) while (not done) do seat = seat + 1 if (seat >= maxAllowed) then break end warpPedIntoVehicle(plr, source, seat) end end end addEventHandler("onVehicleStartEnter", root, transferCriminalsToVehicle) -- Release Player ------------------>> function releasePlayerOnCommand(player, command, criminal) if (not arrests[player] or numberOfArrests[player] == 0) then return end -- Release All Criminals if (criminal == "*") then for criminal,v in pairs(arrests[player]) do releasePlayer(criminal) end return end -- Release a Single Criminal if (not criminal and numberOfArrests[player] == 1) then releasePlayer(criminal) end -- Release a Criminal By Name if (not criminal) then outputChatBox("Syntax: /release or /release *", player, 255, 125, 0) else local criminal = getPlayerFromNamePart(criminal, player) if (not criminal) then exports.GTIhud:dm("Police: You have no persons in custody with this name. Enter a new name." , player, 30, 155, 255) else releasePlayer(criminal) end end end addCommandHandler("release", releasePlayerOnCommand) function releasePlayer(criminal) local officer = arrester[criminal] arrester[criminal] = nil setElementData(criminal, "arrested", nil) local arrestTable = arrests[officer] if (not arrestTable) then arrestTable = {} end arrestTable[criminal] = nil numberOfArrests[officer] = numberOfArrests[officer] - 1 if (numberOfArrests[officer] == 0) then arrests[officer] = nil numberOfArrests[officer] = nil end exports.GTIhud:drawNote("Arrested By", "", criminal, 255, 255, 255) exports.GTIhud:drawNote("Arrested", "", officer, 255, 255, 255) exports.GTIhud:drawTextOnPlayer(criminal, "", officer, 30, 155, 255) exports.GTIhud:dm("You have released "..getPlayerName(criminal).." from custody.", officer, 30, 155, 255) exports.GTIhud:dm("You have been released from custody.", criminal, 30, 155, 255) toggleAllControls(criminal, true, true) triggerEvent("onPlayerReleased", criminal, officer) triggerClientEvent("onClientPlayerReleased", criminal, officer) end -- Arrest Player On... ----------------------->> function arrestPlayerInWater(criminal) if (not criminal or not isElement(criminal) or getElementType(criminal) ~= "player") then return end if (not isPlayerLaw(source) or not isElementInWater(source) or not isPedInWater(criminal)) then return end if (not exports.GTIpoliceWanted:isPlayerWanted(criminal) or isPlayerArrested(criminal)) then return end local weap = getPedWeapon(source) if (weap ~= 3) then return end local x1,y1,z1 = getElementPosition(criminal) local x2,y2,z2 = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x1,y1,z1, x2,y2,z2) if (dist > DISTANCE_WATER_ARREST) then return end arrestPlayer(criminal, source) end addEventHandler("onPlayerTarget", root, arrestPlayerInWater) -- Release Player On... ------------------------>> function releasePlayerOnPoliceQuitOrKill() local arrests = getPlayerArrests(source) if (not arrests) then return end for player,_ in ipairs(arrests) do local dist = getDistanceFromPoliceStation(player) if (dist > DISTANCE_FROM_PD_FOR_JAIL) then releasePlayer(player) else local wantedLevel = exports.GTIpoliceWanted:getWantedLevel(player, true) local jailTime = wantedLevel * SECONDS_PER_WP if (didPlayerSurrender(player)) then jailTime = jailTime * 0.90 end exports.GTIprison:jailPlayer(source, player, jailTime) end end arrests[source] = nil numberOfArrests[source] = nil end addEventHandler("onPlayerQuit", root, releasePlayerOnPoliceQuitOrKill) addEventHandler("onPlayerWasted", root, releasePlayerOnPoliceQuitOrKill) -- Surrender ------------->> function surrender(player) if (not exports.GTIpoliceWanted:isPlayerWanted(player)) then return end if (isPlayerArrested(player)) then return end if (not surrendered[player]) then setPedAnimation(player, "ped", "handsup", -1, false, true, false, true) exports.GTIhud:dm("You have surrendered to the police. For complying, your jail time will be decreased by 10%", player, 30, 155, 255) surrendered[player] = true else setPedAnimation(player) exports.GTIhud:dm("You have chosen not to surrender. Jail time returned to normal.", player, 30, 155, 255) surrendered[player] = nil end end addCommandHandler("sur", surrender) -- Throw Players In Jail ------------------------->> function throwAllPlayersInJail() local arrests = getPlayerArrests(client) for player,_ in pairs(arrests) do Link to comment
Dimos7 Posted June 30, 2016 Share Posted June 30, 2016 first change name to arrest_s.lua all is .lua not slua Link to comment
_DrXenon Posted June 30, 2016 Share Posted June 30, 2016 If team 'Law Enforcement' was not created then create it and then set your team as 'Law Enforcement' And do not change the files names from .slua to .lua in meta.xml, I believe so Link to comment
TheSmart Posted June 30, 2016 Author Share Posted June 30, 2016 Law Enforement team is already created but still not working. Link to comment
_DrXenon Posted June 30, 2016 Share Posted June 30, 2016 Did you set your team as Law Enforcement? And did you change the meta.xml back to the original? Link to comment
_DrXenon Posted June 30, 2016 Share Posted June 30, 2016 exports.GTIpoliceWanted:isPlayerWanted I found this line in the script; it says that there is an exported function called isPlayerWanted. But its not in the exported functions on meta.xml or on the exports.lua This means that someone gave you the script with a missing function. 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