Hey, so I’m trying to make a limp when injured script. I have this so far. It seems to work ONLY when I restart the resource mid session. So if I join in then get hurt nothing happens. If I am still hurt then restart the resource it will take effect immediately. Any ideas?
Citizen.CreateThread(function()
while not NetworkIsPlayerActive(PlayerId()) do
Citizen.Wait(0)
end
while true do
Wait(0)
RequestAnimSet("move_m@injured")
Wait(500)
if DoesEntityExist(ped) then
if GetEntityHealth(ped) <= 120 then
hurt = true
elseif GetEntityHealth(ped) > 121 then
hurt = false
end
end
if hurt then
SetPedMovementClipset(ped, "move_m@injured", true)
else
ResetPedMovementClipset(GetPlayerPed(-1))
ResetPedWeaponMovementClipset(GetPlayerPed(-1))
ResetPedStrafeClipset(GetPlayerPed(-1))
end
end
end, false)
Citizen.CreateThread(function()
while true do
Wait(500)
if GetEntityHealth(GetPlayerPed(-1)) <= 120 then
setHurt()
elseif GetEntityHealth(GetPlayerPed(-1)) > 121 then
setNotHurt()
end
end
end)
function setHurt()
RequestAnimSet("move_m@injured")
SetPedMovementClipset(GetPlayerPed(-1), "move_m@injured", true)
end
function setNotHurt()
ResetPedMovementClipset(GetPlayerPed(-1))
ResetPedWeaponMovementClipset(GetPlayerPed(-1))
ResetPedStrafeClipset(GetPlayerPed(-1))
end
Citizen.CreateThread(function()
while true do
Wait(500)
if GetEntityHealth(GetPlayerPed(-1)) <= 120 then
setHurt()
elseif GetEntityHealth(GetPlayerPed(-1)) > 121 then
setNotHurt()
end
end
end)
function setHurt()
RequestAnimSet("move_m@injured")
SetPedMovementClipset(GetPlayerPed(-1), "move_m@injured", true)
end
function setNotHurt()
ResetPedMovementClipset(GetPlayerPed(-1))
ResetPedWeaponMovementClipset(GetPlayerPed(-1))
ResetPedStrafeClipset(GetPlayerPed(-1))
end
I made sure to set it to 150, 120 is too low (unless you like that)
Also, if you use a hotkey to crouch, it will reset your crouch almost immediately if you have it set to 500. So I suggest to change the wait to like, 60000(1 min) so you can still do that and not have it reset the crouch right away.
ok everyrhing work… but as its script… we cant use any other walk animation.
i struggle with this… im trying to fix the issue
any help would be apreciate.
You probably need to change the amount of time between checks.
Change your wait to something larger. If you have it too short it will check so fast that it keeps resetting your walk style.
what i try is to stop the loop from reset if the player was already reset… this way when we are not hurt anymore and been reset we can use other attitude walk…
i know the wait time can help but still… thw loop will start again and no more set animation will work after the wait…
sorry for the stupid question but i can get it to load its my fist time doing anything like this iv made the client lua and pasted the script in there and then made a _resource lua with client_script ‘client.lua’ in it any help id be thankful