Advertisement
Guest User

JAIL SCRIPT for the GTA 5 multiplayer (FiveM/FiveReborn)

a guest
Mar 30th, 2017
4,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.34 KB | None | 0 0
  1. -- JAIL SCRIPT for the GTA 5 multiplayer platform FiveM/FiveReborn.
  2. -- 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)
  3. -- keywords: prison, jail, fivem, fivereborn, albo1125
  4.  
  5. -- __resource.lua
  6. client_script "clientJailer.lua"
  7. server_script {
  8.     "serverJailer.lua"
  9. }
  10.  
  11.  
  12.  
  13.  
  14. -- clientJailer.lua
  15. local cJ = false
  16. local eJE = false
  17.  
  18. RegisterNetEvent("JP")
  19. AddEventHandler("JP", function(jT)
  20.     if cJ == true then
  21.         return
  22.     end
  23.     local pP = GetPlayerPed(-1)
  24.     if DoesEntityExist(pP) then
  25.        
  26.         Citizen.CreateThread(function()
  27.             local playerOldLoc = GetEntityCoords(pP, true)
  28.             SetEntityCoords(pP, 1677.233, 2658.618, 45.216)
  29.             cJ = true
  30.             eJE = false
  31.             while jT > 0 and not eJE do
  32.                 pP = GetPlayerPed(-1)
  33.                 RemoveAllPedWeapons(pP, true)
  34.                 SetEntityInvincible(pP, true)
  35.                 if IsPedInAnyVehicle(pP, false) then
  36.                     ClearPedTasksImmediately(pP)
  37.                 end
  38.                 if jT % 30 == 0 then
  39.                     TriggerEvent('chatMessage', 'SYSTEM', { 0, 0, 0 }, jT .." more seconds until release.")
  40.                 end
  41.                 Citizen.Wait(500)
  42.                 local pL = GetEntityCoords(pP, true)
  43.                 local D = Vdist(1677.233, 2658.618, 45.216, pL['x'], pL['y'], pL['z'])
  44.                 if D > 90 then
  45.                     SetEntityCoords(pP, 1677.233, 2658.618, 45.216)
  46.                     if D > 100 then
  47.                         jT = jT + 60
  48.                         if jT > 1500 then
  49.                             jT = 1500
  50.                         end
  51.                         TriggerEvent('chatMessage', 'JUDGE', { 0, 0, 0 }, "Your jail time was extended for an unlawful escape attempt.")
  52.                     end
  53.                 end
  54.                 jT = jT - 0.5
  55.             end
  56.             TriggerServerEvent('chatMessageEntered', "SYSTEM", { 0, 0, 0 }, GetPlayerName(PlayerId()) .." was released from jail.")
  57.             SetEntityCoords(pP, 1855.807, 2601.949, 45.323)
  58.             cJ = false
  59.             SetEntityInvincible(pP, false)
  60.         end)
  61.     end
  62. end)
  63.  
  64. RegisterNetEvent("UnJP")
  65. AddEventHandler("UnJP", function()
  66.     eJE = true
  67. end)
  68.  
  69.  
  70.  
  71. -- serverJailer.lua
  72. local jailPassword = "jcrp" --change this password to your liking and don't share it with the criminals ;-)
  73.  
  74. -----------------------------
  75.  
  76. RegisterServerEvent("chatCommandEntered")
  77. AddEventHandler('chatCommandEntered', function(fullcm)
  78.     cm = stringsplit(fullcm, " ")
  79.  
  80.     if(cm[1] == "*jailme") then
  81.         local jT = 180
  82.         if tablelength(cm) > 1 then
  83.             if cm[2] ~= nil then
  84.                 jT = tonumber(cm[2])               
  85.             end
  86.         end
  87.         if jT > 1000 then
  88.             jT = 1000
  89.         end
  90.        
  91.         print("Jailing ".. GetPlayerName(source) .. " for ".. jT .." secs")
  92.         TriggerClientEvent("JP", source, jT)
  93.         TriggerClientEvent('chatMessage', -1, 'JUDGE', { 0, 0, 0 }, GetPlayerName(source) ..' jailed for '.. jT ..' secs')
  94.     elseif cm[1] == "*unjail" then
  95.         if tablelength(cm) > 2 then
  96.             if cm[2] == jailPassword then
  97.                 local tPID = tonumber(cm[3])
  98.                 print("Unjailing ".. GetPlayerName(tPID).. " - cm entered by ".. GetPlayerName(source))
  99.                 TriggerClientEvent("UnJP", tPID)
  100.             else
  101.                 print("Incorrect jailPassword entered by ".. GetPlayerName(source))
  102.             end
  103.         end
  104.     elseif cm[1] == "*jail" then
  105.         if tablelength(cm) > 2 then
  106.             if cm[2] == jailPassword then
  107.                 local tPID = tonumber(cm[3])
  108.                 local jT = 180
  109.                 if tablelength(cm) > 3 then
  110.                     if cm[4] ~= nil then
  111.                         jT = tonumber(cm[4])               
  112.                     end
  113.                 end
  114.                 if jT > 1000 then
  115.                     jT = 1000
  116.                 end
  117.                 print("Jailing ".. GetPlayerName(tPID).. " for ".. jT .." secs - cm entered by ".. GetPlayerName(source))
  118.                 TriggerClientEvent("JP", tPID, jT)
  119.                 TriggerClientEvent('chatMessage', -1, 'JUDGE', { 0, 0, 0 }, GetPlayerName(tPID) ..' jailed for '.. jT ..' secs')
  120.             else
  121.                 print("Incorrect jailPassword entered by ".. GetPlayerName(source))
  122.             end
  123.         end
  124.     end
  125. end)
  126.  
  127. print('Jailer by Albo1125 (LUA, FiveReborn). Commands to type in chat (T):')
  128. print('/jailme SECS - Jails yourself, if SECS not given defaults to 180.')
  129. print('/unjail PSWD PLAYERID - Unjails the player with PLAYERID (hold up arrow ingame to see) if PSWD matches specified jail password.')
  130. 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')
  131. function stringsplit(self, delimiter)
  132.   local a = self:Split(delimiter)
  133.   local t = {}
  134.  
  135.   for i = 0, #a - 1 do
  136.      table.insert(t, a[i])
  137.   end
  138.  
  139.   return t
  140. end
  141.  
  142. function tablelength(T)
  143.   local count = 0
  144.   for _ in pairs(T) do count = count + 1 end
  145.   return count
  146. end
  147.  
  148.  
  149. -- chat_client.lua (need to replace the default FiveM chat_client.lua)
  150. local chatInputActive = false
  151. local chatInputActivating = false
  152.  
  153. RegisterNetEvent('chatMessage')
  154.  
  155. AddEventHandler('chatMessage', function(name, color, message)
  156.     SendNUIMessage({
  157.         name = name,
  158.         color = color,
  159.         message = message
  160.     })
  161. end)
  162.  
  163. RegisterNUICallback('chatResult', function(data, cb)
  164.     chatInputActive = false
  165.  
  166.     SetNuiFocus(false)
  167.  
  168.     if data.message then
  169.         local id = PlayerId()
  170.  
  171.         --local r, g, b = GetPlayerRgbColour(id, _i, _i, _i)
  172.         local r, g, b = 0, 0x99, 255
  173.  
  174.         if(string.sub(data.message, 1, 1) == "*" and string.len(data.message) >= 2) then
  175.             TriggerServerEvent('chatCommandEntered', data.message)
  176.         else       
  177.             TriggerServerEvent('chatMessageEntered', GetPlayerName(id), { r, g, b }, data.message)
  178.         end
  179.     end
  180.  
  181.     cb('ok')
  182. end)
  183.  
  184. Citizen.CreateThread(function()
  185.     SetTextChatEnabled(false)
  186.  
  187.     while true do
  188.         Wait(0)
  189.  
  190.         if not chatInputActive then
  191.             if IsControlPressed(0, 245) --[[ INPUT_MP_TEXT_CHAT_ALL ]] then
  192.                 chatInputActive = true
  193.                 chatInputActivating = true
  194.  
  195.                 SendNUIMessage({
  196.                     meta = 'openChatBox'
  197.                 })
  198.             end
  199.         end
  200.  
  201.         if chatInputActivating then
  202.             if not IsControlPressed(0, 245) then
  203.                 SetNuiFocus(true)
  204.  
  205.                 chatInputActivating = false
  206.             end
  207.         end
  208.     end
  209. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement