fork(1) download
  1. local Keys = {
  2. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12. local GUI = {}
  13. ESX = nil
  14. local PlayerData = {}
  15. local CurrentAction = nil
  16. local CurrentActionMsg = ''
  17. local CurrentActionData = {}
  18. GUI.Time = 0
  19. local prison = Config.Prison
  20. local counter = 0
  21.  
  22.  
  23. Citizen.CreateThread(function()
  24. while ESX == nil do
  25. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  26. Citizen.Wait(0)
  27. end
  28. end)
  29.  
  30. RegisterNetEvent('esx:playerLoaded')
  31. AddEventHandler('esx:playerLoaded', function(xPlayer)
  32. PlayerData = xPlayer
  33. end)
  34.  
  35. RegisterNetEvent('esx:setJob')
  36. AddEventHandler('esx:setJob', function(job)
  37. PlayerData.job = job
  38. end)
  39.  
  40.  
  41.  
  42. function animsAction(animObj)
  43. Citizen.CreateThread(function()
  44. if not playAnim then
  45. local playerPed = GetPlayerPed(-1);
  46. if DoesEntityExist(playerPed) then -- Ckeck if ped exist
  47. dataAnim = animObj
  48.  
  49. -- Play Animation
  50. RequestAnimDict(dataAnim.lib)
  51. while not HasAnimDictLoaded(dataAnim.lib) do
  52. Citizen.Wait(0)
  53. end
  54. if HasAnimDictLoaded(dataAnim.lib) then
  55. local flag = 0
  56. if dataAnim.loop ~= nil and dataAnim.loop then
  57. flag = 1
  58. elseif dataAnim.move ~= nil and dataAnim.move then
  59. flag = 49
  60. end
  61.  
  62. TaskPlayAnim(playerPed, dataAnim.lib, dataAnim.anim, 8.0, -8.0, -1, flag, 0, 0, 0, 0)
  63. playAnimation = true
  64. end
  65.  
  66. -- Wait end annimation
  67. while true do
  68. Citizen.Wait(0)
  69. if not IsEntityPlayingAnim(playerPed, dataAnim.lib, dataAnim.anim, 3) then
  70. playAnim = false
  71. TriggerEvent('ft_animation:ClFinish')
  72. break
  73. end
  74. end
  75. end -- end ped exist
  76. end
  77. end)
  78.  
  79. end
  80.  
  81.  
  82.  
  83.  
  84. AddEventHandler('esx_prison:hasEnteredMarker', function(zone)
  85. if zone == 'EnterPrison' then
  86. CurrentAction = 'enter_prison'
  87. CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~r~emprisoner ~w~un ~b~individu~w~."
  88. CurrentActionData = {}
  89. end
  90. if zone == 'InfoPrison' then
  91. CurrentAction = 'info_prison'
  92. CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~b~voir le temps restant de ~w~votre ~r~peine~w~."
  93. CurrentActionData = {}
  94. end
  95. if zone == 'TravauxPrison' then
  96. CurrentAction = 'travaux_prison'
  97. CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~g~réduire ~w~votre ~r~peine~w~."
  98. CurrentActionData = {}
  99. end
  100. end)
  101.  
  102. AddEventHandler('esx_prison:hasExitedMarker', function(zone)
  103. ESX.UI.Menu.CloseAll()
  104. CurrentAction = nil
  105. end)
  106.  
  107. RegisterNetEvent('esx_prison:teleport_prisonner_c')
  108. AddEventHandler('esx_prison:teleport_prisonner_c', function()
  109. TeleportFadeEffect(GetPlayerPed(-1), prison)
  110. end)
  111.  
  112. RegisterNetEvent('esx_prison:repositionning_prisonner_c')
  113. AddEventHandler('esx_prison:repositionning_prisonner_c', function()
  114. VerifyPosition()
  115.  
  116. end)
  117.  
  118. RegisterNetEvent('esx_prison:change_player_ped')
  119. AddEventHandler('esx_prison:change_player_ped', function()
  120. ChangePlayerPed()
  121. end)
  122.  
  123. function ChangePlayerPed()
  124. ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
  125. if skin.sex == 0 then
  126. SetPedComponentVariation(GetPlayerPed(-1), 4, 3, 7, 0) --Jean
  127. SetPedComponentVariation(GetPlayerPed(-1), 6, 9, 0, 0) --Chaussure
  128. SetPedComponentVariation(GetPlayerPed(-1), 11, 3, 7, 0)--Veste
  129. ClearPedProp(GetPlayerPed(-1), 0) -- Helmet
  130. else
  131. SetPedComponentVariation(GetPlayerPed(-1), 4, 3, 15, 0) --Jean
  132. SetPedComponentVariation(GetPlayerPed(-1), 6, 4, 1, 0) --Chaussure
  133. SetPedComponentVariation(GetPlayerPed(-1), 11, 14, 6, 0)--Veste
  134. ClearPedProp(GetPlayerPed(-1), 0) -- Helmet
  135. end
  136. end)
  137. end
  138. function TeleportFadeEffect(entity,coords)
  139.  
  140. Citizen.CreateThread(function()
  141. ESX.Game.Teleport(entity, coords, function()
  142. end)
  143.  
  144. end)
  145.  
  146. end
  147.  
  148. function GetPeine()
  149. ESX.TriggerServerCallback('esx_prison:get_peine', function(cb)
  150.  
  151. if(cb == 0)then
  152. ESX.ShowNotification("Vous n'avez ~g~aucune peine~w~.")
  153. else
  154. ESX.ShowNotification("Vous devez encore ~r~purger "..cb.." min ~w~!")
  155. end
  156. end)
  157. end
  158.  
  159.  
  160. function ChanceToWinSomething()
  161. local random = math.random(1,100)
  162. local player = GetPlayerPed(-1)
  163. if(random==1)then
  164. local weapon_hash = GetHashKey("WEAPON_KNIFE")
  165. GiveWeaponToPed(player, weapon_hash, 1, false, false)
  166. end
  167. if(random>1 and random <27)then
  168. local random_money = math.random(1,5)
  169. TriggerServerEvent("esx_prison:send_money",random_money)
  170. end
  171. end
  172.  
  173. function GetPed() return GetPlayerPed(-1) end
  174.  
  175. function AttachEntityToPed(prop,bone_ID,x,y,z,RotX,RotY,RotZ)
  176. BoneID = GetPedBoneIndex(GetPed(), bone_ID)
  177. obj = CreateObject(GetHashKey(prop), 1729.73, 6403.90, 34.56, true, true, true)
  178. vX,vY,vZ = table.unpack(GetEntityCoords(GetPed()))
  179. xRot, yRot, zRot = table.unpack(GetEntityRotation(GetPed(),2))
  180. AttachEntityToEntity(obj, GetPed(), BoneID, x,y,z, RotX,RotY,RotZ, false, false, false, false, 2, true)
  181. return obj
  182. end
  183.  
  184. function VerifyPosition()
  185. local Ped = GetPlayerPed(-1)
  186. local coords = GetEntityCoords(Ped)
  187.  
  188. if(GetDistanceBetweenCoords(coords, 1723.90, 2535.55, 45.56, true)> 250) then
  189. TeleportFadeEffect(Ped, prison)
  190. ESX.ShowNotification("Votre peine n'est pas ~r~terminée ~w~!")
  191. end
  192. end
  193.  
  194.  
  195. function ReducePeine()
  196.  
  197.  
  198. while counter < 30 do
  199. local hammer = AttachEntityToPed('prop_tool_hammer',28422, 0,0,0, 0,0,0)
  200. animsAction({ lib = "amb@world_human_hammering@male@base", anim = "base" })
  201. counter = counter +1
  202. Citizen.Wait(1000)
  203. DeleteEntity(hammer)
  204. end
  205. if counter == 30 then
  206. ESX.ShowNotification("Vous avez ~g~réduit ~w~votre peine ! ")
  207. counter =0
  208. end
  209.  
  210. TriggerServerEvent("esx_prison:reduce_peine")
  211. ChanceToWinSomething()
  212.  
  213.  
  214. end
  215.  
  216. function OpenPrisonMenu()
  217. ESX.UI.Menu.Open(
  218. 'default', GetCurrentResourceName(), 'prison',
  219. {
  220. title = "Menu prison",
  221. align = 'top-left',
  222. elements = {
  223. {label = "Emprisonner 30 min", value = 'prison_30_min'},
  224. {label = "Emprisonner 1 heure", value = 'prison_1_heure'},
  225. {label = "Emprisonner 2 heures", value = 'prison_2_heure'},
  226. {label = "Emprisonner 4 heures", value = 'prison_4_heure'},
  227. {label = "Emprisonner 8 heures", value = 'prison_8_heure'}
  228. },
  229. },
  230. function(data, menu)
  231. menu.close()
  232. local player, distance = ESX.Game.GetClosestPlayer()
  233.  
  234. if distance ~= -1 and distance <= 3.0 then
  235.  
  236.  
  237. if data.current.value == 'prison_30_min' then
  238. ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb)
  239. if(cb==0)then
  240.  
  241. TriggerServerEvent('esx_prison:send_to_prison','30_min',GetPlayerServerId(player))
  242. else
  243. ESX.ShowNotification('Cette personne est déjà emprisonnée')
  244. end
  245. end ,GetPlayerServerId(player))
  246.  
  247. end
  248.  
  249.  
  250. if data.current.value == 'prison_1_heure' then
  251. ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb)
  252. if(cb==0)then
  253.  
  254. TriggerServerEvent('esx_prison:send_to_prison','1_heure',GetPlayerServerId(player))
  255. else
  256. ESX.ShowNotification('Cette personne est déjà emprisonnée')
  257. end
  258. end ,GetPlayerServerId(player))
  259. end
  260. if data.current.value == 'prison_2_heure' then
  261. ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb)
  262. if(cb==0)then
  263.  
  264. TriggerServerEvent('esx_prison:send_to_prison','2_heure',GetPlayerServerId(player))
  265. else
  266. ESX.ShowNotification('Cette personne est déjà emprisonnée')
  267. end
  268. end ,GetPlayerServerId(player))
  269.  
  270. end
  271. if data.current.value == 'prison_4_heure' then
  272. ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb)
  273. if(cb==0)then
  274.  
  275. TriggerServerEvent('esx_prison:send_to_prison','4_heure',GetPlayerServerId(player))
  276. else
  277. ESX.ShowNotification('Cette personne est déjà emprisonnée')
  278. end
  279. end ,GetPlayerServerId(player))
  280. end
  281.  
  282. if data.current.value == 'prison_8_heure' then
  283. ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb)
  284. if(cb==0)then
  285.  
  286. TriggerServerEvent('esx_prison:send_to_prison','8_heure',GetPlayerServerId(player))
  287. else
  288. ESX.ShowNotification('Cette personne est déjà emprisonnée')
  289. end
  290. end ,GetPlayerServerId(player))
  291. end
  292.  
  293. else
  294. ESX.ShowNotification("Il n'y a personne autour de vous...")
  295. end
  296.  
  297. CurrentAction = 'prison_menu'
  298. CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour ouvrir le menu'
  299. CurrentActionData = {}
  300.  
  301. end,
  302. function(data, menu)
  303. menu.close()
  304. end)
  305.  
  306. end
  307.  
  308.  
  309. -- Display markers
  310. Citizen.CreateThread(function()
  311. while true do
  312. Wait(0)
  313. local coords = GetEntityCoords(GetPlayerPed(-1))
  314.  
  315. for k,v in pairs(Config.Zones) do
  316. if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
  317. if PlayerData.job ~= nil and PlayerData.job.name == 'police'and v.Police then
  318. DrawMarker(Config.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0,
  319. Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g,
  320. Config.Color.b, 100, false, true, 2, false, false, false, false)
  321. end
  322. if PlayerData.job ~= nil and not v.Police then
  323. DrawMarker(Config.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0,
  324. Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g,
  325. Config.Color.b, 100, false, true, 2, false, false, false, false)
  326. end
  327.  
  328. end
  329. end
  330.  
  331. end
  332. end)
  333.  
  334. Citizen.CreateThread(function()
  335. while true do
  336. Wait(0)
  337.  
  338. local coords = GetEntityCoords(GetPlayerPed(-1))
  339. local isInMarker = false
  340. local currentZone = nil
  341.  
  342. for k,v in pairs(Config.Zones) do
  343. if PlayerData.job ~= nil and PlayerData.job.name == 'police'and v.Police then
  344. if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.Size.x) then
  345. isInMarker = true
  346. currentZone = k
  347. end
  348. else
  349. if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.Size.x) then
  350. isInMarker = true
  351. currentZone = k
  352. end
  353. end
  354. end
  355.  
  356. if isInMarker and not hasAlreadyEnteredMarker then
  357. hasAlreadyEnteredMarker = true
  358. lastZone = currentZone
  359. TriggerEvent('esx_prison:hasEnteredMarker', currentZone)
  360. end
  361.  
  362. if not isInMarker and hasAlreadyEnteredMarker then
  363. hasAlreadyEnteredMarker = false
  364. TriggerEvent('esx_prison:hasExitedMarker', lastZone)
  365. end
  366.  
  367. end
  368. end)
  369.  
  370.  
  371. -- Key Controls
  372. Citizen.CreateThread(function()
  373. while true do
  374. Citizen.Wait(0)
  375.  
  376. if (CurrentAction ~= nil )then
  377.  
  378.  
  379. SetTextComponentFormat('STRING')
  380. AddTextComponentString(CurrentActionMsg)
  381. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  382.  
  383. if IsControlJustReleased(0, Keys['E']) and PlayerData.job ~= nil then
  384.  
  385. if CurrentAction == 'enter_prison' then
  386. OpenPrisonMenu()
  387. end
  388. if CurrentAction == 'info_prison' then
  389. GetPeine()
  390. end
  391. if CurrentAction == 'travaux_prison' then
  392. ReducePeine()
  393. end
  394.  
  395.  
  396. CurrentAction = nil
  397.  
  398. end
  399. end
  400.  
  401. GUI.Time = GetGameTimer()
  402.  
  403. end
  404. end)
  405.  
Runtime error #stdin #stdout #stderr 0s 4564KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:19: attempt to index a nil value (global 'Config')
stack traceback:
	prog.lua:19: in main chunk
	[C]: in ?