orcun99 Posted June 19, 2014 Share Posted June 19, 2014 jailserver.lua addEvent("onPlayerArrested") addEvent("onPlayerReleased") local jailLocations = {} local arrestedCrims = {} local cell = { ["jail 1"] = {3094.1767578125,-808.15942382813,1.2345782518387,6}, } --local cell = {-577.34661865234,2584.078125,53.515625,6},{1102.9329833984,-2927.1062011719,3.9781250953674,6} local zoneTables = { ["los santos"] = {1543.2390136719,-1676.0291748047,13.556066513062,0}, ["san fierro"] = {-1601.7484130859,722.07757568359,11.283002853394,0}, ["las venturas"] = {2289.6687011719,2423.37890625,10.8203125,0}, ["flint county"] = {-550.44763183594,-1006.8661499023,24.081153869629,0}, ["whetstone"] = {-2163.6845703125,-2387.5734863281,30.625,0}, ["red county"] = {633.32086181641,-571.38275146484,16.3359375,0}, ["tierra robada"] = {-1417.8824462891,2631.4116210938,55.8359375,0}, ["bone county"] = {-206.83717346191,981.92529296875,19.221559524536,0}, ["unknown"] = {-206.83717346191,981.92529296875,19.221559524536,0} } local prisonCells = { {-549.94152832031, 2595.9230957031, 53.515625}, {1102.9329833984, -2927.1062011719, 3.9781250953674} } function arrestCrim(crim,cop,message,message2,spawned) if crim and getPlayerTeam(crim) then if not arrestedCrims[crim] then if not spawned then if getElementData(crim,"jailed") then return end end setElementData(crim, "jailed", true) arrestedCrims[crim] = true local crimWanted = getWantedLevel(crim) local jailTime = crimWanted * 15 if getElementData(crim, "surrender.lesstime") then jailTime = jailTime * 0.50 toggleAllControls(crim, true) setElementData(crim,"surrender.lesstime",false) end if cop then local money = 2000 + (crimWanted * 400) --exports.ORCcommands:giveMoney(cop,money) givePlayerMoney ( cop, money ) end setInsideJail(crim,jailTime,crimWanted,adminjail) setInJail(crim,true) removePedFromVehicle(crim) takeAllWeapons(crim) triggerEvent("onPlayerArrested",root,crim,cop) if message then exports.ORCcommands:sendMessage(message, 255,255,255, false, false, true) end if message2 then exports.ORCcommands:sendMessage(message2,255,255,255,crim) end end end end addEvent("arrestCrim",true) addEventHandler("arrestCrim",root,arrestCrim) function setInsideJail(crim,jailTime,wanted,adminjail) fadeCamera(crim,false) tempweapons = {} w = getWantedLevel(crim) local username = getElementData(crim,"username") triggerClientEvent(crim,"startJailCounter",crim,jailTime) setTimer(warpPlayerToCell, 1000, 1, crim,cell,true,wanted,adminjail) end function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function warpPlayerToCell(crim,place,tojail,wanted,adminjail) if crim and isElement(crim) then arrestedCrims[crim] = nil local newDim if tojail then -- if he is sent to jail local x,y,z = getElementPosition(crim) local zone = getZoneName(x,y,z,true) local zTable = zoneTables[zone:lower()] jailLocations[crim] = zTable newDim = 0 setElementHealth(crim, 100) -- -- -- -- -- -- -- -- -- -- -- -- -- -- - local randCell = math.random(#prisonCells); local X,Y,Z = prisonCells[randCell][1], prisonCells[randCell][2], prisonCells[randCell][3] setElementPosition(crim, X, Y, Z) toggleControl(crim, "jump", false) else -- released from jail newDim = 0 setElementInterior(crim, 0, place[1], place[2], place[3]) jailLocations[crim] = nil if theBlip and isElement(theBlip) then setElementVisibleTo(theBlip,root,true) end toggleControl(crim, "jump", true) end setElementDimension(crim, newDim) end end function playerGetReleased() -- source is crim if getElementType(source) == "player" then local injail = getInJail(source) if injail == true then toggleControl(crim, "jump", true) local spawn = jailLocations[source] or zoneTables["los santos"] setTimer(warpPlayerToCell,1000,1,source,spawn,false) triggerEvent("onPlayerReleased",getRootElement(),source) triggerClientEvent("onClientPlayerReleased",source) exports.ORCcommands:sendMessage(getPlayerName(source).." has been released from jail.",255,255,255, false, false, true) setWantedLevel(source,0) setElementData(source, "jailed", false) setInJail(source,false) -- -- -- -- -- -- -- -- -- -- -- -- -- setElementPosition(source, jailLocations[source][1], jailLocations[source][2], jailLocations[source][3]) jailLocations[source] = nil end end end addEvent("onPlayerGetReleased", true) addEventHandler("onPlayerGetReleased", root, playerGetReleased) -- JAILBREAKS OMG local vert1 = {-541.90118408203,2608.1440429688,53.515625} local vert2 = {-541.90118408203,2608.1440429688,53.515625} local w = vert2[1] - vert1[1] local h = vert2[2] - vert1[2] local d = vert2[3] - vert1[3] prisonCol = createColCuboid(vert1[1], vert1[2], w, h, d) setElementDimension(prisonCol, 0) setElementInterior(prisonCol, 0) function playerEnterJail(element,dimension) if element and dimension and getElementType(element) == "player" then local team = getPlayerTeam(element) if team and not (copTeams[getTeamName(team)] or getInJail(element)) then -- the player who entered jail area isn't a cop exports.ORCcommands:sendMessage("*JAIL* You are have entered the jail.",255,255,255,element) if (texthasdisplayed == nil) then texthasdisplayed = true exports.RPGpolice:alertPolice("*JAIL* There is a criminal breach in the prison, all units respond!") setTimer(rePrintText, 15000, 1) end modifyWantedLevel(element, 10) elseif copTeams[getTeamName(team)] and getTeamName(team) == "Police" then if isPedInVehicle(element) then blowVehicle(getPedOccupiedVehicle(element)) end if not isPedDead(element) then killPed(element) end exports.ORCcommands:sendMessage("*JAIL* You are not allowed to enter the jail as a cop. Leave its defense to the army.",255,255,255,element) end end end function playerLeaveJail(element,dimension) if element and dimension and getElementType(element) == "player" then if getElementData(element,"jailed") and not isPedDead(element) then modifyWantedLevel(element, 10) jailLocations[element] = nil for k,v in ipairs({"fire","enter_exit","action","crouch","next_weapon","previous_weapon"}) do toggleControl(element,v,true) end triggerEvent("onPlayerReleased",root,element) triggerClientEvent( element, "onClientPlayerReleased", element) setInJail(element,false) setElementData(element, "jailed", false) exports.ORCcommands:sendMessage("You have broken out from prison!",255,255,255, element, false) exports.RPGpolice:alertPolice( getPlayerName(element).." has broken out from prison!" ) toggleControl(element, "jump", true) end end end addEventHandler ( "onPlayerWasted", root, function() if getElementData(source,"jailed") then setElementData(source,"jailed",false) end end ) addEventHandler("onColShapeHit",prisonCol,playerEnterJail) addEventHandler("onColShapeLeave",prisonCol,playerLeaveJail) function rePrintText() texthasdisplayed = nil end function fadePlayerIn(crim) if crim then if isElement(crim) then fadeCamera(crim,true) end end end function resetCrimOnQuit() jailLocations[source] = nil end addEventHandler("onPlayerQuit", root, resetCrimOnQuit) Erorr: RPGPolice/jail_server.lua:35: attempt to perform aritmethic on local "crimwanted" < a nil value> 35: local(jailTime = crimWanted * 15) Link to comment
Et-win Posted June 19, 2014 Share Posted June 19, 2014 Check with: outputChatBox(tostring(crim)) at the start of the function or crim is actually the player (usedata) or nil. If it is nil, then it wasn't correctly send. Link to comment
_DrXenon Posted June 19, 2014 Share Posted June 19, 2014 well, Idk if "getWantedLevel" exists... So, The right one is "getPlayerWantedLevel(crim) Link to comment
Et-win Posted June 19, 2014 Share Posted June 19, 2014 well, Idk if "getWantedLevel" exists... So, The right one is "getPlayerWantedLevel(crim) Ah yes, you are right. Didn't see that I got redirected from getWantedLevel to getPlayerWantedLevel. Link to comment
orcun99 Posted June 19, 2014 Author Share Posted June 19, 2014 wantedlevel.lua local wantedLevel = {} local wantedLevelTimer = {} local newWantedTimer = {} local injail = {} addEvent("onPlayerWantedLevelChange", true) function startWantedLevel() for k, v in ipairs(getElementsByType("player")) do local account = getPlayerAccount(v) if account then local wlevel = 0 if getElementData(v,"wanted") then wlevel = getElementData(v,"wanted") else wlevel = getAccountData(account, "wanted") or 0 end setElementData(v,"damAttacked","no") setWantedLevel(v,wlevel) setPlayerNametagText(v,getPlayerName(v).."["..tostring(wlevel).."]") end end end function setWantedLevel(thePlayer, level) local wl = getWantedLevel(thePlayer) or 0 if thePlayer and level and wl and (tonumber(level) >= 0 and tonumber(level) <= 24 and wl >= 0 and wl <= 24) then --and sendTheEvents(thePlayer, level) Stops people in jail from loosing stars! wantedLevel[thePlayer] = tonumber(level) setElementData(thePlayer,"wanted",tostring(level)) setPlayerNametagText(thePlayer, getPlayerName(thePlayer).."["..tostring(level).."]") if tonumber(level) ~= 0 then setWantedTimer(thePlayer, level) end return triggerClientEvent(thePlayer, "setWLevel", root, level) else return false end end addEvent("setWantedLevel", true) addEventHandler("setWantedLevel", root, setWantedLevel) function modifyWantedLevel(thePlayer, level) if not thePlayer or not isElement(thePlayer) or getElementType(thePlayer) ~= "player" or not level then return false end if tonumber(level) == 0 then return false end local curWanted = getWantedLevel(thePlayer) or 0 local newWanted = tonumber(curWanted)+tonumber(level) if newWanted > 24 then newWanted = 24 elseif newWanted < 0 then newWanted = 0 end if sendTheEvents(thePlayer, newWanted) then wantedLevel[thePlayer] = newWanted setElementData(thePlayer,"wanted",tostring(newWanted)) setPlayerNametagText(thePlayer,getPlayerName(thePlayer).."["..tostring(newWanted).."]") if newWanted ~= 0 then setWantedTimer(thePlayer,newWanted) end return triggerClientEvent(thePlayer,"setWLevel",root,newWanted) else return false end end addEvent("modifyWantedLevel", true) addEventHandler("modifyWantedLevel",root,modifyWantedLevel) function getWantedLevel(thePlayer) if not thePlayer or not isElement(thePlayer) or getElementType(thePlayer) ~= "player" then return false end if not getElementData(thePlayer,"loggedIn") then return end if wantedLevel and wantedLevel[thePlayer] then return wantedLevel[thePlayer] else return tonumber(getElementData(thePlayer,"wanted")) or 0 end end function setInJail(thePlayer,isinjail) if not isinjail then isinjail = false end local account = getPlayerAccount(thePlayer) if account then setAccountData(account, "jailed", isinjail) injail[thePlayer] = isinjail setElementData(thePlayer,"jailed",isinjail) return true else return false end end function getInJail(thePlayer) if not thePlayer or not isElement(thePlayer) or getElementType(thePlayer) ~= "player" then return false end local account = getPlayerAccount(thePlayer) if not account then return false end return getAccountData(account, "jailed") end function setWantedTimer(player, wlevel) if wantedLevelTimer[player] then killTimer(wantedLevelTimer[player]) end if tonumber(wlevel) > 0 then wantedLevelTimer[player] = setTimer(function(player) local wlevel = getWantedLevel(player) if type(wlevel) ~= "number" then return end local wlevel = tonumber(wlevel)-1 setWantedLevel(player,wlevel) end,300000,1,player) setPlayerNametagText(player,getPlayerName(player).."["..tostring(wlevel).."]") end end function joinedWantedLevel() local account = getPlayerAccount(source) if not account then return end local wlevel = 0 if getAccountData(account, "wanted") then wlevel = getAccountData(account, "wanted") end setWantedLevel(source,wlevel) end addEventHandler("onPlayerLogIn",root,joinedWantedLevel) function quitWantedLevel(player, account) if not account then account = getPlayerAccount(player) end if wantedLevelTimer[player] then killTimer(wantedLevelTimer[player]) end local wlevel = getWantedLevel(player) or 0 if account then setAccountData(account, "wanted", wlevel) end if wantedLevel[player] then wantedLevel[player] = nil end end addEventHandler("onPlayerLogout",root,function(acc) quitWantedLevel(source, acc) end) addEventHandler("onPlayerQuit",root,function() quitWantedLevel(source) end) local mta_killTimer = killTimer function killTimer(timer) for key,value in ipairs(getTimers()) do if (timer == value) then return mta_killTimer(timer) end end return false end function startWantedResource() setTimer(startWantedLevel,500,1) end addEventHandler("onResourceStart",resourceRoot,startWantedResource) function playerSpawn() if getPlayerTeam(source) then if copTeams[getTeamName(getPlayerTeam(source))] and getWantedLevel(source) > 0 then setTimer(function(player) killPed(player) exports.ORCcommands:sendMessage("You can't spawn in a law enforcement team with stars.", 255, 255, 0, player) end, 1000, 1, source) end end end addEventHandler("onPlayerSpawn", root, playerSpawn) function sendTheEvents(player, stars) local e1 = triggerEvent("onPlayerWantedLevelChange", player, stars) local e2 = triggerClientEvent("onClientPlayerWantedLevelChange", player, stars) return e1 and e2 end Link to comment
orcun99 Posted June 19, 2014 Author Share Posted June 19, 2014 Erorr: RPGPolice/jail_server.lua:35: attempt to perform aritmethic on local "crimwanted" < a nil value> 35: local(jailTime = crimWanted * 15) Link to comment
Et-win Posted June 19, 2014 Share Posted June 19, 2014 Check with: outputChatBox(tostring(crim)) at the start of the function or crim is actually the player (usedata) or nil. If it is nil, then it wasn't correctly send. Tested already? getWantedLevel changed to getPlayerWantedLevel? Link to comment
orcun99 Posted June 19, 2014 Author Share Posted June 19, 2014 I do not understand much of the script coding SALE OF me a script that my friend does not work, but all the code is correct if you write to me again, it would be better unfortunately I do not understand much that I gave you fix the code rewrite would be very happy if my english is not too good thanks Link to comment
orcun99 Posted June 19, 2014 Author Share Posted June 19, 2014 getWantedLevel changed getPlayerWantedLevel Link to comment
Et-win Posted June 20, 2014 Share Posted June 20, 2014 addEvent("onPlayerArrested") addEvent("onPlayerReleased") local jailLocations = {} local arrestedCrims = {} local cell = { ["jail 1"] = {3094.1767578125,-808.15942382813,1.2345782518387,6}, } --local cell = {-577.34661865234,2584.078125,53.515625,6},{1102.9329833984,-2927.1062011719,3.9781250953674,6} local zoneTables = { ["los santos"] = {1543.2390136719,-1676.0291748047,13.556066513062,0}, ["san fierro"] = {-1601.7484130859,722.07757568359,11.283002853394,0}, ["las venturas"] = {2289.6687011719,2423.37890625,10.8203125,0}, ["flint county"] = {-550.44763183594,-1006.8661499023,24.081153869629,0}, ["whetstone"] = {-2163.6845703125,-2387.5734863281,30.625,0}, ["red county"] = {633.32086181641,-571.38275146484,16.3359375,0}, ["tierra robada"] = {-1417.8824462891,2631.4116210938,55.8359375,0}, ["bone county"] = {-206.83717346191,981.92529296875,19.221559524536,0}, ["unknown"] = {-206.83717346191,981.92529296875,19.221559524536,0} } local prisonCells = { {-549.94152832031, 2595.9230957031, 53.515625}, {1102.9329833984, -2927.1062011719, 3.9781250953674} } function arrestCrim(crim,cop,message,message2,spawned) if crim and getPlayerTeam(crim) then if not arrestedCrims[crim] then if not spawned then if getElementData(crim,"jailed") then return end end setElementData(crim, "jailed", true) arrestedCrims[crim] = true local crimWanted = getWantedLevel(crim) local jailTime = crimWanted * 15 if getElementData(crim, "surrender.lesstime") then jailTime = jailTime * 0.50 toggleAllControls(crim, true) setElementData(crim,"surrender.lesstime",false) end if cop then local money = 2000 + (crimWanted * 400) --exports.ORCcommands:giveMoney(cop,money) givePlayerMoney ( cop, money ) end setInsideJail(crim,jailTime,crimWanted,adminjail) setInJail(crim,true) removePedFromVehicle(crim) takeAllWeapons(crim) triggerEvent("onPlayerArrested",root,crim,cop) if message then exports.ORCcommands:sendMessage(message, 255,255,255, false, false, true) end if message2 then exports.ORCcommands:sendMessage(message2,255,255,255,crim) end end end end addEvent("arrestCrim",true) addEventHandler("arrestCrim",root,arrestCrim) function setInsideJail(crim,jailTime,wanted,adminjail) fadeCamera(crim,false) tempweapons = {} w = getWantedLevel(crim) local username = getElementData(crim,"username") triggerClientEvent(crim,"startJailCounter",crim,jailTime) setTimer(warpPlayerToCell, 1000, 1, crim,cell,true,wanted,adminjail) end function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function warpPlayerToCell(crim,place,tojail,wanted,adminjail) if crim and isElement(crim) then arrestedCrims[crim] = nil local newDim if tojail then -- if he is sent to jail local x,y,z = getElementPosition(crim) local zone = getZoneName(x,y,z,true) local zTable = zoneTables[zone:lower()] jailLocations[crim] = zTable newDim = 0 setElementHealth(crim, 100) -- -- -- -- -- -- -- -- -- -- -- -- -- -- - local randCell = math.random(#prisonCells); local X,Y,Z = prisonCells[randCell][1], prisonCells[randCell][2], prisonCells[randCell][3] setElementPosition(crim, X, Y, Z) toggleControl(crim, "jump", false) else -- released from jail newDim = 0 setElementInterior(crim, 0, place[1], place[2], place[3]) jailLocations[crim] = nil if theBlip and isElement(theBlip) then setElementVisibleTo(theBlip,root,true) end toggleControl(crim, "jump", true) end setElementDimension(crim, newDim) end end function playerGetReleased() -- source is crim if getElementType(source) == "player" then local injail = getInJail(source) if injail == true then toggleControl(crim, "jump", true) local spawn = jailLocations[source] or zoneTables["los santos"] setTimer(warpPlayerToCell,1000,1,source,spawn,false) triggerEvent("onPlayerReleased",getRootElement(),source) triggerClientEvent("onClientPlayerReleased",source) exports.ORCcommands:sendMessage(getPlayerName(source).." has been released from jail.",255,255,255, false, false, true) setWantedLevel(source,0) setElementData(source, "jailed", false) setInJail(source,false) -- -- -- -- -- -- -- -- -- -- -- -- -- setElementPosition(source, jailLocations[source][1], jailLocations[source][2], jailLocations[source][3]) jailLocations[source] = nil end end end addEvent("onPlayerGetReleased", true) addEventHandler("onPlayerGetReleased", root, playerGetReleased) -- JAILBREAKS OMG local vert1 = {-541.90118408203,2608.1440429688,53.515625} local vert2 = {-541.90118408203,2608.1440429688,53.515625} local w = vert2[1] - vert1[1] local h = vert2[2] - vert1[2] local d = vert2[3] - vert1[3] prisonCol = createColCuboid(vert1[1], vert1[2], vert1[3], w, h, d) setElementDimension(prisonCol, 0) setElementInterior(prisonCol, 0) function playerEnterJail(element,dimension) if element and dimension and getElementType(element) == "player" then local team = getPlayerTeam(element) if team and not (copTeams[getTeamName(team)] or getInJail(element)) then -- the player who entered jail area isn't a cop exports.ORCcommands:sendMessage("*JAIL* You are have entered the jail.",255,255,255,element) if (texthasdisplayed == nil) then texthasdisplayed = true exports.RPGpolice:alertPolice("*JAIL* There is a criminal breach in the prison, all units respond!") setTimer(rePrintText, 15000, 1) end modifyWantedLevel(element, 10) elseif copTeams[getTeamName(team)] and getTeamName(team) == "Police" then if isPedInVehicle(element) then blowVehicle(getPedOccupiedVehicle(element)) end if not isPedDead(element) then killPed(element) end exports.ORCcommands:sendMessage("*JAIL* You are not allowed to enter the jail as a cop. Leave its defense to the army.",255,255,255,element) end end end function playerLeaveJail(element,dimension) if element and dimension and getElementType(element) == "player" then if getElementData(element,"jailed") and not isPedDead(element) then modifyWantedLevel(element, 10) jailLocations[element] = nil for k,v in ipairs({"fire","enter_exit","action","crouch","next_weapon","previous_weapon"}) do toggleControl(element,v,true) end triggerEvent("onPlayerReleased",root,element) triggerClientEvent( element, "onClientPlayerReleased", element) setInJail(element,false) setElementData(element, "jailed", false) exports.ORCcommands:sendMessage("You have broken out from prison!",255,255,255, element, false) exports.RPGpolice:alertPolice( getPlayerName(element).." has broken out from prison!" ) toggleControl(element, "jump", true) end end end addEventHandler ( "onPlayerWasted", root, function() if getElementData(source,"jailed") then setElementData(source,"jailed",false) end end ) addEventHandler("onColShapeHit",prisonCol,playerEnterJail) addEventHandler("onColShapeLeave",prisonCol,playerLeaveJail) function rePrintText() texthasdisplayed = nil end function fadePlayerIn(crim) if crim then if isElement(crim) then fadeCamera(crim,true) end end end function resetCrimOnQuit() jailLocations[source] = nil end addEventHandler("onPlayerQuit", root, resetCrimOnQuit) You forgot argument 3 'pZ' (Position Z): prisonCol = createColCuboid(vert1[1], vert1[2], vert1[3], w, h, d) At line 139. Link to comment
orcun99 Posted June 20, 2014 Author Share Posted June 20, 2014 RPGpolice/wantedlevel.lua:160: attempt to compare number with nil Link to comment
Et-win Posted June 20, 2014 Share Posted June 20, 2014 Change getWantedLevel to getPlayerWantedLevel. And I don't keep fixing your stuff if you don't even try it by yourself. Link to comment
_DrXenon Posted June 20, 2014 Share Posted June 20, 2014 yeah...! Change every getWantedLevel written in the script to getPlayerWantedLevel ... as there is no getWantedLevel function, that's why it keep outputting : attempt to compare 'number' with 'nil' nil = getWantedLevel , to get it as number use : getPlayerWantedLevel!!!!! Link to comment
orcun99 Posted June 20, 2014 Author Share Posted June 20, 2014 Can you give me again please correct this file link: https://www.mediafire.com/?poezma4z9du6969 Link to comment
Et-win Posted June 20, 2014 Share Posted June 20, 2014 I'm not going to download anything. Also, I ain't going to totally fully repair your script. You should contact the owner of the script if it isn't yours. This is also probably why nobody is replying to this topic. Link to comment
orcun99 Posted June 20, 2014 Author Share Posted June 20, 2014 this script is not mine I bought from a server that person the script is working fine but my serverimiz I do not work I get people work told him, but works for me something Sorry I said, this site gave you help said Link to comment
Et-win Posted June 20, 2014 Share Posted June 20, 2014 We give help if the script isn't stolen. Nor we don't have any proof or this is really bought by you. I would be glad to help, but you have to take and put time into the code aswell, trying to fix it by yourself. Link to comment
Mr_Moose Posted June 21, 2014 Share Posted June 21, 2014 There is another topic posted not long ago where someone had the exact same problem, an RPG arrest system that he bought, I recognize the source code once again and this seems to be a leaked script, the person you bought it from is probably the same scammer as in the other topic, can't find that topic thought but it may help if you remember, and are able to tell us who sold the script to you. 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