mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
added isEating callback
fixed animation issues you can now use a personnalized prop by calling onEat or onDrink.
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'ESX Basic Needs'
|
||||
|
||||
version '1.0.0'
|
||||
version '1.0.1'
|
||||
|
||||
server_scripts {
|
||||
'@es_extended/locale.lua',
|
||||
|
||||
+45
-23
@@ -1,5 +1,6 @@
|
||||
ESX = nil
|
||||
local IsDead = false
|
||||
local IsAnimated = false
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
@@ -107,31 +108,52 @@ AddEventHandler('esx_status:loaded', function(status)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_basicneeds:onEat')
|
||||
AddEventHandler('esx_basicneeds:onEat', function()
|
||||
|
||||
local pid = PlayerPedId()
|
||||
|
||||
RequestAnimDict("mp_player_inteat@burger")
|
||||
|
||||
while not HasAnimDictLoaded("mp_player_inteat@burger") do
|
||||
Wait(0)
|
||||
end
|
||||
AddEventHandler('esx_basicneeds:isEating', function(cb)
|
||||
cb(IsAnimated)
|
||||
end)
|
||||
|
||||
TaskPlayAnim(pid, 'mp_player_inteat@burger', 'mp_player_int_eat_burger', 1.0, -1.0, 2000, 0, 1, true, true, true)
|
||||
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'
|
||||
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)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_basicneeds:onDrink')
|
||||
AddEventHandler('esx_basicneeds:onDrink', function()
|
||||
|
||||
local pid = PlayerPedId()
|
||||
|
||||
RequestAnimDict("amb@world_human_drinking@coffee@male@idle_a")
|
||||
|
||||
while not HasAnimDictLoaded("amb@world_human_drinking@coffee@male@idle_a") do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
TaskPlayAnim(pid, 'amb@world_human_drinking@coffee@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
|
||||
|
||||
AddEventHandler('esx_basicneeds:onDrink', function(prop_name)
|
||||
if not IsAnimated then
|
||||
local prop_name = prop_name or 'prop_ld_flow_bottle'
|
||||
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_intdrink')
|
||||
while not HasAnimDictLoaded('mp_player_intdrink') do
|
||||
Wait(0)
|
||||
end
|
||||
TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 1.0, -1.0, 2000, 0, 1, true, true, true)
|
||||
Wait(3000)
|
||||
IsAnimated = false
|
||||
ClearPedSecondaryTask(playerPed)
|
||||
DeleteObject(prop)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user