mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 10:48:52 +00:00
Only keyboard input (fixes #3), removed bugy anim, cleanup
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
# fxserver-esx_animations
|
||||
FXServer ESX Animations
|
||||
|
||||
[INSTALLATION]
|
||||
# esx_animations
|
||||
|
||||
### Installation
|
||||
1) CD in your resources/[esx] folder
|
||||
2) Clone the repository
|
||||
```
|
||||
git clone https://github.com/FXServer-ESX/fxserver-esx_animations esx_animations
|
||||
git clone https://github.com/ESX-Org/esx_animations esx_animations
|
||||
```
|
||||
3) Add this in your server.cfg :
|
||||
|
||||
|
||||
+39
-78
@@ -10,6 +10,7 @@ local Keys = {
|
||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
||||
}
|
||||
|
||||
local isDead = false
|
||||
ESX = nil
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
@@ -19,54 +20,54 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
function startAttitude(lib, anim)
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
RequestAnimSet(anim)
|
||||
|
||||
while not HasAnimSetLoaded(anim) do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
SetPedMovementClipset(playerPed, anim, true)
|
||||
end)
|
||||
AddEventHandler('esx:onPlayerDeath', function()
|
||||
isDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function(spawn)
|
||||
isDead = false
|
||||
end)
|
||||
|
||||
function startAttitude(lib, anim)
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
RequestAnimSet(anim)
|
||||
|
||||
while not HasAnimSetLoaded(anim) do
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
SetPedMovementClipset(playerPed, anim, true)
|
||||
end)
|
||||
end
|
||||
|
||||
function startAnim(lib, anim)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
RequestAnimDict(lib)
|
||||
while not HasAnimDictLoaded( lib) do
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
|
||||
RequestAnimDict(lib)
|
||||
|
||||
while not HasAnimDictLoaded( lib) do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
TaskPlayAnim(GetPlayerPed(-1), lib ,anim ,8.0, -8.0, -1, 0, 0, false, false, false )
|
||||
|
||||
TaskPlayAnim(GetPlayerPed(-1), lib ,anim ,8.0, -8.0, -1, 0, 0, false, false, false )
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function startScenario(anim)
|
||||
TaskStartScenarioInPlace(GetPlayerPed(-1), anim, 0, false)
|
||||
TaskStartScenarioInPlace(GetPlayerPed(-1), anim, 0, false)
|
||||
end
|
||||
|
||||
function OpenAnimationsMenu()
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #Config.Animations, 1 do
|
||||
table.insert(elements, {label = Config.Animations[i].label, value = Config.Animations[i].name})
|
||||
end
|
||||
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'animations',
|
||||
{
|
||||
title = 'Animations',
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
@@ -76,18 +77,15 @@ function OpenAnimationsMenu()
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function OpenAnimationsSubMenu(menu)
|
||||
|
||||
local title = nil
|
||||
local elements = {}
|
||||
|
||||
for i=1, #Config.Animations, 1 do
|
||||
|
||||
|
||||
if Config.Animations[i].name == menu then
|
||||
|
||||
title = Config.Animations[i].label
|
||||
|
||||
for j=1, # Config.Animations[i].items, 1 do
|
||||
@@ -104,10 +102,9 @@ function OpenAnimationsSubMenu(menu)
|
||||
'default', GetCurrentResourceName(), 'animations_sub',
|
||||
{
|
||||
title = title,
|
||||
align = 'top-left',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
}, function(data, menu)
|
||||
local type = data.current.type
|
||||
local lib = data.current.value.lib
|
||||
local anim = data.current.value.anim
|
||||
@@ -122,61 +119,25 @@ function OpenAnimationsSubMenu(menu)
|
||||
end
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
end, function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
local function startPointing()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
RequestAnimDict("anim@mp_point")
|
||||
|
||||
while not HasAnimDictLoaded("anim@mp_point") do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
|
||||
SetPedCurrentWeaponVisible(playerPed, 0, 1, 1, 1)
|
||||
SetPedConfigFlag(playerPed, 36, 1)
|
||||
|
||||
Citizen.InvokeNative(0x2D537BA194896636, playerPed, "task_mp_pointing", 0.5, 0, "anim@mp_point", 24)
|
||||
end
|
||||
|
||||
local function stopPointing()
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
Citizen.InvokeNative(0xD01015C7316AE176, playerPed, "Stop")
|
||||
|
||||
if not IsPedInjured(playerPed) then
|
||||
ClearPedSecondaryTask(playerPed)
|
||||
end
|
||||
|
||||
if not IsPedInAnyVehicle(playerPed, 1) then
|
||||
SetPedCurrentWeaponVisible(playerPed, 1, 1, 1, 1)
|
||||
end
|
||||
|
||||
SetPedConfigFlag(playerPed, 36, 0)
|
||||
|
||||
ClearPedSecondaryTask(PlayerPedId())
|
||||
end
|
||||
|
||||
-- Key Controls
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
while true do
|
||||
Citizen.Wait(10)
|
||||
|
||||
if IsControlJustReleased(0, Keys['F3']) then
|
||||
OpenAnimationsMenu()
|
||||
end
|
||||
if IsControlJustReleased(0, Keys['F3']) and GetLastInputMethod(2) and not isDead then
|
||||
OpenAnimationsMenu()
|
||||
end
|
||||
|
||||
if IsControlJustReleased(0, Keys['X']) then
|
||||
ClearPedTasks(GetPlayerPed(-1))
|
||||
end
|
||||
if IsControlJustReleased(0, Keys['X']) and GetLastInputMethod(2) and not isDead then
|
||||
ClearPedTasks(GetPlayerPed(-1))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -43,7 +43,6 @@ Config.Animations = {
|
||||
{label = "Police : circulation", type = "scenario", data = {anim = "WORLD_HUMAN_CAR_PARK_ATTENDANT"}},
|
||||
{label = "Police : jumelles", type = "scenario", data = {anim = "WORLD_HUMAN_BINOCULARS"}},
|
||||
{label = "Agriculture : récolter", type = "scenario", data = {anim = "world_human_gardener_plant"}},
|
||||
{label = "Dépanneur : réparer sous véhicule", type = "scenario", data = {anim = "world_human_vehicle_mechanic"}},
|
||||
{label = "Dépanneur : réparer le moteur", type = "anim", data = {lib = "mini@repair", anim = "fixing_a_ped"}},
|
||||
{label = "Médecin : observer", type = "scenario", data = {anim = "CODE_HUMAN_MEDIC_KNEEL"}},
|
||||
{label = "Taxi : parler au client", type = "anim", data = {lib = "oddjobs@taxi@driver", anim = "leanover_idle"}},
|
||||
@@ -102,7 +101,6 @@ Config.Animations = {
|
||||
items = {
|
||||
{label = "Boire un café", type = "anim", data = {lib = "amb@world_human_aa_coffee@idle_a", anim = "idle_a"}},
|
||||
{label = "S'asseoir", type = "anim", data = {lib = "anim@heists@prison_heistunfinished_biztarget_idle", anim = "target_idle"}},
|
||||
{label = "S'asseoir (Par terre)", type = "scenario", data = {anim = "WORLD_HUMAN_PICNIC"}},
|
||||
{label = "Attendre contre un mur", type = "scenario", data = {anim = "world_human_leaning"}},
|
||||
{label = "Couché sur le dos", type = "scenario", data = {anim = "WORLD_HUMAN_SUNBATHE_BACK"}},
|
||||
{label = "Couché sur le ventre", type = "scenario", data = {anim = "WORLD_HUMAN_SUNBATHE"}},
|
||||
|
||||
Reference in New Issue
Block a user