mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Major cleanup, /heal, fixed #12, sv locale
This commit is contained in:
@@ -1,24 +1,43 @@
|
||||
# fxserver-esx_basicneeds
|
||||
FXServer ESX Basic Needs
|
||||
# esx_basicneeds
|
||||
This script implements hunger and thirst status, they can be increased when eating bread or drinking water.
|
||||
|
||||
[REQUIREMENTS]
|
||||
## Requirements
|
||||
- [esx_status](https://github.com/ESX-Org/esx_status)
|
||||
|
||||
- esx_status => https://github.com/FXServer-ESX/fxserver-esx_status
|
||||
## Download & Installation
|
||||
|
||||
[INFO]
|
||||
|
||||
This plugin add hunger and thirst status, they can be increased when eating bread or drinking water
|
||||
|
||||
[INSTALLATION]
|
||||
|
||||
1) CD in your resources/[esx] folder
|
||||
2) Clone the repository
|
||||
### Using [fvm](https://github.com/qlaffont/fvm-installer)
|
||||
```
|
||||
git clone https://github.com/FXServer-ESX/fxserver-esx_basicneeds esx_basicneeds
|
||||
fvm install --save --folder=esx esx-org/esx_basicneeds
|
||||
```
|
||||
3) Import esx_basicneeds.sql in your database
|
||||
4) Add this in your server.cfg :
|
||||
|
||||
### Using Git
|
||||
```
|
||||
cd resources
|
||||
git clone https://github.com/ESX-Org/esx_basicneeds [esx]/esx_basicneeds
|
||||
```
|
||||
|
||||
### Manually
|
||||
- Download https://github.com/ESX-Org/esx_basicneeds/archive/master.zip
|
||||
- Put it in the `[esx]` directory
|
||||
|
||||
|
||||
## Installation
|
||||
- Import `esx_basicneeds.sql` in your database
|
||||
- Add this in your server.cfg :
|
||||
|
||||
```
|
||||
start esx_basicneeds
|
||||
```
|
||||
|
||||
# Legal
|
||||
### License
|
||||
esx_basicneeds - thirst and hunger system
|
||||
|
||||
Copyright (C) 2015-2018 Jérémie N'gadi
|
||||
|
||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||
|
||||
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
|
||||
|
||||
You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/.
|
||||
@@ -25,3 +25,8 @@ client_scripts {
|
||||
'config.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
'es_extended',
|
||||
'esx_status'
|
||||
}
|
||||
|
||||
+44
-59
@@ -12,11 +12,24 @@ end)
|
||||
AddEventHandler('esx_basicneeds:resetStatus', function()
|
||||
TriggerEvent('esx_status:set', 'hunger', 500000)
|
||||
TriggerEvent('esx_status:set', 'thirst', 500000)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
RegisterNetEvent('esx_basicneeds:healPlayer')
|
||||
AddEventHandler('esx_basicneeds:healPlayer', function()
|
||||
-- restore hunger & thirst
|
||||
TriggerEvent('esx_status:set', 'hunger', 1000000)
|
||||
TriggerEvent('esx_status:set', 'thirst', 1000000)
|
||||
|
||||
-- restore hp
|
||||
local sourcePed = GetPlayerPed(-1)
|
||||
SetEntityHealth(sourcePed, GetEntityMaxHealth(sourcePed))
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:onPlayerDeath', function()
|
||||
IsDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function(spawn)
|
||||
if IsDead then
|
||||
TriggerEvent('esx_basicneeds:resetStatus')
|
||||
end
|
||||
@@ -29,33 +42,29 @@ AddEventHandler('esx_status:loaded', function(status)
|
||||
TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(200)
|
||||
end, function(status)
|
||||
status.remove(100)
|
||||
end
|
||||
)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(250)
|
||||
end, function(status)
|
||||
status.remove(75)
|
||||
end
|
||||
)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while true do
|
||||
|
||||
Wait(1000)
|
||||
Citizen.Wait(1000)
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
local prevHealth = GetEntityHealth(playerPed)
|
||||
local health = prevHealth
|
||||
|
||||
TriggerEvent('esx_status:getStatus', 'hunger', function(status)
|
||||
|
||||
if status.val == 0 then
|
||||
|
||||
if prevHealth <= 150 then
|
||||
@@ -63,13 +72,10 @@ AddEventHandler('esx_status:loaded', function(status)
|
||||
else
|
||||
health = health - 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_status:getStatus', 'thirst', function(status)
|
||||
|
||||
if status.val == 0 then
|
||||
|
||||
if prevHealth <= 150 then
|
||||
@@ -77,35 +83,14 @@ AddEventHandler('esx_status:loaded', function(status)
|
||||
else
|
||||
health = health - 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
if health ~= prevHealth then
|
||||
SetEntityHealth(playerPed, health)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while true do
|
||||
|
||||
Wait(0)
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
if IsEntityDead(playerPed) and not IsDead then
|
||||
IsDead = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_basicneeds:isEating', function(cb)
|
||||
@@ -114,24 +99,24 @@ end)
|
||||
|
||||
RegisterNetEvent('esx_basicneeds:onEat')
|
||||
AddEventHandler('esx_basicneeds:onEat', function(prop_name)
|
||||
if not IsAnimated then
|
||||
if not IsAnimated then
|
||||
local prop_name = prop_name or 'prop_cs_burger_01'
|
||||
IsAnimated = true
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
Citizen.CreateThread(function()
|
||||
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
|
||||
Wait(0)
|
||||
end
|
||||
TaskPlayAnim(playerPed, 'mp_player_inteat@burger', 'mp_player_int_eat_burger_fp', 8.0, -8, -1, 49, 0, 0, 0, 0)
|
||||
Wait(3000)
|
||||
IsAnimated = false
|
||||
ClearPedSecondaryTask(playerPed)
|
||||
DeleteObject(prop)
|
||||
end)
|
||||
IsAnimated = true
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
Citizen.CreateThread(function()
|
||||
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)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -143,17 +128,17 @@ AddEventHandler('esx_basicneeds:onDrink', function(prop_name)
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
Citizen.CreateThread(function()
|
||||
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)
|
||||
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
|
||||
Wait(0)
|
||||
Citizen.Wait(10)
|
||||
end
|
||||
TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 1.0, -1.0, 2000, 0, 1, true, true, true)
|
||||
Wait(3000)
|
||||
IsAnimated = false
|
||||
ClearPedSecondaryTask(playerPed)
|
||||
Citizen.Wait(3000)
|
||||
IsAnimated = false
|
||||
ClearPedSecondaryTask(playerPed)
|
||||
DeleteObject(prop)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
+1
-4
@@ -1,5 +1,2 @@
|
||||
Config = {}
|
||||
Config.Locale = 'fr'
|
||||
|
||||
Config.TickTime = 100
|
||||
Config.UpdateClientTime = 5000
|
||||
Config.Locale = 'fr'
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `items` (name, label) VALUES
|
||||
('bread', 'Pain'),
|
||||
('water', 'Eau')
|
||||
;
|
||||
INSERT INTO `items` (`name`, `label`, `limit`) VALUES
|
||||
('bread', 'Pain', 10),
|
||||
('water', 'Eau', 5)
|
||||
;
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
Locales['br'] = {
|
||||
|
||||
['used_bread'] = 'Você comeu 1x pão',
|
||||
['used_water'] = 'Você tomou 1x água',
|
||||
|
||||
}
|
||||
['used_bread'] = 'você comeu ~y~1x~s~ ~b~pão~s~',
|
||||
['used_water'] = 'você tomou ~y~1x~s~ ~b~água~s~',
|
||||
}
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
Locales['de'] = {
|
||||
|
||||
['used_bread'] = 'Du hast 1x Brot gegessen',
|
||||
['used_water'] = 'Du hast 1x Wasser getrunken',
|
||||
|
||||
}
|
||||
['used_bread'] = 'du hast ~y~1x~s~ ~b~Brot gegessen~s~',
|
||||
['used_water'] = 'du hast ~y~1x~s~ ~b~Wasser getrunken~s~',
|
||||
}
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
Locales['en'] = {
|
||||
|
||||
['used_bread'] = 'you have used 1x bread',
|
||||
['used_water'] = 'you have used 1x water',
|
||||
|
||||
}
|
||||
['used_bread'] = 'you have used ~y~1x~s~ ~b~bread~s~',
|
||||
['used_water'] = 'you have used ~y~1x~s~ ~b~water~s~',
|
||||
}
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
Locales['fi'] = {
|
||||
|
||||
['used_bread'] = 'sinä söit 1x Leipä',
|
||||
['used_water'] = 'sinä joit 1x Vesi',
|
||||
|
||||
}
|
||||
['used_bread'] = 'sinä söit ~y~1x~s~ ~b~leipä~s~',
|
||||
['used_water'] = 'sinä joit ~y~1x~s~ ~b~vesi~s~',
|
||||
}
|
||||
+3
-5
@@ -1,6 +1,4 @@
|
||||
Locales['fr'] = {
|
||||
|
||||
['used_bread'] = 'vous avez utilisé 1x pain',
|
||||
['used_water'] = 'vous avez utilisé 1x eau',
|
||||
|
||||
}
|
||||
['used_bread'] = 'vous avez utilisé ~y~1x~s~ ~b~pain~s~',
|
||||
['used_water'] = 'vous avez utilisé ~y~1x~s~ ~b~eau~s~',
|
||||
}
|
||||
@@ -0,0 +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~',
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `items` (name, label) VALUES
|
||||
('bread', 'Brot'),
|
||||
('water', 'Wasser')
|
||||
;
|
||||
INSERT INTO `items` (`name`, `label`, `limit`) VALUES
|
||||
('bread', 'Brot', 10),
|
||||
('water', 'Wasser', 5)
|
||||
;
|
||||
@@ -1,6 +1,6 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `items` (name, label) VALUES
|
||||
('bread', 'Leipä'),
|
||||
('water', 'Vesi')
|
||||
;
|
||||
INSERT INTO `items` (`name`, `label`, `limit`) VALUES
|
||||
('bread', 'Leipä', 10),
|
||||
('water', 'Vesi', 5)
|
||||
;
|
||||
@@ -0,0 +1,6 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
INSERT INTO `items` (`name`, `label`, `limit`) VALUES
|
||||
('bread', 'Bröd', 10),
|
||||
('water', 'Vatten', 5)
|
||||
;
|
||||
+30
-8
@@ -3,27 +3,49 @@ ESX = nil
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
ESX.RegisterUsableItem('bread', function(source)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeInventoryItem('bread', 1)
|
||||
|
||||
TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
|
||||
TriggerClientEvent('esx_basicneeds:onEat', source)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('used_bread'))
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem('water', function(source)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeInventoryItem('water', 1)
|
||||
|
||||
TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
|
||||
TriggerClientEvent('esx_basicneeds:onDrink', source)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('used_water'))
|
||||
|
||||
end)
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'heal', 'admin', function(source, args, user)
|
||||
-- heal another player - don't heal source
|
||||
if args[1] then
|
||||
local target = tonumber(args[1])
|
||||
|
||||
-- is the argument a number?
|
||||
if target ~= nil then
|
||||
|
||||
-- is the number a valid player?
|
||||
if GetPlayerName(target) then
|
||||
print('esx_basicneeds: ' .. GetPlayerName(source) .. ' is healing a player!')
|
||||
TriggerClientEvent('esx_basicneeds:healPlayer', target)
|
||||
TriggerClientEvent('chatMessage', target, "HEAL", {223, 66, 244}, "You have been healed!")
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "HEAL", {255, 0, 0}, "Player not found!")
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "HEAL", {255, 0, 0}, "Incorrect syntax! You must provide a valid player ID")
|
||||
end
|
||||
else
|
||||
-- heal source
|
||||
print('esx_basicneeds: ' .. GetPlayerName(source) .. ' is healing!')
|
||||
TriggerClientEvent('esx_basicneeds:healPlayer', source)
|
||||
end
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "HEAL", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = "Heal a player, or yourself - restores thirst, hunger and health."})
|
||||
Reference in New Issue
Block a user