So I’ve been trying to create a lua script that basically just caps the player health to 100 instead of 200 and is supposed to trigger a ragdoll whenever the player gets injured. I have tried isolating multiple lines with comments to no success and am starting to beat my head over this. Anyone have an idea why it could not be working?
Thanks in advance. And yes I am relatively new to modding here so please don’t chew me out for amateur mistakes.
Edit: Typos and changing format of code text.
-- Created by Scott and Eddie
-- Clientside
Citizen.CreateThread(function()
Citizen.Wait(10000)
local ped = GetPlayerPed(-1)
local playerLoc = GetEntityCoords(GetPlayerPed(-1))
SetEntityMaxHealth(GetPlayerPed(-1), 100)
SetEntityHealth(GetPlayerPed(-1), GetEntityMaxHealth(ped))
local currentHealth = GetEntityHealth(ped)
SetAiMeleeWeaponDamageModifier(1.0)
SetAiWeaponDamageModifier(1.0)
SetPlayerMeleeWeaponDamageModifier(1.0)
SetPlayerMeleeWeaponDefenseModifier(1.0)
Citizen.Wait(0)
while true do
Citizen.Wait(0)
ped = GetPlayerPed(-1)
playerLoc = GetEntityCoords(GetPlayerPed(-1))
SetPedCanPlayInjuredAnims(GetPlayerPed(-1), true)
SetPedCanRagdollFromPlayerImpact(GetPlayerPed(-1), true)
if currentHealth > GetEntityHealth(ped) then
SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
end
currentHealth = GetEntityHealth(ped)
if GetEntityHealth(ped) < 50 and IsPedInWrithe(ped)~=true then
SetPlayerControl(GetPlayerPed(-1),false,4)
TaskWrithe(GetPlayerPed(-1), GetClosestPed(playerLoc.x, playerLoc.y, playerLoc.z, 999999.0, true, false,ped,nil,nil,-1), 300000, 0)
end
end
end)