Jump to content

Jail Bug


Tando

Recommended Posts

function jailPlayer(player, jtype, jfrom, jtime, reason, relid)
	if(isElement(player) and getElementType(player) == "player" and type(jtype) == "number" and isElement(jfrom) and getElementType(jfrom) == "player" and type(jtime) == "number" and jtime > 0 and jtype >= 0 and jtype <= 3) then
		px, py, pz = getElementPosition(player)
		if(relid ~= nil) then
			relid = relid
		else
			relid = findNearestPD(player)
		end
		if(jtype == 2 or jtype == 1) then
			jtime = math.floor(jtime)
		else
			if(getElementData(player, "viplevel") == 2) then
				jtime = math.floor(jtime-(jtime*0.1))
			elseif(getElementData(player, "viplevel") == 3) then
				jtime = math.floor(jtime-(jtime*0.25))
			elseif(getElementData(player, "viplevel") == 4) then
				jtime = math.floor(jtime-(jtime*0.5))
			else
				jtime = math.floor(jtime)
			end
		end
		if(getElementData(player, "isInSpawner")) then setElementData(player, "isInSpawner", false) triggerClientEvent(player, "onPlayerLeaveSpawner", player) end
		if(getElementData(player, "isInOSpawner")) then setElementData(player, "isInOSpawner", false) triggerClientEvent(player, "hideOwnedVehicles", player) end
		if(isPedInVehicle(player)) then removePedFromVehicle(player) end
        if(doesPedHaveJetPack(player)) then removePedJetPack(player) end
		if(law[getTeamName(getPlayerTeam(player))]) then
			setPlayerTeam(player, getTeamFromName("Unemployed"))
			setElementData(player, "Job", "Unemployed")
			setElementData(player, "Job Rank", "None")
			setElementModel(player, 0)
		end
		setElementInterior(player, 0)
		setElementDimension(player, 33 )
		local nm = math.random(#positions)
		setElementPosition(player, positions[nm][1] or 1573.71, positions[nm][2] or -1641.84,positions[nm][3] or 73.46)
		setElementData(player, "Jailed", "yes")
		triggerClientEvent(player, "deleteTurfInfo", player)
		setElementData(player, "JailTime", jtime)
		setElementData(player, "JailType", jtype)
		setElementData(player, "ReleaseID", relid)
		setElementData(player, "jailFrom",jfrom)
		triggerClientEvent(player,"onClientPlayerJailed",player,jfrom)
		triggerEvent("onPlayerJailed",player,jfrom)
		setPedWeaponSlot(player, 0)
		toggleControl(player, "fire", false)
		toggleControl(player, "action", false)
		toggleControl(player, "next_weapon", false)
		toggleControl(player, "previous_weapon", false)
		toggleControl(player, "jump", false)
		if(jtype == 2 and player ~= jfrom) then
			if(reason == nil or reason == "" or reason == " ") then reason = "No reason" end
			outputChatBox("* "..getPlayerName(jfrom).." jailed "..getPlayerName(player).." for "..jtime.." seconds ("..reason..")", getRootElement(), 255, 0, 0)
			setElementPosition(player,1573.71, -1641.84, 73.46)
			local cxdata = exports.SAUGecho:getPlayerAccountData(player,"adminjailed")
			if cxdata == nil or cxdata == 0 or cxdata == false then
				cxdata = 0
			end
			exports.SAUGecho:setPlayerAccountData(player,"adminjailed",cxdata+1)
			local cxdata = exports.SAUGecho:getPlayerAccountData(player,"adminjailed")
			if cxdata == 1 then
				exports.SAUGucp:givePlayerAch(player,9)
			end
		end
		triggerClientEvent(player, "showJailTime", player, jtime)
		return true
	end
	return false
end
addEvent("ArrestP", true)
addEventHandler("ArrestP", getRootElement(), jailPlayer)

it's has bug

when player reconnect unjailed

Link to comment
18 hours ago, KillerX said:

in addition to Mr.Loki's information

you can use


executeSQLQuery

insted of


getAccountDatasetAccountData

if the player didn't log in

 

18 hours ago, Mr.Loki said:

When the player quits onPlayerQuit, check if they were in jail then set the jail data to their account setAccountData so when they log in again onPlayerLogin just get the jail data from their account getAccountData and jail them with the account data.

i tried on PlayQuit / Login but didn't fix

can i request u to help me, Please ?

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...