diff --git a/ylle_beds/__resource.lua b/ylle_beds/__resource.lua new file mode 100644 index 0000000..9b0616a --- /dev/null +++ b/ylle_beds/__resource.lua @@ -0,0 +1,5 @@ +client_scripts { + 'config.lua', + 'client.lua', + +} \ No newline at end of file diff --git a/ylle_beds/client.lua b/ylle_beds/client.lua new file mode 100644 index 0000000..4b133f9 --- /dev/null +++ b/ylle_beds/client.lua @@ -0,0 +1,78 @@ +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 +} + +ESX = nil + +local InAction = false + +Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end +end) + +Citizen.CreateThread(function() + while true do + + Citizen.Wait(5) + + for i=1, #Config.BedList do + local bedID = Config.BedList[i] + local distance = GetDistanceBetweenCoords(GetEntityCoords(PlayerPedId()), bedID.objCoords.x, bedID.objCoords.y, bedID.objCoords.z, true) + + if distance < Config.MaxDistance and InAction == false then + + ESX.Game.Utils.DrawText3D({ x = bedID.objCoords.x, y = bedID.objCoords.y, z = bedID.objCoords.z + 1 }, bedID.text, 0.6) + + if IsControlJustReleased(0, Keys['E']) then + bedActive(bedID.objCoords.x, bedID.objCoords.y, bedID.objCoords.z, bedID.heading, bedID) + end + end + end + end +end) + +function bedActive(x, y, z, heading) + + SetEntityCoords(GetPlayerPed(-1), x, y, z + 0.3) + RequestAnimDict('anim@gangops@morgue@table@') + while not HasAnimDictLoaded('anim@gangops@morgue@table@') do + Citizen.Wait(0) + end + TaskPlayAnim(GetPlayerPed(-1), 'anim@gangops@morgue@table@' , 'ko_front' ,8.0, -8.0, -1, 1, 0, false, false, false ) + SetEntityHeading(GetPlayerPed(-1), heading + 180.0) + InAction = true + + + Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + + if InAction == true then + headsUp('Tryck ~INPUT_VEH_DUCK~ för att ställa dig upp') + if IsControlJustReleased(0, Keys['X']) then + ClearPedTasks(GetPlayerPed(-1)) + FreezeEntityPosition(GetPlayerPed(-1), false) + SetEntityCoords(GetPlayerPed(-1), x, y + 0.5, z) + InAction = false + end + end + end + end) +end + +function headsUp(text) + SetTextComponentFormat('STRING') + AddTextComponentString(text) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end \ No newline at end of file diff --git a/ylle_beds/config.lua b/ylle_beds/config.lua new file mode 100644 index 0000000..ed6ddd9 --- /dev/null +++ b/ylle_beds/config.lua @@ -0,0 +1,95 @@ +Config = {} +Config.MaxDistance = 1.5 + +Config.BedList = { + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -451.3828, y = -356.163, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -448.53, y = -356.163, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -448.5128, y = -362.93, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -451.8128, y = -362.93, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -451.39, y = -345.8, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -448.3, y = -345.81, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -448.55, y = -353.4, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -451.76, y = -353.47, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -451.98, y = -336.24, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -448.99, y = -336.21, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -448.69, y = -343.1, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 180.0, + objCoords = {x = -451.68, y = -343.1, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 0.0, + objCoords = {x = -453.96, y = -373.5, z = -186.79572}, + }, + + { + text = '[E] Lägg dig i sängen', + heading = 92.0, + objCoords = {x = -470.33, y = -367.96, z = -186.79572}, + }, + + { + text = '[E] Lägg dig på operationsbordet', + heading = 272.85, + objCoords = {x = -465.5, y = -373.63, z = -186.79572}, + } +} \ No newline at end of file