local Keys = { ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } local GUI = {} ESX = nil local PlayerData = {} local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} GUI.Time = 0 local prison = Config.Prison local counter = 0 Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) PlayerData = xPlayer end) RegisterNetEvent('esx:setJob') AddEventHandler('esx:setJob', function(job) PlayerData.job = job end) function animsAction(animObj) Citizen.CreateThread(function() if not playAnim then local playerPed = GetPlayerPed(-1); if DoesEntityExist(playerPed) then -- Ckeck if ped exist dataAnim = animObj -- Play Animation RequestAnimDict(dataAnim.lib) while not HasAnimDictLoaded(dataAnim.lib) do Citizen.Wait(0) end if HasAnimDictLoaded(dataAnim.lib) then local flag = 0 if dataAnim.loop ~= nil and dataAnim.loop then flag = 1 elseif dataAnim.move ~= nil and dataAnim.move then flag = 49 end TaskPlayAnim(playerPed, dataAnim.lib, dataAnim.anim, 8.0, -8.0, -1, flag, 0, 0, 0, 0) playAnimation = true end -- Wait end annimation while true do Citizen.Wait(0) if not IsEntityPlayingAnim(playerPed, dataAnim.lib, dataAnim.anim, 3) then playAnim = false TriggerEvent('ft_animation:ClFinish') break end end end -- end ped exist end end) end AddEventHandler('esx_prison:hasEnteredMarker', function(zone) if zone == 'EnterPrison' then CurrentAction = 'enter_prison' CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~r~emprisoner ~w~un ~b~individu~w~." CurrentActionData = {} end if zone == 'InfoPrison' then CurrentAction = 'info_prison' CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~b~voir le temps restant de ~w~votre ~r~peine~w~." CurrentActionData = {} end if zone == 'TravauxPrison' then CurrentAction = 'travaux_prison' CurrentActionMsg = "Appuyez sur ~INPUT_CONTEXT~ pour ~g~réduire ~w~votre ~r~peine~w~." CurrentActionData = {} end end) AddEventHandler('esx_prison:hasExitedMarker', function(zone) ESX.UI.Menu.CloseAll() CurrentAction = nil end) RegisterNetEvent('esx_prison:teleport_prisonner_c') AddEventHandler('esx_prison:teleport_prisonner_c', function() TeleportFadeEffect(GetPlayerPed(-1), prison) end) RegisterNetEvent('esx_prison:repositionning_prisonner_c') AddEventHandler('esx_prison:repositionning_prisonner_c', function() VerifyPosition() end) RegisterNetEvent('esx_prison:change_player_ped') AddEventHandler('esx_prison:change_player_ped', function() ChangePlayerPed() end) function ChangePlayerPed() ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) if skin.sex == 0 then SetPedComponentVariation(GetPlayerPed(-1), 4, 3, 7, 0) --Jean SetPedComponentVariation(GetPlayerPed(-1), 6, 9, 0, 0) --Chaussure SetPedComponentVariation(GetPlayerPed(-1), 11, 3, 7, 0)--Veste ClearPedProp(GetPlayerPed(-1), 0) -- Helmet else SetPedComponentVariation(GetPlayerPed(-1), 4, 3, 15, 0) --Jean SetPedComponentVariation(GetPlayerPed(-1), 6, 4, 1, 0) --Chaussure SetPedComponentVariation(GetPlayerPed(-1), 11, 14, 6, 0)--Veste ClearPedProp(GetPlayerPed(-1), 0) -- Helmet end end) end function TeleportFadeEffect(entity,coords) Citizen.CreateThread(function() ESX.Game.Teleport(entity, coords, function() end) end) end function GetPeine() ESX.TriggerServerCallback('esx_prison:get_peine', function(cb) if(cb == 0)then ESX.ShowNotification("Vous n'avez ~g~aucune peine~w~.") else ESX.ShowNotification("Vous devez encore ~r~purger "..cb.." min ~w~!") end end) end function ChanceToWinSomething() local random = math.random(1,100) local player = GetPlayerPed(-1) if(random==1)then local weapon_hash = GetHashKey("WEAPON_KNIFE") GiveWeaponToPed(player, weapon_hash, 1, false, false) end if(random>1 and random <27)then local random_money = math.random(1,5) TriggerServerEvent("esx_prison:send_money",random_money) end end function GetPed() return GetPlayerPed(-1) end function AttachEntityToPed(prop,bone_ID,x,y,z,RotX,RotY,RotZ) BoneID = GetPedBoneIndex(GetPed(), bone_ID) obj = CreateObject(GetHashKey(prop), 1729.73, 6403.90, 34.56, true, true, true) vX,vY,vZ = table.unpack(GetEntityCoords(GetPed())) xRot, yRot, zRot = table.unpack(GetEntityRotation(GetPed(),2)) AttachEntityToEntity(obj, GetPed(), BoneID, x,y,z, RotX,RotY,RotZ, false, false, false, false, 2, true) return obj end function VerifyPosition() local Ped = GetPlayerPed(-1) local coords = GetEntityCoords(Ped) if(GetDistanceBetweenCoords(coords, 1723.90, 2535.55, 45.56, true)> 250) then TeleportFadeEffect(Ped, prison) ESX.ShowNotification("Votre peine n'est pas ~r~terminée ~w~!") end end function ReducePeine() while counter < 30 do local hammer = AttachEntityToPed('prop_tool_hammer',28422, 0,0,0, 0,0,0) animsAction({ lib = "amb@world_human_hammering@male@base", anim = "base" }) counter = counter +1 Citizen.Wait(1000) DeleteEntity(hammer) end if counter == 30 then ESX.ShowNotification("Vous avez ~g~réduit ~w~votre peine ! ") counter =0 end TriggerServerEvent("esx_prison:reduce_peine") ChanceToWinSomething() end function OpenPrisonMenu() ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'prison', { title = "Menu prison", align = 'top-left', elements = { {label = "Emprisonner 30 min", value = 'prison_30_min'}, {label = "Emprisonner 1 heure", value = 'prison_1_heure'}, {label = "Emprisonner 2 heures", value = 'prison_2_heure'}, {label = "Emprisonner 4 heures", value = 'prison_4_heure'}, {label = "Emprisonner 8 heures", value = 'prison_8_heure'} }, }, function(data, menu) menu.close() local player, distance = ESX.Game.GetClosestPlayer() if distance ~= -1 and distance <= 3.0 then if data.current.value == 'prison_30_min' then ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb) if(cb==0)then TriggerServerEvent('esx_prison:send_to_prison','30_min',GetPlayerServerId(player)) else ESX.ShowNotification('Cette personne est déjà emprisonnée') end end ,GetPlayerServerId(player)) end if data.current.value == 'prison_1_heure' then ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb) if(cb==0)then TriggerServerEvent('esx_prison:send_to_prison','1_heure',GetPlayerServerId(player)) else ESX.ShowNotification('Cette personne est déjà emprisonnée') end end ,GetPlayerServerId(player)) end if data.current.value == 'prison_2_heure' then ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb) if(cb==0)then TriggerServerEvent('esx_prison:send_to_prison','2_heure',GetPlayerServerId(player)) else ESX.ShowNotification('Cette personne est déjà emprisonnée') end end ,GetPlayerServerId(player)) end if data.current.value == 'prison_4_heure' then ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb) if(cb==0)then TriggerServerEvent('esx_prison:send_to_prison','4_heure',GetPlayerServerId(player)) else ESX.ShowNotification('Cette personne est déjà emprisonnée') end end ,GetPlayerServerId(player)) end if data.current.value == 'prison_8_heure' then ESX.TriggerServerCallback('esx_prison:is_in_prison', function(cb) if(cb==0)then TriggerServerEvent('esx_prison:send_to_prison','8_heure',GetPlayerServerId(player)) else ESX.ShowNotification('Cette personne est déjà emprisonnée') end end ,GetPlayerServerId(player)) end else ESX.ShowNotification("Il n'y a personne autour de vous...") end CurrentAction = 'prison_menu' CurrentActionMsg = 'Appuyez sur ~INPUT_CONTEXT~ pour ouvrir le menu' CurrentActionData = {} end, function(data, menu) menu.close() end) end -- Display markers Citizen.CreateThread(function() while true do Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) for k,v in pairs(Config.Zones) do if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then if PlayerData.job ~= nil and PlayerData.job.name == 'police'and v.Police then DrawMarker(Config.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) end if PlayerData.job ~= nil and not v.Police then DrawMarker(Config.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false) end end end end end) Citizen.CreateThread(function() while true do Wait(0) local coords = GetEntityCoords(GetPlayerPed(-1)) local isInMarker = false local currentZone = nil for k,v in pairs(Config.Zones) do if PlayerData.job ~= nil and PlayerData.job.name == 'police'and v.Police then if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.Size.x) then isInMarker = true currentZone = k end else if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.Size.x) then isInMarker = true currentZone = k end end end if isInMarker and not hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = true lastZone = currentZone TriggerEvent('esx_prison:hasEnteredMarker', currentZone) end if not isInMarker and hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = false TriggerEvent('esx_prison:hasExitedMarker', lastZone) end end end) -- Key Controls Citizen.CreateThread(function() while true do Citizen.Wait(0) if (CurrentAction ~= nil )then SetTextComponentFormat('STRING') AddTextComponentString(CurrentActionMsg) DisplayHelpTextFromStringLabel(0, 0, 1, -1) if IsControlJustReleased(0, Keys['E']) and PlayerData.job ~= nil then if CurrentAction == 'enter_prison' then OpenPrisonMenu() end if CurrentAction == 'info_prison' then GetPeine() end if CurrentAction == 'travaux_prison' then ReducePeine() end CurrentAction = nil end end GUI.Time = GetGameTimer() end end)