Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- JAIL SCRIPT for the GTA 5 multiplayer platform FiveM/FiveReborn.
- -- Instructions: (1) save below scripts individually for each file: __resource.lua, clientJailer.lua, serverJailer.lua, chat_client.lua; (2) place the first 3 files in a folder "Jail" in the "resources" subfolder of your FiveM server then edit your server's "citmp-server.yml" file to add "- Jail" to the list of resources under "AutoStartResources:". (3) find your server's default chat_client.lua and replace with this version to enable the jail commands -- see below for the jail commands available in FiveM chat, executed by placing an asterisk before the command name (*jail, *unjail, etc)
- -- keywords: prison, jail, fivem, fivereborn, albo1125
- -- __resource.lua
- client_script "clientJailer.lua"
- server_script {
- "serverJailer.lua"
- }
- -- clientJailer.lua
- local cJ = false
- local eJE = false
- RegisterNetEvent("JP")
- AddEventHandler("JP", function(jT)
- if cJ == true then
- return
- end
- local pP = GetPlayerPed(-1)
- if DoesEntityExist(pP) then
- Citizen.CreateThread(function()
- local playerOldLoc = GetEntityCoords(pP, true)
- SetEntityCoords(pP, 1677.233, 2658.618, 45.216)
- cJ = true
- eJE = false
- while jT > 0 and not eJE do
- pP = GetPlayerPed(-1)
- RemoveAllPedWeapons(pP, true)
- SetEntityInvincible(pP, true)
- if IsPedInAnyVehicle(pP, false) then
- ClearPedTasksImmediately(pP)
- end
- if jT % 30 == 0 then
- TriggerEvent('chatMessage', 'SYSTEM', { 0, 0, 0 }, jT .." more seconds until release.")
- end
- Citizen.Wait(500)
- local pL = GetEntityCoords(pP, true)
- local D = Vdist(1677.233, 2658.618, 45.216, pL['x'], pL['y'], pL['z'])
- if D > 90 then
- SetEntityCoords(pP, 1677.233, 2658.618, 45.216)
- if D > 100 then
- jT = jT + 60
- if jT > 1500 then
- jT = 1500
- end
- TriggerEvent('chatMessage', 'JUDGE', { 0, 0, 0 }, "Your jail time was extended for an unlawful escape attempt.")
- end
- end
- jT = jT - 0.5
- end
- TriggerServerEvent('chatMessageEntered', "SYSTEM", { 0, 0, 0 }, GetPlayerName(PlayerId()) .." was released from jail.")
- SetEntityCoords(pP, 1855.807, 2601.949, 45.323)
- cJ = false
- SetEntityInvincible(pP, false)
- end)
- end
- end)
- RegisterNetEvent("UnJP")
- AddEventHandler("UnJP", function()
- eJE = true
- end)
- -- serverJailer.lua
- local jailPassword = "jcrp" --change this password to your liking and don't share it with the criminals ;-)
- -----------------------------
- RegisterServerEvent("chatCommandEntered")
- AddEventHandler('chatCommandEntered', function(fullcm)
- cm = stringsplit(fullcm, " ")
- if(cm[1] == "*jailme") then
- local jT = 180
- if tablelength(cm) > 1 then
- if cm[2] ~= nil then
- jT = tonumber(cm[2])
- end
- end
- if jT > 1000 then
- jT = 1000
- end
- print("Jailing ".. GetPlayerName(source) .. " for ".. jT .." secs")
- TriggerClientEvent("JP", source, jT)
- TriggerClientEvent('chatMessage', -1, 'JUDGE', { 0, 0, 0 }, GetPlayerName(source) ..' jailed for '.. jT ..' secs')
- elseif cm[1] == "*unjail" then
- if tablelength(cm) > 2 then
- if cm[2] == jailPassword then
- local tPID = tonumber(cm[3])
- print("Unjailing ".. GetPlayerName(tPID).. " - cm entered by ".. GetPlayerName(source))
- TriggerClientEvent("UnJP", tPID)
- else
- print("Incorrect jailPassword entered by ".. GetPlayerName(source))
- end
- end
- elseif cm[1] == "*jail" then
- if tablelength(cm) > 2 then
- if cm[2] == jailPassword then
- local tPID = tonumber(cm[3])
- local jT = 180
- if tablelength(cm) > 3 then
- if cm[4] ~= nil then
- jT = tonumber(cm[4])
- end
- end
- if jT > 1000 then
- jT = 1000
- end
- print("Jailing ".. GetPlayerName(tPID).. " for ".. jT .." secs - cm entered by ".. GetPlayerName(source))
- TriggerClientEvent("JP", tPID, jT)
- TriggerClientEvent('chatMessage', -1, 'JUDGE', { 0, 0, 0 }, GetPlayerName(tPID) ..' jailed for '.. jT ..' secs')
- else
- print("Incorrect jailPassword entered by ".. GetPlayerName(source))
- end
- end
- end
- end)
- print('Jailer by Albo1125 (LUA, FiveReborn). Commands to type in chat (T):')
- print('/jailme SECS - Jails yourself, if SECS not given defaults to 180.')
- print('/unjail PSWD PLAYERID - Unjails the player with PLAYERID (hold up arrow ingame to see) if PSWD matches specified jail password.')
- print('/jail PSWD PLAYERID SECS - Jails the player with PLAYERID (hold up arrow ingame to see) if PSWD matches specified jail password. If SECS not given defaults to 180')
- function stringsplit(self, delimiter)
- local a = self:Split(delimiter)
- local t = {}
- for i = 0, #a - 1 do
- table.insert(t, a[i])
- end
- return t
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- -- chat_client.lua (need to replace the default FiveM chat_client.lua)
- local chatInputActive = false
- local chatInputActivating = false
- RegisterNetEvent('chatMessage')
- AddEventHandler('chatMessage', function(name, color, message)
- SendNUIMessage({
- name = name,
- color = color,
- message = message
- })
- end)
- RegisterNUICallback('chatResult', function(data, cb)
- chatInputActive = false
- SetNuiFocus(false)
- if data.message then
- local id = PlayerId()
- --local r, g, b = GetPlayerRgbColour(id, _i, _i, _i)
- local r, g, b = 0, 0x99, 255
- if(string.sub(data.message, 1, 1) == "*" and string.len(data.message) >= 2) then
- TriggerServerEvent('chatCommandEntered', data.message)
- else
- TriggerServerEvent('chatMessageEntered', GetPlayerName(id), { r, g, b }, data.message)
- end
- end
- cb('ok')
- end)
- Citizen.CreateThread(function()
- SetTextChatEnabled(false)
- while true do
- Wait(0)
- if not chatInputActive then
- if IsControlPressed(0, 245) --[[ INPUT_MP_TEXT_CHAT_ALL ]] then
- chatInputActive = true
- chatInputActivating = true
- SendNUIMessage({
- meta = 'openChatBox'
- })
- end
- end
- if chatInputActivating then
- if not IsControlPressed(0, 245) then
- SetNuiFocus(true)
- chatInputActivating = false
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement