Jump to content

Help


Gastonito

Recommended Posts

1 hour ago, Wumbaloo said:

Post your code. (jail_server_lua)


addEvent("onPlayerArrested")
addEvent("onPlayerReleased")

local jailLocations = {}
local arrestedCrims = {}
local cell = {1370.3150634766, -841.86193847656, 1185.9202880859}
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 = {
	{1382.9124755859,-865.97760009766,1181.7562255859},
	{1379.3326416016,-866.18615722656,1181.7562255859},
	{1374.9655761719,-866.15270996094,1181.7562255859},
        {1371.0844726563,-865.92327880859,1181.7562255859},
	{1367.1547851563,-865.70574951172,1181.7562255859},
	{1363.0505371094,-866.38110351563,1181.7562255859},
	{1359.2626953125,-865.60180664063,1181.7562255859},
	{1355.2829589844,-865.80017089844,1181.7562255859},
	{1351.6278076172,-865.64959716797,1181.7562255859},
	{1347.3681640625,-865.76251220703,1181.7562255859},
}

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 * 6
			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 * 1000)
				exports.SAEGcommands:giveMoney(cop,money)
			end
			setInsideJail(crim,jailTime,crimWanted,adminjail)
			setInJail(crim,true)
			removePedFromVehicle(crim)
			takeAllWeapons(crim)
			triggerEvent("onPlayerArrested",root,crim,cop)
			if message then
				exports.SAEGcommands:sendMessage(message, 6,10,103, false, false, true)
			end
			if message2 then
				exports.SAEGcommands:sendMessage(message2,80,155,130,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)
			setPedSkin(crim, 312)
			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.SAEGcommands:sendMessage(getPlayerName(source).." has been realeased from Prison.",0,255,0, 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 = {1344.802734375,-864.62359619141,1185.9268798828}
local vert2 = {1344.8363037109,-866.92114257813,1185.9268798828}
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.SAEGcommands:sendMessage("*JAIL* You are have entered the jail.",255,255,255,element)
			if (texthasdisplayed == nil) then 
				texthasdisplayed = true
		    	exports.SAEGpolice:alertPolice("*SAEG Prison* 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.SAEGcommands:sendMessage("*SAEG Prison* 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 playerLeaveSmallJailArea(element,dimension)
	if element and dimension and getElementType(element) == "player" then
		if getTeamName(getPlayerTeam(element)) == "Admin" then
			setInJail(element, 0)
			setElementData(element, "jailed", false)
		end
		-- it's important to use element data here
		if ( getElementData(element,"jailed") and not (getTeamName(getPlayerTeam(element)) == "Admin" or isPedDead(element)) ) then -- player was in jail
			if isElementWithinColShape(element,JailColShape) and not isElementWithinColShape(element,CellsColShape) and not isElementWithinColShape(element,CellsYardColShape) then

			    local curWanted = getWantedLevel(element) or 0
				local newWanted = tonumber(curWanted)+10
				if newWanted > 36 then
					newWanted = 36
				elseif newWanted < 0 then
					newWanted = 0
				end
				setWantedLevel(element,newWanted)
				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,0)
			    setElementData(element, "jailed", false)
			    local blip = getBlipAttachedToPlayer(element)
			    if blip then
				    setElementVisibleTo(blip,root,true)
			    end
				exports.SAEGcommands:sendMessage("You have 	n out from the Los Santos Prison!",100,100,255, element, false)
				exports.SAEGPolice:alertPolice( getPlayerName(element).." has broken out from the Los Santos Prison!" )
				--[[elseif isElementWithinColShape(element,JailColShape) and not (isElementWithinColShape(element,deJailColShape1) or isElementWithinColShape(element,deJailColShape2))	then			
			    modifyWantedLevel(element,20)
			   			jailLocations[element] = nil
			    for k,v in ipairs({"fire","enter_exit","action","crouch","next_weapon","previous_weapon"}) do
				toggleControl(element,v,true)]]--
			else if isElementWithinColShape(element,JailColShape) and isElementWithinColShape(element,CellsYardColShape) and isElementWithinColShape(element,CellsColShape) then
				local curWanted = getWantedLevel(element) or 0
				local newWanted = tonumber(curWanted)+5
				if newWanted > 36 then
					newWanted = 36
				elseif newWanted < 0 then
					newWanted = 0
				end
				setWantedLevel(element,newWanted) -- 5 stars for a try.
				exports.SAEGcommands:sendMessage("You have left your cell! Police have been alarmed!",100,100,255, element )
				if (texthasdisplayed == nil) then 
					texthasdisplayed = true
					exports.SAEGPolice:alertPolice("Some of the Prisoners in LS Prison have left their cells, respond immediately!")
			    	setTimer(rePrintText, 15000, 1)
			    end
			end
			end
	--[[	triggerEvent("onPlayerReleased",root,element)
			triggerClientEvent( element, "onClientPlayerReleased", element)
			setInJail(element,0)
			setElementData(element, "jailed", false)
			local blip = getBlipAttachedToPlayer(element)
			if blip then
				setElementVisibleTo(blip,root,true)
			end
			exports.SAEGcommands:sendMessage(getPlayerName(element).." has broken out from the Los Santos Prison!",100,100,255, element, false)
			exports.SAEGPolice:alertPolice( getPlayerName(element).." has broken out from the Los Santos Prison!" ) ]]--
		end
	end
end

 addEventHandler ( "onPlayerWasted", root, function()
	if getElementData(source,"jailed") then
		setElementData(source,"jailed",false)
	end
 end )

addEventHandler("onColShapeHit",OutSideYarColShape,playerEnterPrisonsYardArea)
addEventHandler("onColShapeHit",JailColShape,playerEnterPrisonsArea)
addEventHandler("onColShapeHit",CellsColShape,playerEnterPrisonsArea)
addEventHandler("onColShapeHit",CellsYardColShape,playerLeaveSmallJailArea)
addEventHandler("onColShapeLeave",CellsColShape,playerLeaveSmallJailArea)

function rePrintText()
	texthasdisplayed = nil
end

--[[ Doesn't make sense with the new jail
function playerVehicleEscape( enteringPlayer )
	if ( getInJail(enteringPlayer) ) then -- player was in jail
		if (not jailLocations[element] == nil) then
			jailLocations[element] = nil
		end
		for k,v in ipairs({"fire","enter_exit","action","crouch","next_weapon","previous_weapon"}) do
			toggleControl(enteringPlayer,v,true)
		end
		triggerEvent("onPlayerReleased",root,enteringPlayer)
		triggerClientEvent( enteringPlayer, "onClientPlayerReleased", enteringPlayer)
		modifyWantedLevel(enteringPlayer,5)
		local blip = getBlipAttachedToPlayer(enteringPlayer)
		if blip then
			setElementVisibleTo(blip,root,true)
		end
	end
end
addEventHandler("onVehicleEnter", getRootElement(), playerVehicleEscape)
]]--

function wardenWeaponTake( leaveElement )
	if ( getElementType( leaveElement ) == "player" ) then
		if ( getElementData( leaveElement, "class" ) == "Prison Warden" ) then
			takeAllWeapons( leaveElement )
		end
	end
end

function wardenWeaponGive( hitElement )
	if ( getElementType ( hitElement ) == "player" ) then
		if ( getElementData( hitElement, "class" ) == "Prison Warden" ) then
			giveWeapon( hitElement, 3, 1)
			giveWeapon( hitElement, 41, 500)
			giveWeapon( hitElement, 31, 1000)
		end
	end
end
addEventHandler( "onColShapeHit", JailColShape, wardenWeaponGive )
addEventHandler( "onColShapeLeave", JailColShape, wardenWeaponTake )

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)

function storeJailTime()
	if getElementData(source, 'SAEGPolice.jailTimer') ~= nil then
		local id = getElementData(source, 'id')
		outputDebugString("ID: ".. id)
		outputDebugString("TD: ".. getTimerDetails( getElementData(source, 'RPGPolice.jailTimer') ) )
		local timeInJail,_,_ = getTimerDetails(getElementData(source, 'SAEGPolice.jailTimer'))
		executeSQLCreateTable("quitTimerJail","id INTEGER, timeLeftInJail INTEGER")
		executeSQLInsert("quitTimerJail","'"..id.."','"..timeInJail.."'")
	end
end
addEventHandler("onPlayerQuit", root, storeJailTime)

function getBlipAttachedToPlayer(player)
	if player and isElement(player) then
		local attachedElements = getAttachedElements(player)
		for k,v in ipairs(getAttachedElements(player)) do
			if getElementType(v) == "blip" then
				return v
				-- no break needed
			end
		end
		-- if it didn't return there
		return false
	end
end

addEvent("takeAll",true)
addEventHandler("takeAll",getRootElement(),function()
	if isElement(source) then
		takeAllWeapons(source)
	end
end)

function saveJailTimer(timeInJail,id)
	outputDebugString("!")
	if id and timeInJail then
	    outputDebugString(""..timeInJail)
	    outputDebugString(""..id)
	    local result = executeSQLSelect("quitTimerJail", "id, quitTimer", "id = '"..id.."'", 1)
		if result and #result > 0 then
			outputDebugString("Olsd timer"..timeInJail)
			return
		else
			executeSQLInsert("quitTimerJail","'"..id.."','"..timeInJail.."'")
		end
    end
end
addEvent("saveJailTimer",true)
addEventHandler("saveJailTimer",root,saveJailTimer)

 

19 minutes ago, SuperCroz said:

Before posting the code, Prove that you have relation/connection to SAEG server else this is a leaked script.

Sure dude, ask me any question private or come ingame if u want me to proove that for u ......

Link to comment
33 minutes ago, Gravestone said:

If you're the owner of this code, then you'll obviously know how to fix it yourself.

OMG DUDE I AM THE FKING OWNER !!! Check this forum and and contact the owner, his profile is *-* and then u will see that it is me ffs .....

saegrpg.byethost3.com

Edited by Angel02
Link to comment

Sorry but this is like every other server. They are making use of the WSS police script, it's pretty obviously that this guy is making usage of the leaked WSS scripts.So don't expect any help from me.If you need help with something make sure you aren't asking them to fix things in leaked scripts, and as server owner it's required that you know how to script incase something goes wrong.

I consider this topic useless since you are requesting us to fix a leaked WSS script

Link to comment
1 hour ago, Syntrax# said:

Sorry but this is like every other server. They are making use of the WSS police script, it's pretty obviously that this guy is making usage of the leaked WSS scripts.So don't expect any help from me.If you need help with something make sure you aren't asking them to fix things in leaked scripts, and as server owner it's required that you know how to script incase something goes wrong.

I consider this topic useless since you are requesting us to fix a leaked WSS script

OH rly ? WSS script and bugged ? -_- ........

Link to comment
5 hours ago, Angel02 said:

OH rly ? WSS script and bugged ? -_- ........

Yes it's obviously WSSpolice, Considering your scripting knowledge it's pretty clear that this is a leaked script nad you are just claiming that this is yours.

And it's not bugged it's a quick simple fix, if you aren't able to fix this how did you create the script at all O.o

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...