Jump to content

ممكن مساعدة فى سكرت jail


Recommended Posts

سلام عليكم jail

هذا مود jail حقى

المشكلة ان jail

لما يجيب 0 sec

ما يخرج من السجن

ممكن مساعدة

server

local prisoner = {} 
  
local positions =    
{ 
    {3930, -1737, 9.50}, 
    {3930, -1737, 9.50}, 
        {3930, -1737, 9.50}, 
    {3930, -1737, 9.50}, 
} 
  
function sendPlayerToPrison(player, jailTime) 
    if (not isElement(player)) then return end 
    local jailTime = jailTime / 1000 
    local x, y, z = getElementPosition(player) 
    if (isPedInVehicle(player)) then 
        removePedFromVehicle(player) 
    end 
    toggleControl(player, "fire", false) 
    prisoner[player] = {} 
    prisoner[player][1] = getZoneName(x, y, z, true) 
    prisoner[player][2] = jailTime 
    setTimer(triggerClientEvent, 500, 1, player, "CORprison.onPlayerEnterPrison", player, jailTime) 
        setTimer(triggerEvent, 1000, 1, "CIFpayjailfine.finejailmeAuto", player, player) 
    setElementPosition(player, unpack(positions[math.random(#positions)])) 
    setElementDimension(player, 0) 
    setElementInterior(player, 0) 
        local jails = getElementData(player, "jails") 
        setElementData(player, "jails", jails+1) 
    local function updateTheTime(player) 
        if (prisoner[player] and prisoner[player][2]) then 
            prisoner[player][2] = prisoner[player][2] - 1 
            if (prisoner[player][2] < 1) then 
                releasePlayerFromPrison(player) 
            end 
        end 
    end 
    prisoner[player][3] =  setTimer(updateTheTime, 1000, jailTime, player) 
end 
  
function isPlayerJailed(player) 
    if (player and isElement(player)) then 
        if (prisoner[player]) then  
            return true 
        else 
            return false 
        end 
    end 
end 
  
function saveTimeOnQuit() 
    local account = getPlayerAccount(source) 
    if (not account) then return end 
    if (prisoner[source] and prisoner[source][2] > 1) then 
        setAccountData(account, "CORprison.prisonTime", prisoner[source][2]) 
    end 
end 
addEventHandler("onPlayerQuit", root, saveTimeOnQuit, true, "high") 
  
function saveTimeOnQLogout(account) 
    if (prisoner[source] and prisoner[source][2] > 1) then 
        setAccountData(account, "CORprison.prisonTime", prisoner[source][2]) 
    end 
end 
addEventHandler("onPlayerLogout", root, saveTimeOnQLogout) 
  
function sendPlayerToJailOnStart() 
    for index, player in pairs(getElementsByType("player")) do 
        if (not isGuestAccount(getPlayerAccount(player))) then 
            local account = getPlayerAccount(player) 
            local prisontime = getAccountData(account, "CORprison.prisonTime") or 0 
            local zone = getAccountData(account, "CORprison.zone") 
            if (tonumber(prisontime) > 1) then 
                sendPlayerToPrison(player, prisontime * 1000) 
            end              
        end 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, sendPlayerToJailOnStart) 
  
function saveTimeOnResourceStop() 
    for index, player in pairs(getElementsByType("player")) do 
        if (not isGuestAccount(getPlayerAccount(player)) and prisoner[player] and prisoner[player][2] > 1) then 
            local account = getPlayerAccount(player) 
            setAccountData(account, "CORprison.zone", prisoner[player][1]) 
            setAccountData(account, "CORprison.prisonTime", prisoner[player][2]) 
        end 
    end 
end 
addEventHandler("onResourceStop", resourceRoot, saveTimeOnResourceStop) 
  
function onPlayerLogin() 
    local account = getPlayerAccount(source) 
    local prisontime = getAccountData(account, "CORprison.prisonTime") or 0 
    local w = getAccountData(account, "w") or 0 
    if (tonumber(prisontime) > 1) then 
        setTimer(sendPlayerToPrison, 1000, 1, source, prisontime * 1000) 
    return end 
    if (w >= 1) and (prisontime == 0) then 
        setTimer(sendPlayerToPrison, 1000, 1, source, w * 10000) 
    end 
end 
addEventHandler("onPlayerLogin", root, onPlayerLogin) 
  
function releasePlayerFromPrison(player) 
    if (not isElement(player)) then return end 
    if (prisoner[player]) then 
        if (prisoner[player][3]) then 
            if (isTimer(prisoner[player][3])) then 
                killTimer(prisoner[player][3]) 
            end 
        end 
        toggleControl(player, "fire", true) 
        fadeCamera(player, false, 0) 
        setTimer(fadeCamera, 800, 1, player, true) 
        exports.CILtexts:output("You have been released from prison", player, 0, 245, 0) 
        local zone = prisoner[player][1] 
        if (zone == "Unknown") then 
            setElementPosition(player, 403.719, -1538.365, 32.27) 
            zone = getAccountData(getPlayerAccount(player), "CORprison.zone") 
        end 
        if (zone == "Los Santos") then 
            setTimer(setElementPosition(player, 403.719, -1538.365, 32.27), 1000, 1) 
        elseif (zone == "San Fierro") then 
            setTimer(setElementPosition(player, -1631.78, 678.41, 7), 1000, 1) 
        elseif (zone == "Las Venturas") then 
            setTimer(setElementPosition(player, 2287.54, 2430.20, 10), 1000, 1) 
        end 
        setElementDimension(player, 0) 
        prisoner[player] = nil 
        setPlayerWantedLevel(player, 0) 
                setElementData(player, "w", 0) 
        setAccountData(getPlayerAccount(player), "CORprison.prisonTime", 0) 
                exports.CILhelp:modTextBar(player, "prisontime", "", 255, 255, 255, 255) 
        triggerClientEvent(player, "CORprison.onPlayerReleased", root) 
    end 
end 

client

local sx, sy = guiGetScreenSize() 
  
function onPlayerEnterPrison(time) 
    addEventHandler("onClientRender", root, drawPrisonText) 
    prisonTextActive = true 
    prisonTime = time or 0 
    local function decreasePrisonTime() 
        prisonTime = prisonTime - 1 
        if (prisonTime < 1) then 
            if (prisonTextActive) then removeEventHandler("onClientRender", root, drawPrisonText) end 
            prisonTextActive = false 
        end 
    end 
    decreaseTimer = setTimer(decreasePrisonTime, 1000, time) 
end 
addEvent("CORprison.onPlayerEnterPrison", true) 
addEventHandler("CORprison.onPlayerEnterPrison", root, onPlayerEnterPrison) 
  
function onPlayerReleased() 
    if (prisonTextActive) then removeEventHandler("onClientRender", root, drawPrisonText) end 
end 
addEvent("CORprison.onPlayerReleased", true) 
addEventHandler("CORprison.onPlayerReleased", root, onPlayerReleased) 
  
function drawPrisonText() 
    local color 
    if (prisonTime < 80) then 
        color = tocolor(255, 255, 255, 255) 
    elseif (prisonTime >= 80 and prisonTime <= 150) then 
        color = tocolor(255, 255, 255, 255) 
    elseif (prisonTime > 150) then 
        color = tocolor(255, 255, 255, 255) 
    end 
    exports.CILhelp:modTextBar("prisontime", prisonTime.." Seconds Remaining", 255, 255, 255) 
end 
  
function isPlayerJailed(player) 
    if (player and isElement(player)) then 
        if (prisoner[player]) then  
            return true 
        else 
            return false 
        end 
    end 
end 

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