[Solved] Limp Walking Style When Low On Health

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
1 Like

I’ll give that a go when I’m home from work.

Thank you @KeiranPower

1 Like

Did you resolve this issue? with that script??

Edit: This does indeed work. @KrizFrost @KeiranPower. Its between 100 - 200 it seems, with 100 being actually 0 (dead). not 0 - 200

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

Is fully working? @davewazere

4 Likes

@KrizFrost yes, it should work

1 Like

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.

1 Like

where do you put the script

Create a client.lua under a new folder in your resources and paste that code, then create __resource.lua in the same folder as the client.lua

In that __resource.lua

client_script 'client.lua'

You’re done. :heavy_check_mark:

Ok it worked now thanks

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.

yeah we all know the time… doesnt help

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…

ResetPedMovementClipset(GetPlayerPed(-1)) ResetPedWeaponMovementClipset(GetPlayerPed(-1)) ResetPedStrafeClipset(GetPlayerPed(-1))

how can we possibly reset once and let the loop look if we eventually hurt again.

yea, same problem here

Am I able to post this in #server-development so people can actually use this or no?

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

Which client.lua is correct for the script to actually work?

where i put this code?

1 Like