Jump to content

اريد مقر شرطة


Recommended Posts

  • 2 weeks later...
On 23/03/2020 at 17:22, DmaR..x said:

تفضل رابط المود , 

أضغط هنأ

بخصوص مقر الشرطة , يمديك تصمم ..
 

 

شكرا على المود ولكن سؤال ابغاه انويتحقق من قروب الشرطة وليس التيم لانو التيم ماينحفظ عند الخروج ممكن مساعدة

Edited by mohammedhadj
Link to comment
3 hours ago, Marwan_bv said:

شكرا على المود ولكن سؤال ابغاه انويتحقق من قروب الشرطة وليس التيم لانو التيم ماينحفظ عند الخروج ممكن مساعدة

وضح حبيبي

  • Like 1
Link to comment
16 hours ago, DmaR..x said:

وضح حبيبي

قتلك انو عملت قروب شرطة من مود قروبات فلم يعمل المود وعملت تيم شرطة واظفت نفسي فيه من لوحة الادمن فعمل المود يعني كيف اجعله يتحقق من القروب وليس التيم

Link to comment
2 hours ago, jakson said:

اعرض كودك و راح نساعدك 

 

1 hour ago, -Ilker. said:

تحقق من الداتا الي مسجل عليها اسم القروب

addEventHandler("onClientPlayerWeaponFire", localPlayer,
function(wp)
	if wp == 41 then return end
	local team = getPlayerTeam(source)
	if team and getTeamName(team) ~= "Police" then
		if not isTimer(gunFireCheckTimer) then
			gunFireCheckTimer = setTimer(function() end, 3500, 1)
			local wL = getPlayerWantedLevel(source)
			if wp ~= 16 then
				if wL < 2 then
					for i, player in ipairs(getElementsByType("player")) do
						local team = getPlayerTeam(player)
						if team and getTeamName(team) == "Police" then
							local x1, y1, z1 = getElementPosition(source)
							local x2, y2, z2 = getElementPosition(player)
							if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 15 then
								triggerServerEvent("setWantLevel", localPlayer, 2)
								break
							end
						end
					end
				end
			else
				if wL < 4 then
					for i, player in ipairs(getElementsByType("player")) do
						local team = getPlayerTeam(player)
						if team and getTeamName(team) == "Police" then
							local x1, y1, z1 = getElementPosition(source)
							local x2, y2, z2 = getElementPosition(player)
							if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) < 15 then
								triggerServerEvent("setWantLevel", localPlayer, 4)
								break
							end
						end
					end
				end
			end
		end
	end
end)

addEventHandler("onClientVehicleDamage", root,
function(attacker)
	local player = getVehicleController(source)
	if attacker then
		if getElementType(attacker) == "vehicle" then
			attacker = getVehicleController(attacker)
		end
		if player and attacker and getElementType(attacker) == "player" then
			local playerTeam = getPlayerTeam(player)
			local attackerTeam = getPlayerTeam(attacker)
			if playerTeam and getTeamName(playerTeam) == "Police" and attackerTeam ~= playerTeam then
				if not isTimer(vehicleDMGCheckTimer) then
					vehicleDMGCheckTimer = setTimer(function() end, 3500, 1)
					local wL = getPlayerWantedLevel(attacker)
					if wL < 3 then
						triggerServerEvent("setWantLevel", attacker, 3)
					end
				end
			end
		end
	end
end)

addEventHandler("onClientPlayerDamage", localPlayer,
function(attacker, wp)
	if wp == 41 then return end
	if attacker and attacker ~= source then
		--if getElementType(attacker) == "vehicle" then
			--attacker = getVehicleController(attacker)
		--end
		local attackerTeam = getPlayerTeam(attacker)
		local sourceTeam = getPlayerTeam(source)
		local LegalStatus = getElementData(source, "LegalStatus")
		if attackerTeam and getTeamName(attackerTeam) == "Police" then
			local wL = getPlayerWantedLevel(source)
			if wL <= 2 then
				cancelEvent()
			end
		end
		if LegalStatus == "Jailed" or LegalStatus == "Arrested" then
			cancelEvent()
		end
		if sourceTeam and getTeamName(sourceTeam) == "Police" and getElementData(attacker, "LegalStatus") == "Jailed" then
			cancelEvent()
		end
		if attackerTeam and getTeamName(attackerTeam) == "Police" and wp == 3 and LegalStatus == "Jailed" then
			if isElementWithinColShape(localPlayer, JailCol1) or isElementWithinColShape(localPlayer, JailCol2) or isElementWithinColShape(localPlayer, JailCol3) or isElementWithinColShape(localPlayer, JailCol4) then
				return
			end
			triggerServerEvent("backMeToJail", localPlayer)
		end
	end
end)

addEvent("startAlarm", true)
addEventHandler("startAlarm", root,
function()
	if isElement(alarmSound) then destroyElement(alarmSound) end
	if isTimer(alarmTimer) then killTimer(alarmTimer) end
	alarmSound = playSound("jail-Warning.mp3", true)
	alarmTimer = setTimer(function()
		if isElement(alarmSound) then
			destroyElement(alarmSound)
		end
	end, 8000, 1)
end)

Blip = {}

addEventHandler("onClientResourceStart", resourceRoot,
function()
	for i, player in ipairs(getElementsByType("player")) do
		Blip[player] = createBlipAttachedTo(player)
	end
end)

addEventHandler("onClientPlayerJoin", root,
function()
	Blip[source] = createBlipAttachedTo(source)
end)

addEventHandler("onClientPlayerQuit", root,
function()
	if isElement(Blip[source]) then
		destroyElement(Blip[source])
	end
	Blip[source] = nil
end)

JailCol1 = createColCuboid(1546.53, -1618.5, -90.35, 18.85, 5, 4)
JailCol2 = createColCuboid(1546.53, -1640.7, -90.35, 18.85, 6.5, 4)
JailCol3 = createColCuboid(1542, -1640.7, -84, 32.7, 6.5, 4)
JailCol4 = createColCuboid(1542, -1618.5, -84, 32.7, 5, 4)

addEvent("onHacking", true)
addEventHandler("onHacking", root,
function()
	if isTimer(hackShowTimer) then killTimer(hackShowTimer) end
	hackShow = getPlayerName(source)
	exports.TopBarChat:sendClientMessage(getPlayerName(source).." is hacking the Police PC.", 255, 0, 100, false, 7)
	hackShowTimer = setTimer(function() hackShow = false end, 7000, 1)
end)

addEvent("onEscaping", true)
addEventHandler("onEscaping", root,
function(rsp)
	if isTimer(escapShowTimer) then killTimer(escapShowTimer) end
	escapShow = rsp
	exports.TopBarChat:sendClientMessage(getPlayerName(source).." has escape from the Jail, responsible for his escape "..rsp, 255, 0, 0, false, 7)
	escapShowTimer = setTimer(function() escapShow = false end, 7000, 1)
end)

local x, y = guiGetScreenSize()

addEventHandler("onClientPreRender", root,
function()
	local Cop = getElementData(localPlayer, "ArresterCop")
	if isElement(Cop) and not isPedInVehicle(localPlayer) then
		local copX, copY, copZ = getElementPosition(Cop)
		local PrisonerX, PrisonerY, PrisonerZ = getElementPosition(localPlayer)
		
		local copInt = getElementInterior(Cop)
		local prisonerInt = getElementInterior(localPlayer)
		if copInt ~= prisonerInt and not isTimer(intTimer) then
			intTimer = setTimer(function() end, 3000, 1)
			triggerServerEvent("warpPosAndIntAndDim", localPlayer, "INT", copInt, copX, copY, copZ)
		end
		
		local copDim = getElementDimension(Cop)
		local prisonerDim = getElementDimension(localPlayer)
		if copDim ~= prisonerDim and not isTimer(dimTimer) then
			dimTimer = setTimer(function() end, 3000, 1)
			triggerServerEvent("warpPosAndIntAndDim", localPlayer, "DIM", copDim, copX+0.1, copY+0.1, copZ+0.5)
		end
		
		local dis = getDistanceBetweenPoints3D(copX, copY, copZ, PrisonerX, PrisonerY, PrisonerZ)
		if (dis > 20) then
			if not isTimer(tooFarCopTimer) then
				triggerServerEvent("warpPosAndIntAndDim", localPlayer, false, false, copX+1, copY+1, copZ)
				setControlState("forwards", false)
				setControlState("walk", false)
				setControlState("sprint", false)
				tooFarCopTimer = setTimer(function() end, 3000, 1)
			end
		elseif (dis > 10) then
			setControlState("forwards", true)
			setControlState("sprint", true)
			setControlState("walk", false)
		elseif (dis > 3) then
			setControlState("forwards", true)
			setControlState("sprint", false)
			setControlState("walk", false)
		elseif (dis > 2) then
			setControlState("forwards", true)
			setControlState("sprint", false)
			setControlState("walk", true)
		elseif (dis > 1) then
			setControlState("forwards", false)
			setControlState("walk", false)
			setControlState("sprint", false)
		end
		setPedRotation(localPlayer, 360-math.deg(math.atan2((copX-PrisonerX), (copY-PrisonerY))) % 360)
		setCameraTarget(localPlayer)
	end
	
	local HackTime = getElementData(localPlayer, "HackTime") or 0
	if HackTime and HackTime > 0 then
		dxDrawFramedText("Hacking in process: "..HackTime.." sec", x*0.1, y*0.550, x*0.99, y*0.97, tocolor(255, 0, 0, 255), 1.5, "clear", "center")
	end
	
	if hackShow then
		dxDrawImage(x/2+160, y-110, 100, 100, "hack.png")
	end
	
	if escapShow then
		dxDrawImage(x/2+160, y-110, 100, 100, "esc.png")
	end
	
	if isElement(alarmSound) then
		if getElementInterior(localPlayer) ~= 6 then
			setSoundVolume(alarmSound, 0)
		else
			setSoundVolume(alarmSound, 1)
		end
	end
	
	LegalStatus = getElementData(localPlayer, "LegalStatus")
	if LegalStatus == "Arrested" or LegalStatus == "Jailed" then
		setPedWeaponSlot(localPlayer, 0)
	end
	JailTime = tonumber(getElementData(localPlayer, "JailTime")) or 0
	BailAmount = tonumber(getElementData(localPlayer, "BailAmount")) or 0
	if LegalStatus == "Jailed" then
		if (JailTime) > 0 then
			dxDrawFramedText("Remaining Time: "..JailTime.." Secs", x*0.875, y*0.911, x*0.99, y*0.97, tocolor(0, 150, 255, 255), 1.5, "clear")
		end
		if getKeyBoundToFunction(onJailTimeComplete) then
			if JailTime <= 0 and BailAmount <= 0 then
				dxDrawFramedText("Your Jail time finish | Press 'H' to exit the jail.", x*0.875, y*0.911, x*0.99, y*0.97, tocolor(0, 255, 0, 255), 1.5, "clear")
			else
				dxDrawFramedText("Your Jail time finish | Press 'H' to pay your bail and exit the jail.", x*0.875, y*0.911, x*0.99, y*0.97, tocolor(255, 150, 0, 255), 1.5, "clear")
			end
		end
		dxDrawFramedText("Bail: $"..BailAmount, x*0.875, y*0.951, x*0.99, y*0.97, tocolor(150, 255, 0, 255), 1.5, "clear")
	end
end)

addEventHandler("onClientMarkerHit", root,
function(player)
	if player == localPlayer then
		if source == sendToJail then
			triggerServerEvent("sendToJail", localPlayer)
			destroyElement(sendToJail)
		end
	end
end)

setTimer(function()
	local team = getPlayerTeam(localPlayer)
	if team and getTeamName(team) == "Police" then
		local r, g, b = getTeamColor(team)
		setPlayerNametagColor(localPlayer, r, g, b)
		setBlipColor(Blip[localPlayer], r, g, b, 255)
		jMarker = false
		for _, p in ipairs(getElementsByType("player")) do
			if (getElementData(p, "ArresterCop") == localPlayer) then
				jMarker = true
				if not isElement(sendToJail) then
					sendToJail = createMarker(1533, -1676, 11, "cylinder", 5, 255, 0, 255, 150)
				end
				break
			end
		end
		if not jMarker and isElement(sendToJail) then
			destroyElement(sendToJail)
		end
		for i, player in ipairs(getElementsByType("player")) do
			local team = getPlayerTeam(player)
			if team and getTeamName(team) ~= "Police" then
				local LegalStatus = getElementData(player, "LegalStatus")
				local wL = getPlayerWantedLevel(player)
				if LegalStatus == "Arrested" or LegalStatus == "Jailed" then
					setPlayerNametagColor(player, 0, 0, 0)
					setBlipColor(Blip[player], 0, 0, 0, 255)
				elseif wL >= 5 then
					setPlayerNametagColor(player, 255, 0, 0)
					setBlipColor(Blip[player], 255, 0, 0, 255)
				elseif wL >= 3 then
					setPlayerNametagColor(player, 255, 150, 0)
					setBlipColor(Blip[player], 255, 150, 0, 255)
				elseif wL >= 1 then
					setPlayerNametagColor(player, 255, 255, 0)
					setBlipColor(Blip[player], 255, 250, 0, 255)
				elseif wL == 0 then
					setPlayerNametagColor(player, 255, 255, 255)
					setBlipColor(Blip[player], 255, 250, 255, 255)
				end
			else
				if team and getTeamName(team) == "Police" then
					local r, g, b = getTeamColor(team)
					setPlayerNametagColor(player, r, g, b)
					setBlipColor(Blip[player], r, g, b, 255)
				end
			end
		end
	else
		for i, player in ipairs(getElementsByType("player")) do
			local team = getPlayerTeam(player)
			if team then
				local r, g, b = getTeamColor(team)
				setPlayerNametagColor(player, r, g, b)
				setBlipColor(Blip[player], r, g, b, 255)
			end
		end
	end
	if LegalStatus == "Jailed" then
		if isElementWithinColShape(localPlayer, JailCol1) or isElementWithinColShape(localPlayer, JailCol2) or isElementWithinColShape(localPlayer, JailCol3) or isElementWithinColShape(localPlayer, JailCol4) then
			if JailTime > 0 then
				setElementData(localPlayer, "JailTime", JailTime-1)
				if getKeyBoundToFunction(onJailTimeComplete) then
					unbindKey("H", "down", onJailTimeComplete)
				end
			elseif BailAmount >= 50 then
				bindJailExit()
				setElementData(localPlayer, "BailAmount", BailAmount-50)
			elseif BailAmount < 50 and BailAmount > 0 then
				setElementData(localPlayer, "BailAmount", 0)
				bindJailExit()
			else
				bindJailExit()
			end
		end
	end
end, 1000, 0)

function bindJailExit()
	if not getKeyBoundToFunction(onJailTimeComplete) then
		bindKey("H", "down", onJailTimeComplete)
	end
end

function onJailTimeComplete()
	if JailTime <= 0 then
		if BailAmount > 0 then 
			if getPlayerMoney() >= BailAmount then
				setElementData(localPlayer, "LegalStatus", "Free")
				unbindKey("H", "down", onJailTimeComplete)
				setElementPosition(localPlayer, 255.5, 86.5, 1002.5)
				setElementInterior(localPlayer, 6)
				triggerServerEvent("takeMoney", localPlayer, BailAmount)
				setElementData(localPlayer, "BailAmount", false)
				setElementData(localPlayer, "JailTime", false)
			else
				exports.TopBarChat:sendClientMessage("You don't have enough money!", 255, 0, 0, false)
			end
		else
			setElementData(localPlayer, "LegalStatus", "Free")
			unbindKey("H", "down", onJailTimeComplete)
			setElementPosition(localPlayer, 255.5, 86.5, 1002.5)
			setElementInterior(localPlayer, 6)
		end
	end
end

function dxDrawFramedText(message, left, top, width, height, color, scale, sans, alignX, alignY, clip, wordBreak, postGUI, frameColor)
  if not color then
    color = tocolor(255, 255, 255, 255)
  end
  if not frameColor then
    frameColor = tocolor(0, 0, 0, 255)
  end
  if not scale then
    scale = 1
  end
  if not sans then
    sans = "sans"
  end
  if not alignX then
    alignX = "right"
  end
  if not alignY then
    alignY = "top"
  end
  if not clip then
    clip = false
  end
  if not wordBreak then
    wordBreak = false
  end
  message1 = string.gsub(message, "#%x%x%x%x%x%x", "")
  dxDrawText(message, left + 1, top + 1, width + 1, height + 1, frameColor, scale, sans, alignX, alignY, clip, wordBreak, true)
  dxDrawText(message, left + 1, top - 1, width + 1, height - 1, frameColor, scale, sans, alignX, alignY, clip, wordBreak, true)
  dxDrawText(message, left - 1, top + 1, width - 1, height + 1, frameColor, scale, sans, alignX, alignY, clip, wordBreak, true)
  dxDrawText(message, left - 1, top - 1, width - 1, height - 1, frameColor, scale, sans, alignX, alignY, clip, wordBreak, true)
  dxDrawText(message, left, top, width, height, color, scale, sans, alignX, alignY, clip, wordBreak, true)
end

function getPlayerWantedLevel(player)
	local level = getElementData(player, "WantLvl") or 0
	return level
end
--server--
------- ------- ------- ------- ------- ------- ------- ------- -------
------- ------ ------ ------|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" then
				if getTeamName(damagedTeam) ~= "Police" 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" 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 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" then
				if getTeamName(killedTeam) ~= "Police" 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" 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 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 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")
			setAccountData(account, "BailAmount", wL*1000)
			setAccountData(account, "JailTime", wL*60)
			setAccountData(account, "wL", 0)
			local Cop = getElementData(source, "ArresterCop")
			if isElement(Cop) then
				givePlayerMoney(Cop, wL*1000)
				exports.TopBarChat:sendClientMessage("You earned $"..(wL*1000)..".", Cop, 0, 255, 0)
			end
		elseif LegalStatus == "Jailed" then
			setAccountData(account, "LegalStatus", "Jailed")
			setAccountData(account, "BailAmount", BailAmount)
			setAccountData(account, "JailTime", JailTime)
			setAccountData(account, "wL", 0)
		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("onPlayerLogin", root,
function()
	loadPlayerSetting(source)
	bindKey(source, "h", "down", ticketAction)
end)

addEventHandler("onResourceStart", resourceRoot,
function()
	for i, player in ipairs(getElementsByType("player")) do
		loadPlayerSetting(player)
		bindKey(player, "h", "down", ticketAction)
	end
end)

addEventHandler("onResourceStop", resourceRoot,
function()
	for i, player in ipairs(getElementsByType("player")) do
		local account = getPlayerAccount(player)
		if account and not isGuestAccount(account) then
			local LegalStatus = getElementData(player, "LegalStatus")
			local BailAmount = getElementData(player, "BailAmount") or 0
			local JailTime = getElementData(player, "JailTime") or 0
			local wL = getPlayerWantedLevel(player) 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")
				setAccountData(account, "BailAmount", wL*1000)
				setAccountData(account, "JailTime", wL*60)
				setAccountData(account, "wL", 0)
			elseif LegalStatus == "Jailed" then
				setAccountData(account, "LegalStatus", "Jailed")
				setAccountData(account, "BailAmount", BailAmount)
				setAccountData(account, "JailTime", JailTime)
				setAccountData(account, "wL", 0)
			end
		end
	end
end)

function ticketAction(player)
	local team = getPlayerTeam(player)
	local TeamName = team and getTeamName(team) or false
	if TeamName == "Police" then
		local target = getPedTarget(player)
		if target and getControlState(player, "aim_weapon") and getElementType(target) == "player" then
			local LegalStatus = getElementData(target, "LegalStatus")
			local wL = getPlayerWantedLevel(target)
			local TicketStat = getElementData(target, "Ticket")
			if wL == 2 and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" and not TicketStat then
				local team = getPlayerTeam(target)
				local TeamName = team and getTeamName(team) or false
				if TeamName ~= "Police" then
					exports.TopBarChat:sendClientMessage(getPlayerName(player).." is asking you to pay a ticket $500. press H to pay.", target, 255, 255, 0)
					exports.TopBarChat:sendClientMessage("You asked "..getPlayerName(target).." to pay a ticket $500.", player, 255, 255, 0)
					setElementData(target, "Ticket", player)
				end
			end
		end
	else
		local TicketStat = getElementData(player, "Ticket")
		if TicketStat then
			local LegalStatus = getElementData(player, "LegalStatus")
			local wL = getPlayerWantedLevel(player)
			if wL == 2 and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then
				if getPlayerMoney(player) >= 500 then
					setPlayerWantedLevel(player, 0)
					takePlayerMoney(player, 500)
					setElementData(player, "Ticket", false)
					exports.TopBarChat:sendClientMessage("You've paid the ticket $500 to the cop "..getPlayerName(TicketStat)..".", player, 0, 255, 0)
					if isElement(TicketStat) then
						givePlayerMoney(TicketStat, 500)
						exports.TopBarChat:sendClientMessage(getPlayerName(player).." has pay his $500 ticket.", TicketStat, 0, 255, 0)
					end
				end
			else
				setElementData(player, "Ticket", false)
			end
		end
	end
end

function loadPlayerSetting(player)
	local account = getPlayerAccount(player)
	if account and not isGuestAccount(account) then
		local LegalStatus = getAccountData(account, "LegalStatus") or "Free"
		local BailAmount = getAccountData(account, "BailAmount") or 0
		local JailTime = getAccountData(account, "JailTime") or 0
		local wL = getAccountData(account, "wL") or 0
		setElementData(player, "LegalStatus", LegalStatus)
		setElementData(player, "BailAmount", BailAmount)
		setElementData(player, "JailTime", JailTime)
		setPlayerWantedLevel(player, wL)
	end
end

pModel = {
	["598"] = true,
	["597"] = true,
	["596"] = true,
	["523"] = true,
	["599"] = true,
	["427"] = true
}

addEventHandler("onPlayerVehicleEnter", root,
function(vehicle, seat, jacked)
	local team = getPlayerTeam(source)
	if team and getTeamName(team) == "Police" then
		if jacked then
			local wL = getPlayerWantedLevel(jacked)
			local LegalStatus = getElementData(jacked, "LegalStatus")
			if wL >= 3 and LegalStatus ~= "Arrested" and LegalStatus ~= "Jailed" then
				setElementData(jacked, "ArresterCop", source)
				setElementData(jacked, "LegalStatus", "Arrested")
				showCursor(jacked, true)
				toggleAllControls(jacked, false, true, false)
				ArrestTimer[jacked] = setTimer(sendToJail, 40000, 1, jacked)
				exports.TopBarChat:sendClientMessage("You Arrested "..getPlayerName(jacked).."!", source, 0, 255, 0)
				exports.TopBarChat:sendClientMessage("You have been Arrested by "..getPlayerName(source).."!", jacked, 255, 255, 0)
			end
		end
		for i, player in ipairs(getElementsByType("player")) do
			if (getElementData(player, "ArresterCop") == source) then
				local passengers = getVehicleMaxPassengers(vehicle)
				for seat = 0, passengers do
					if seat > 0 and not getVehicleOccupant(vehicle, seat) then
						warpPedIntoVehicle(player, vehicle, seat)
						break
					end
				end
			end
		end
	else
		if pModel[getElementModel(vehicle)] then
			setPlayerWantedLevel(source, 4)
		end
	end
end)

addEventHandler("onVehicleStartEnter", root,
function(player, seat, driver)
	if driver and seat == 0 then
		local policeTeam = getTeamFromName("Police")
		if getPlayerTeam(driver) == policeTeam and getPlayerTeam(player) == policeTeam then
			cancelEvent()
		end
	end
end)

addEventHandler("onPlayerVehicleExit", root,
function(vehicle)
	local team = getPlayerTeam(source)
	if team and getTeamName(team) == "Police" then
		for i, player in ipairs(getElementsByType("player")) do
			if (getElementData(player, "ArresterCop") == source) then
				removePedFromVehicle(player)
			end
		end
	end
end)

function freePrisoner(player)
	setElementData(player, "ArresterCop", false)
	setElementData(player, "LegalStatus", "Free")
	showCursor(player, false)
	setControlState(player, "sprint", false)
	setControlState(player, "walk", false)
	setControlState(player, "forwards", false)
	toggleAllControls(player, true)
	if isTimer(ArrestTimer[player]) then killTimer(ArrestTimer[player]) ArrestTimer[player] = nil end
end

addCommandHandler("free",
function(player)
	local team = getPlayerTeam(player)
	if team and getTeamName(team) == "Police" then
		for i, p in ipairs(getElementsByType("player")) do
			if (getElementData(p, "ArresterCop") == player) then
				freePrisoner(p)
				exports.TopBarChat:sendClientMessage("You freed "..getPlayerName(p), player, 255, 255, 0)
				exports.TopBarChat:sendClientMessage("The cop "..getPlayerName(player).." has freed you!", p, 255, 255, 0)
			end
		end
	end
end)

function sendToJail(player, i)
	local Cop = getElementData(player, "ArresterCop")
	if not isPedDead(player) then
		local Index = i or math.random(1, #gDoors-3)
		local x, y, z, r = gDoors[Index]["JPosX"], gDoors[Index]["JPosY"], gDoors[Index]["JPosZ"], gDoors[Index]["JRot"]
		if isPedInVehicle(player) then
			removePedFromVehicle(player)
		end
		setElementPosition(player, x, y, z)
		setPedRotation(player, r)
		setElementInterior(player, 6)
	end
	setElementData(player, "ArresterCop", false)
	setElementData(player, "LegalStatus", "Jailed")
	local wL = getPlayerWantedLevel(player)
	if isElement(Cop) then
		givePlayerMoney(Cop, wL*1000)
		exports.TopBarChat:sendClientMessage("You earned $"..(wL*1000)..".", Cop, 0, 255, 0)
	end
	setElementData(player, "JailTime", wL*60)
	setElementData(player, "BailAmount", wL*1000)
	showCursor(player, false)
	toggleAllControls(player, true)
	setControlState(player, "sprint", false)
	setControlState(player, "walk", false)
	setControlState(player, "forwards", false)
	setPlayerWantedLevel(player, 0)
	if isTimer(ArrestTimer[player]) then killTimer(ArrestTimer[player]) ArrestTimer[player] = nil end
end

addEvent("sendToJail", true)
addEventHandler("sendToJail", root,
function()
	for _, p in ipairs(getElementsByType("player")) do
		if (getElementData(p, "ArresterCop") == source) then
			sendToJail(p)
		end
	end
end)

addEventHandler("onPlayerSpawn", root,
function()
	local LegalStatus = getElementData(source, "LegalStatus")
	if LegalStatus == "Jailed" then
		local gDoors = gDoors[math.random(1, #gDoors-3)]
		local x, y, z, r = gDoors["JPosX"], gDoors["JPosY"], gDoors["JPosZ"], gDoors["JRot"]
		setTimer (setElementPosition, 2000, 1, source, x, y, z)
		setTimer (setElementInterior, 2000, 1, source, 6)
		setTimer (setElementDimension, 2000, 1, source, 0)
		setTimer (setPedRotation, 2000, 1, source, r)
	end
end)

bribeTable = {}
bribeTimer = {}

function bribe_acc(player, cmd)
	if getElementData(player, "MissionProtection") or getElementData(player, "MissionWarProtection") or getElementData(player, "MissionStreet") then return end
	if cmd == "sop" then
		if not isTimer(bribeTimer[player]) and (getElementData(player, "HackTime") or 0) <= 0 then
			local LegalStatus = getElementData(player, "LegalStatus")
			local wL = getPlayerWantedLevel(player)
			local Bail = 0
			local JailTime = 0
			if LegalStatus ~= "Arrested" then
				if wL > 2 then
					Bail= wL*1000
					JailTime = wL*60
				elseif LegalStatus == "Jailed" then
					Bail= getElementData(player, "BailAmount") or 0
					JailTime = getElementData(player, "JailTime") or 0
				end
				if JailTime > 0 and Bail > 0 then
					if getPlayerMoney(player) >= Bail then
						for i, p in ipairs(getElementsByType("player")) do
							local team = getPlayerTeam(p)
							if team and getTeamName(team) == "Police" then
								local x1, y1, z1 = getElementPosition(p)
								local x2, y2, z2 = getElementPosition(player)
								if getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2) <= 35 then
									if not bribeTable[p] then bribeTable[p] = {} end
									if not bribeTable[p][player] then 
										bribeTable[p][player] = Bail
										exports.TopBarChat:sendClientMessage(getPlayerName(player).." is offering you bribe $"..Bail, p, 0, 255, 0)
										exports.TopBarChat:sendClientMessage("You offered bribe $"..Bail.." to the cop "..getPlayerName(p), player, 0, 255, 0)
										bribeTimer[player] = setTimer(function(player) bribeTimer[player] = nil end, 3000, 1, player)
										break
									end
								end
							end
						end
						if not isTimer(bribeTimer[player]) then
							exports.TopBarChat:sendClientMessage("There no cops near you.", player, 255, 255, 0)
						end
					else
						exports.TopBarChat:sendClientMessage("You don't have enough money!", player, 255, 0, 0)
					end
				end
			end
		else
			exports.TopBarChat:sendClientMessage("Please wait 3 sec to be able to bribe again.", player, 255, 255, 0)
		end
	elseif cmd == "ok" then
		if bribeTable[player] then
			for p, Bail in pairs(bribeTable[player]) do
				local LegalStatus = getElementData(p, "LegalStatus")
				local wL = getPlayerWantedLevel(p)
				if not isElement(p) or getPlayerMoney(p) < Bail or (LegalStatus == "Arrested" and LegalStatus == "Free" and LegalStatus == false and wL < 3) or (getElementData(p, "HackTime") or 0) > 0 then
					for i, police in ipairs(getElementsByType("player")) do
						if bribeTable[police] then
							bribeTable[police][p] = nil
						end
					end
				else
					givePlayerMoney(player, Bail)
					takePlayerMoney(p, Bail)
					exports.TopBarChat:sendClientMessage("You accepted bribe from "..getPlayerName(p).." for $"..Bail, player, 0, 255, 0)
					exports.TopBarChat:sendClientMessage("The cop "..getPlayerName(player).." has accepted your bribe $"..Bail, p, 0, 255, 0)
					for i, police in ipairs(getElementsByType("player")) do
						if bribeTable[police] then
							bribeTable[police][p] = nil
						end
					end
					setElementData(p, "JailTime", 0)
					setElementData(p, "BailAmount", 0)
					setPlayerWantedLevel(p, 0)
					break
				end
			end
		end
	end
end
addCommandHandler("sop", bribe_acc)
addCommandHandler("ok", bribe_acc)

HackMarker = createMarker(1585.5, -1614.4, -84, "cylinder", 1.85, 255, 0, 0, 100)
setElementInterior(HackMarker, 6)

addEventHandler("onMarkerHit", HackMarker,
function(player)
	if getElementType(player) == "player" then
		local team = getPlayerTeam(player)
		if team and getTeamName(team) ~= "Police" then
			if not isKeyBound(player, "tab", "down", HackPoliceComputer) then
				bindKey(player, "tab", "down", HackPoliceComputer)
			end
		end
	end
end)

addEventHandler("onMarkerLeave", HackMarker,
function(player)
	if getElementType(player) == "player" then
		local team = getPlayerTeam(player)
		if team and getTeamName(team) ~= "Police" then
			if isKeyBound(player, "tab", "down", HackPoliceComputer) then
				unbindKey(player, "tab", "down", HackPoliceComputer)
			end
			if (getElementData(player, "HackTime") or 0) > 0 then
				setElementData(player, "HackTime", false)
				exports.TopBarChat:sendClientMessage(getPlayerName(player).." failed to hack the police pc", root, 255, 0, 0)
				if isTimer(HackTimer) then killTimer(HackTimer) end
			end
		end
	end
end)

function HackPoliceComputer(player)
	local team = getPlayerTeam(player)
	if team and getTeamName(team) ~= "Police" then
		if not isTimer(HackTimer) then
			if not isTimer(HackResetTimer) then
				setElementData(player, "HackTime", 50)
				--exports.TopBarChat:sendClientMessage(getPlayerName(player).." is hacking the police pc.", root, 0, 255, 255)
				triggerClientEvent(root, "onHacking", player)
				setPlayerWantedLevel(player, 6)
				setPedRotation(player, 270)
				setElementPosition(player, 1585.5, -1614.49, -83.5)
				setElementFrozen(player, true)
				setPedAnimation(player, "INT_OFFICE", "OFF_Sit_Type_Loop", -1, true, false)
				HackTimer = setTimer(function(player) 
					local currentTime = getElementData(player, "HackTime") or 0
					if currentTime <= 0 then
						killTimer(HackTimer)
						setElementData(player, "HackTime", false)
						triggerClientEvent(root, "startAlarm", root)
						HackResetTimer = setTimer(function() end, 1800000, 1)
						HackedComputerTimer = setTimer(function() end, 35000, 1)
						openAllJailDoors()
						exports.TopBarChat:sendClientMessage(getPlayerName(player).." has hacked the police pc and all jail is now opened.", root, 255, 0, 100)
						givePlayerMoney(player, 10000)
						setElementFrozen(player, false)
						setPedAnimation(player, false)
					else
						setElementData(player, "HackTime", currentTime - 1)
					end
				end, 1000, 0, player)
			else
				exports.TopBarChat:sendClientMessage("The pc already hacked before, try again later.", player, 255, 255, 0)
			end
		end
	end
end

function openAllJailDoors()
	for i, door in pairs(Doors) do
		local i = getElementData(door, "Index")
		setElementData(door, "Stat", "Opened", false)
		moveObject(door, 1500, gDoors[i]["oPosX"], gDoors[i]["oPosY"], gDoors[i]["oPosZ"])
		setElementData(door, "LastOpen", false, false)
		if isTimer(moveGtaTimer[door]) then killTimer(moveGtaTimer[door]) moveGtaTimer[door] = nil end
	end
end
------- ------- ------- ------- ------- ------- ------- ------- -------
------- ------- ------- ------- ------- ------- ------- ------- -------
------- ------- ------- ------- ------- ------- ------- ------- -------

Doors = {}

gDoors = {
	{Model = 2930, oPosX = 1560.6, oPosY = -1634.3800048828, oPosZ = -87.699996948242, Rot = 90, cPosX = 1562.3000488281, cPosY = -1634.3800048828, cPosZ = -87.699996948242, JPosX = 1563.3, JPosY = -1637.3, JPosZ = -89.3, JRot = 0},
	{Model = 2930, oPosX = 1556, oPosY = -1634.3800048828, oPosZ = -87.699996948242, Rot = 90, cPosX = 1557.6999511719, cPosY = -1634.3800048828, cPosZ = -87.699996948242, JPosX = 1558.5, JPosY = -1637, JPosZ = -89.3, JRot = 0},
	{Model = 2930, oPosX = 1551, oPosY = -1634.3800048828, oPosZ = -87.699996948242, Rot = 90, cPosX = 1552.9000244141, cPosY = -1634.3800048828, cPosZ = -87.699996948242, JPosX = 1553.7, JPosY = -1637, JPosZ = -89.3, JRot = 0},
	{Model = 2930, oPosX = 1549.8000488281, oPosY = -1634.3800048828, oPosZ = -87.699996948242, Rot = 90, cPosX = 1548.1, cPosY = -1634.3800048828, cPosZ = -87.699996948242, JPosX = 1549, JPosY = -1637, JPosZ = -89.3, JRot = 0},
	{Model = 2930, oPosX = 1549.8, oPosY = -1618.3000488281, oPosZ = -87.699996948242, Rot = 90, cPosX = 1548.1999511719, cPosY = -1618.3000488281, cPosZ = -87.699996948242, JPosX = 1549, JPosY = -1616, JPosZ = -89.3, JRot = 180},
	{Model = 2930, oPosX = 1554.6, oPosY = -1618.3000488281, oPosZ = -87.699996948242, Rot = 90, cPosX = 1553, cPosY = -1618.3000488281, cPosZ = -87.699996948242, JPosX = 1553.5, JPosY = -1616, JPosZ = -89.3, JRot = 180},
	{Model = 2930, oPosX = 1559.3, oPosY = -1618.3000488281, oPosZ = -87.699996948242, Rot = 90, cPosX = 1557.6, cPosY = -1618.3000488281, cPosZ = -87.699996948242, JPosX = 1558, JPosY = -1616, JPosZ = -89.3, JRot = 180},
	{Model = 2930, oPosX = 1560.7, oPosY = -1618.3000488281, oPosZ = -87.699996948242, Rot = 90, cPosX = 1562.4, cPosY = -1618.3000488281, cPosZ = -87.699996948242, JPosX = 1563, JPosY = -1616, JPosZ = -89.3, JRot = 180},
	{Model = 2930, oPosX = 1542, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1543.5, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1544.2, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1549.8, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1548.2, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1549, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1551.3, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1552.9, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1553.5, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1556, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1557.6, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1558.5, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1560.7, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1562.3, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1563, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1565.5, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1566.87, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1567, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1570, oPosY = -1618.2700195313, oPosZ = -81.400001525879, Rot = 90, cPosX = 1571.8, cPosY = -1618.2700195313, cPosZ = -81.400001525879, JPosX = 1572.5, JPosY = -1615.9, JPosZ = -83, JRot = 180},
	{Model = 2930, oPosX = 1570, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1571.6999511719, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1572.5, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1565.4, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1567, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1568, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1564, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1562.3, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1563, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1559.2, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1557.6, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1558.5, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1554.5, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1553, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1553.5, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1546.6, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1548.1, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1549, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1545, oPosY = -1634.3000488281, oPosZ = -81.400001525879, Rot = 90, cPosX = 1543.4, cPosY = -1634.3000488281, cPosZ = -81.400001525879, JPosX = 1544.5, JPosY = -1637, JPosZ = -83, JRot = 0},
	{Model = 2930, oPosX = 1575.2, oPosY = -1636.1999511719, oPosZ = -87.699996948242, Rot = 0, cPosX = 1575.2001953125, cPosY = -1634.7001953125, cPosZ = -87.699996948242},
	{Model = 2930, oPosX = 1570.4, oPosY = -1633.5999755859, oPosZ = -87.699996948242, Rot = 90, cPosX = 1572, cPosY = -1633.5999755859, cPosZ = -87.699996948242},
	{Model = 980, oPosX = 1538.5999755859, oPosY = -1627.44, oPosZ = -85.1, Rot = 90, cPosX = 1538.5999755859, cPosY = -1627.44, cPosZ = -87.7},
}

EscpJail1 = createColCuboid(1575.4, -1637, -90.35, 1, 3, 2.5)
EscpJail2 = createColCuboid(1537, -1629.5, -90.35, 1, 4, 2.5)

for i, door in ipairs(gDoors) do
	if i == #gDoors then
		model = 980
		gate = createObject(door["Model"], door["cPosX"], door["cPosY"], door["cPosZ"], 0, 0, door["Rot"])
		table.insert(Doors, gate)
		marker = createMarker(door["cPosX"], door["cPosY"], door["cPosZ"]-3, "cylinder", 1.85, 255, 0, 0, 0)
		setElementInterior(marker, 6)
		setElementInterior(gate, 6)
		setElementData(EscpJail2, "Door", gate)
	else
		gate = createObject(door["Model"], door["cPosX"], door["cPosY"], door["cPosZ"], 0, 0, door["Rot"])
		table.insert(Doors, gate)
		marker = createMarker(door["Rot"] == 90 and door["cPosX"]+1 or door["cPosX"], door["Rot"] == 90 and door["cPosY"] or door["cPosY"]-1, door["cPosZ"]-3, "cylinder", 1.85, 255, 0, 0, 0)
		setElementInterior(marker, 6)
		setElementInterior(gate, 6)
	end
	setElementData(marker, "Door", gate, false)
	setElementData(gate, "Index", i, false)
	setElementData(gate, "Stat", "Closed", false)
	if i == 23 then
		setElementData(EscpJail1, "Door", gate)
	end
end


addEventHandler("onColShapeLeave", root,
function(player)
	if getElementType(player) == "player" then
		if source == EscpJail1 then
			local LegalStatus = getElementData(player, "LegalStatus")
			if LegalStatus == "Jailed" then
				local door = getElementData(source, "Door")
				local rsp = getElementData(door, "LastOpen") or "Unknown"
				if rsp then
					for i, p in ipairs(getPlayersInTeam(getTeamFromName("Police"))) do
						triggerClientEvent(p, "onEscaping", player, rsp)
						triggerClientEvent(p, "startAlarm", player)
					end
				end
				exports.TopBarChat:sendClientMessage("You escape from the Jail!!", player, 255, 255, 0)
				setElementData(player, "LegalStatus", "Free")
				setElementData(player, "JailTime", false)
				setElementData(player, "BailAmount", false)
				setPlayerWantedLevel(player, 6)
				local rP = getPlayerFromName(rsp)
				if rP then
					takePlayerMoney(rP, 2500)
				end
			end
		elseif source == EscpJail2 then
			local LegalStatus = getElementData(player, "LegalStatus")
			if LegalStatus == "Jailed" then
				local door = getElementData(source, "Door")
				local rsp = getElementData(door, "LastOpen") or "Unknown"
				if rsp then
					for i, p in ipairs(getPlayersInTeam(getTeamFromName("Police"))) do
						triggerClientEvent(p, "onEscaping", player, rsp)
						triggerClientEvent(p, "startAlarm", player)
					end
				end
				exports.TopBarChat:sendClientMessage("You escape from the Jail!!", player, 255, 255, 0)
				setElementData(player, "LegalStatus", "Free")
				setElementData(player, "JailTime", false)
				setElementData(player, "BailAmount", false)
				setPlayerWantedLevel(player, 6)
				local rP = getPlayerFromName(rsp)
				if rP then
					takePlayerMoney(rP, 2500)
				end
			end
		end
	end
end)

local EnterPoliceMarker1 = createMarker(1555, -1675.7, 15.2, "cylinder", 1.2, 255, 150, 0, 150)
local EnterPoliceMarker2 = createMarker(1560.6, -1691, 4.9, "cylinder", 1.2, 255, 150, 0, 150)
local ExitPoliceMarker = createMarker(246.8, 63, 1002.65, "cylinder", 1.2, 255, 150, 0, 150)
--
local EnterJailMarker1 = createMarker(242.8, 66.42, 1002.65, "cylinder", 1.2, 255, 150, 0, 150)
local EnterJailMarker2 = createMarker(246.33, 87.45, 1002.65, "cylinder", 1.2, 255, 150, 0, 150)
--
local ExitJailMarker1 = createMarker(1545.5, -1652.3, -90.5, "cylinder", 1.5, 255, 150, 0, 150)
local ExitJailMarker2 = createMarker(1586.265, -1638.9, -84, "cylinder", 1.5, 255, 150, 0, 150)
setElementInterior(ExitPoliceMarker, 6)
setElementInterior(EnterJailMarker1, 6)
setElementInterior(EnterJailMarker2, 6)
setElementInterior(ExitJailMarker1, 6)
setElementInterior(ExitJailMarker2, 6)

createBlipAttachedTo(EnterPoliceMarker1, 30)

addEventHandler("onMarkerHit", resourceRoot,
function(player)
	if getElementType(player) == "player" and not isPedInVehicle(player) then
		if source == EnterPoliceMarker1 then
			setElementInterior(player, 6, 246.8, 65, 1003)
		elseif source == EnterPoliceMarker2 and getPlayerTeam(player) == getTeamFromName("Police") then
			setElementInterior(player, 6, 217, 78, 1005)
		elseif source == ExitPoliceMarker then
			setElementInterior(player, 0, 1552.7, -1675.4, 16.2)
		elseif source == EnterJailMarker1 then
			setElementPosition(player, 1544, -1652.3, -90)
		elseif source == EnterJailMarker2 then
			setElementPosition(player, 1584.265, -1638.9, -83)
		elseif source == ExitJailMarker1 then
			setElementPosition(player, 244.5, 66.42, 1003)
		elseif source == ExitJailMarker2 then
			setElementPosition(player, 246.33, 85.5, 1003)
		else
			local door = getElementData(source, "Door")
			if door and getElementType(door) == "object" then
				bindKey(player, "tab", "down", onKeyTab, door)
				local index = getElementData(door, "Index")
				if index < #gDoors-3 then
					for i, p in ipairs(getElementsByType("player")) do
						if (getElementData(p, "ArresterCop") == player) then
							bindKey(player, "H", "down", onKeyH, door)
							textDisplayAddObserver(Display, player)
							break
						end
					end
				end
			end
		end
	end
end)


addEventHandler("onMarkerLeave", resourceRoot,
function(player)
	if getElementType(player) == "player" then
		local door = getElementData(source, "Door")
		if door and getElementType(door) == "object" then
			unbindKey(player, "tab", "down", onKeyTab, door)
			unbindKey(player, "H", "down", onKeyH, door)
			textDisplayRemoveObserver(Display, player)
		end
	end
end)

function onKeyTab(player, key, keyState, door)
	local Team = getPlayerTeam(player)
	if Team and Team == getTeamFromName("Police") then
		MoveGate(door, player)
	end
end

function onKeyH(player, key, keyState, door)
	local Team = getPlayerTeam(player)
	if Team and Team == getTeamFromName("Police") then
		local i = getElementData(door, "Index")
		for _, p in ipairs(getElementsByType("player")) do
			if (getElementData(p, "ArresterCop") == player) then
				sendToJail(p, i)
			end
		end
	end
end

moveGtaTimer = {}

function MoveGate(door, player)
	local i = getElementData(door, "Index")
	local Stat = getElementData(door, "Stat")
	if isTimer(HackedComputerTimer) then return end
	if (Stat == "Opened") then
		moveObject(door, 1500, gDoors[i]["cPosX"], gDoors[i]["cPosY"], gDoors[i]["cPosZ"])
		setElementData(door, "Stat", "Closed", false)
		--setTimer(setElementData, 1500, 1, door, "LastOpen", false, false)
		if isTimer(moveGtaTimer[door]) then killTimer(moveGtaTimer[door]) moveGtaTimer[door] = nil end
	elseif (Stat == "Closed") then
		moveObject(door, 1500, gDoors[i]["oPosX"], gDoors[i]["oPosY"], gDoors[i]["oPosZ"])
		setElementData(door, "Stat", "Opened", false)
		if player then setElementData(door, "LastOpen", getPlayerName(player), false) end
		if isTimer(moveGtaTimer[door]) then killTimer(moveGtaTimer[door]) moveGtaTimer[door] = nil end
		if i > #gDoors-3 then
			moveGtaTimer[door] = setTimer(function(door, i) 
				moveObject(door, 1500, gDoors[i]["cPosX"], gDoors[i]["cPosY"], gDoors[i]["cPosZ"])
				setElementData(door, "Stat", "Closed", false)
				moveGtaTimer[door] = nil
				--setTimer(setElementData, 1500, 1, door, "LastOpen", false, false)
			end, 5000, 1, door, i)
		end
	end
end

policeDoor = createObject(968, 1544.699, -1630.798, 13.100, 0, 90, 90)
col = createMarker(1544.4, -1626.8, 12, "cylinder", 10, 0, 0, 0, 0)

moving = false
closed = true
movetime = 968

function openDoor(player)
	if getElementType(player) == "player" then
	if getPlayerTeam(player) ~= getTeamFromName("Police") then return end
	if not moving and closed then
		moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, -90)
		moving = true
		closed = false
		setTimer(function() moving = false end, movetime, 1)
	end
	end
end
addEventHandler("onMarkerHit", col, openDoor)
 
function closeDoor(player)
	if getElementType(player) == "player" then
	if getPlayerTeam(player) ~= getTeamFromName("Police") then return end
	if not moving and not closed then
		moveObject(policeDoor, 968, 1544.699, -1630.798, 13.100, 0, 90)
		moving = true
		closed = true
		setTimer(function() moving = false end, movetime, 1)
	end
	end
end
addEventHandler("onMarkerLeave", col, closeDoor)

setPlayerWantedLevel_ = setPlayerWantedLevel

function setPlayerWantedLevel(player, level)
	local stat = setPlayerWantedLevel_(player, level)
	if stat then
		setElementData(player, "WantLvl", level)
	end
	return stat
end

هاهي الاكواد المشكل يعمل بالتيم وليس القروب و التيم لما اخرج من السيرفر وارجع لا يحفظ ممك نعدلو يبقى بالقروب وازاي نعدلو

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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