diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua b/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua index f3c9cffb1..1bea099aa 100644 --- a/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_basicneeds/client/main.lua @@ -1,11 +1,6 @@ -ESX = nil local IsDead = false local IsAnimated = false -Citizen.CreateThread(function() - ESX = exports["es_extended"]:getSharedObject() -end) - AddEventHandler('esx_basicneeds:resetStatus', function() TriggerEvent('esx_status:set', 'hunger', 500000) TriggerEvent('esx_status:set', 'thirst', 500000) @@ -26,7 +21,7 @@ AddEventHandler('esx:onPlayerDeath', function() IsDead = true end) -AddEventHandler('esx:onPlayerSpawn', function(spawn) +AddEventHandler('esx:onPlayerSpawn', function() if IsDead then TriggerEvent('esx_basicneeds:resetStatus') end @@ -34,55 +29,44 @@ AddEventHandler('esx:onPlayerSpawn', function(spawn) IsDead = false end) -AddEventHandler('esx_status:loaded', function(status) - - TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status) +AddEventHandler('esx_status:loaded', function() + TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function() return Config.Visible end, function(status) status.remove(100) end) - TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status) + TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function() return Config.Visible end, function(status) status.remove(75) end) +end) - Citizen.CreateThread(function() - while true do - Citizen.Wait(1000) - - 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 - health = health - 1 - end - end - end) - - TriggerEvent('esx_status:getStatus', 'thirst', function(status) - if status.val == 0 then - if prevHealth <= 150 then - health = health - 5 - else - health = health - 1 - end - end - end) - - if health ~= prevHealth then - SetEntityHealth(playerPed, health) +AddEventHandler('esx_status:onTick', function(data) + local playerPed = PlayerPedId() + local prevHealth = GetEntityHealth(playerPed) + local health = prevHealth + + for _, v in pairs(data) do + if v.name == 'hunger' and v.percent == 0 then + if prevHealth <= 150 then + health = health - 5 + else + health = health - 1 + end + elseif v.name == 'thirst' and v.percent == 0 then + if prevHealth <= 150 then + health = health - 5 + else + health = health - 1 end end - end) + end + + if health ~= prevHealth then SetEntityHealth(playerPed, health) end end) AddEventHandler('esx_basicneeds:isEating', function(cb) cb(IsAnimated) -end) +end) \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/config.lua b/server-data/resources/[esx_addons]/esx_basicneeds/config.lua index 7fb6e3a44..9c86897f6 100644 --- a/server-data/resources/[esx_addons]/esx_basicneeds/config.lua +++ b/server-data/resources/[esx_addons]/esx_basicneeds/config.lua @@ -1,2 +1,3 @@ Config = {} -Config.Visible = false +Config.Locale = 'en' +Config.Visible = false \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua b/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua index 8dea3236f..2a26ba787 100644 --- a/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua +++ b/server-data/resources/[esx_addons]/esx_basicneeds/fxmanifest.lua @@ -2,18 +2,22 @@ fx_version 'adamant' game 'gta5' -description 'ESX Basic Needs' +description 'Basic Needs' +lua54 'yes' +version '0.0.5' -version '0.0.4' +shared_script '@es_extended/imports.lua' server_scripts { '@es_extended/locale.lua', + 'locales/*.lua', 'config.lua', 'server/main.lua' } client_scripts { '@es_extended/locale.lua', + 'locales/*.lua', 'config.lua', 'client/main.lua' } diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua new file mode 100644 index 000000000..15c31d5a8 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/da.lua @@ -0,0 +1,3 @@ +Locales['da'] = { + ['got_healed'] = 'Du er blevet helbredt.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua new file mode 100644 index 000000000..94d91f9d5 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/de.lua @@ -0,0 +1,3 @@ +Locales['de'] = { + ['got_healed'] = 'Du wurdest geheilt.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua new file mode 100644 index 000000000..3f490d0a1 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/en.lua @@ -0,0 +1,3 @@ +Locales['en'] = { + ['got_healed'] = 'You have been healed.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua new file mode 100644 index 000000000..06d9abb57 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/es.lua @@ -0,0 +1,4 @@ +Locales['es'] = { + ['used_bread'] = 'Has usado 1x pan', + ['used_water'] = 'Has usado 1x agua', +} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua new file mode 100644 index 000000000..92702f41d --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fi.lua @@ -0,0 +1,4 @@ +Locales['fi'] = { + ['used_bread'] = 'sinä söit 1x leipä', + ['used_water'] = 'sinä joit 1x vesi', +} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua new file mode 100644 index 000000000..728539d77 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/fr.lua @@ -0,0 +1,3 @@ +Locales['fr'] = { + ['got_healed'] = 'Vous avez été soigné.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua new file mode 100644 index 000000000..1277cbaca --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/hu.lua @@ -0,0 +1,4 @@ +Locales['hu'] = { + ['used_bread'] = 'Megettél egy kenyeret.', + ['used_water'] = 'Megittál egy vizet.', +} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua new file mode 100644 index 000000000..d23eb7668 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/it.lua @@ -0,0 +1,5 @@ +Locales['it'] = { + ['used_bread'] = 'hai usato 1x panino', + ['used_water'] = 'hai usato 1x acqua', + ['got_healed'] = 'Sei stato curato.' +} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua new file mode 100644 index 000000000..23bb68a10 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/nl.lua @@ -0,0 +1,3 @@ +Locales['nl'] = { + ['used_eat'] = 'je hebt een %s gegeten', +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua new file mode 100644 index 000000000..6ce6b3af6 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/pl.lua @@ -0,0 +1,4 @@ +Locales['pl'] = { + ['used_bread'] = 'zjadłeś/aś 1x chleb', + ['used_water'] = 'wypiłeś/aś 1x woda', +} \ No newline at end of file diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua new file mode 100644 index 000000000..031851624 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sl.lua @@ -0,0 +1,3 @@ +Locales['sl'] = { + ['got_healed'] = 'Vi ste bili Pozdravljeni.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua new file mode 100644 index 000000000..336eda766 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/sr.lua @@ -0,0 +1,3 @@ +Locales['sr'] = { + ['got_healed'] = 'Vi ste izlečeni.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua b/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua new file mode 100644 index 000000000..2ed1e6073 --- /dev/null +++ b/server-data/resources/[esx_addons]/esx_basicneeds/locales/zh-cn.lua @@ -0,0 +1,3 @@ +Locales['zh-cn'] = { + ['got_healed'] = '已重置饥饿+饥渴双值.' +} diff --git a/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua b/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua index ba61f8463..6cbd0c7e1 100644 --- a/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_basicneeds/server/main.lua @@ -1,10 +1,14 @@ -ESX = nil - -ESX = exports["es_extended"]:getSharedObject() - -ESX.RegisterCommand('heal', 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand('heal', 'admin', function(_, args) args.playerId.triggerEvent('esx_basicneeds:healPlayer') - args.playerId.triggerEvent('chat:addMessage', {args = {'^5HEAL', 'You have been healed.'}}) + args.playerId.showNotification(_U('got_healed')) end, true, {help = 'Heal a player, or yourself - restores thirst, hunger and health.', validate = true, arguments = { {name = 'playerId', help = 'the player id', type = 'player'} -}}) \ No newline at end of file +}}) + +AddEventHandler('txAdmin:events:healedPlayer', function(eventData) + if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then + return + end + + TriggerClientEvent('esx_basicneeds:healPlayer', eventData.id) +end) \ No newline at end of file