From 49dc255546ac67c2037dd6480d7fd8ce87c9ae43 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 16 Sep 2018 10:59:33 +0200 Subject: [PATCH] Minor improvements --- client/main.lua | 93 ++++++++++++++++++++++++------------------------- locales/sv.lua | 4 +-- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/client/main.lua b/client/main.lua index 0cb1debd..dbb79b32 100644 --- a/client/main.lua +++ b/client/main.lua @@ -21,8 +21,8 @@ AddEventHandler('esx_basicneeds:healPlayer', function() TriggerEvent('esx_status:set', 'thirst', 1000000) -- restore hp - local sourcePed = GetPlayerPed(-1) - SetEntityHealth(sourcePed, GetEntityMaxHealth(sourcePed)) + local playerPed = PlayerPedId() + SetEntityHealth(playerPed, GetEntityMaxHealth(playerPed)) end) AddEventHandler('esx:onPlayerDeath', function() @@ -39,34 +39,28 @@ end) AddEventHandler('esx_status:loaded', function(status) - TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', - function(status) - return true - end, function(status) - status.remove(100) - end - ) + TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status) + return true + end, function(status) + status.remove(100) + end) - TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', - function(status) - return true - end, function(status) - status.remove(75) - end - ) + TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status) + return true + end, function(status) + status.remove(75) + end) Citizen.CreateThread(function() - while true do Citizen.Wait(1000) - local playerPed = GetPlayerPed(-1) + local playerPed = PlayerPedId() local prevHealth = GetEntityHealth(playerPed) local health = prevHealth TriggerEvent('esx_status:getStatus', 'hunger', function(status) if status.val == 0 then - if prevHealth <= 150 then health = health - 5 else @@ -77,7 +71,6 @@ AddEventHandler('esx_status:loaded', function(status) TriggerEvent('esx_status:getStatus', 'thirst', function(status) if status.val == 0 then - if prevHealth <= 150 then health = health - 5 else @@ -87,7 +80,7 @@ AddEventHandler('esx_status:loaded', function(status) end) if health ~= prevHealth then - SetEntityHealth(playerPed, health) + SetEntityHealth(playerPed, health) end end end) @@ -100,45 +93,51 @@ end) RegisterNetEvent('esx_basicneeds:onEat') AddEventHandler('esx_basicneeds:onEat', function(prop_name) if not IsAnimated then - local prop_name = prop_name or 'prop_cs_burger_01' + prop_name = prop_name or 'prop_cs_burger_01' IsAnimated = true - local playerPed = GetPlayerPed(-1) + Citizen.CreateThread(function() + local playerPed = PlayerPedId() local x,y,z = table.unpack(GetEntityCoords(playerPed)) - prop = CreateObject(GetHashKey(prop_name), x, y, z+0.2, true, true, true) - AttachEntityToEntity(prop, playerPed, GetPedBoneIndex(playerPed, 18905), 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) - RequestAnimDict('mp_player_inteat@burger') - while not HasAnimDictLoaded('mp_player_inteat@burger') do - Citizen.Wait(10) - end - TaskPlayAnim(playerPed, 'mp_player_inteat@burger', 'mp_player_int_eat_burger_fp', 8.0, -8, -1, 49, 0, 0, 0, 0) - Citizen.Wait(3000) - IsAnimated = false - ClearPedSecondaryTask(playerPed) - DeleteObject(prop) + local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true) + local boneIndex = GetPedBoneIndex(playerPed, 18905) + AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) + + ESX.Streaming.RequestAnimDict('mp_player_inteat@burger', function() + TaskPlayAnim(playerPed, 'mp_player_inteat@burger', 'mp_player_int_eat_burger_fp', 8.0, -8, -1, 49, 0, 0, 0, 0) + + Citizen.Wait(3000) + IsAnimated = false + ClearPedSecondaryTask(playerPed) + DeleteObject(prop) + end) end) + end end) RegisterNetEvent('esx_basicneeds:onDrink') AddEventHandler('esx_basicneeds:onDrink', function(prop_name) if not IsAnimated then - local prop_name = prop_name or 'prop_ld_flow_bottle' + prop_name = prop_name or 'prop_ld_flow_bottle' IsAnimated = true - local playerPed = GetPlayerPed(-1) + Citizen.CreateThread(function() + local playerPed = PlayerPedId() local x,y,z = table.unpack(GetEntityCoords(playerPed)) - prop = CreateObject(GetHashKey(prop_name), x, y, z+0.2, true, true, true) - AttachEntityToEntity(prop, playerPed, GetPedBoneIndex(playerPed, 18905), 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) - RequestAnimDict('mp_player_intdrink') - while not HasAnimDictLoaded('mp_player_intdrink') do - Citizen.Wait(10) - end - TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 1.0, -1.0, 2000, 0, 1, true, true, true) - Citizen.Wait(3000) - IsAnimated = false - ClearPedSecondaryTask(playerPed) - DeleteObject(prop) + local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true) + local boneIndex = GetPedBoneIndex(playerPed, 18905) + AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true) + + ESX.Streaming.RequestAnimDict('mp_player_intdrink', function() + TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 1.0, -1.0, 2000, 0, 1, true, true, true) + + Citizen.Wait(3000) + IsAnimated = false + ClearPedSecondaryTask(playerPed) + DeleteObject(prop) + end) end) + end end) \ No newline at end of file diff --git a/locales/sv.lua b/locales/sv.lua index 29c4f001..b0f9d316 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -1,4 +1,4 @@ Locales['sv'] = { - ['used_bread'] = 'du käkade upp ~y~1x~s~ ~b~bröd~s~', - ['used_water'] = 'du drack ~y~1x~s~ ~b~vatten~s~', + ['used_bread'] = 'du käkade upp en bit ~b~bröd~s~', + ['used_water'] = 'du drack upp en ~b~vattenflaska~s~', } \ No newline at end of file