Hi everyone,
I need help with a simple script about Knockout. Originaly from @Cosmo [[Release] Player Knockout]
I use the last version of ESX.
I use many other script but no one that interact with Health or Damage.
The fact is, actually the script don’t put the player in invincible mode.
I tryied to set SetPlayerInvincible(PlayerId() on “myPed” but the script don’t work after that.
I know that the Invincible mod is a native [https://runtime.fivem.net/doc/natives/?_0x239528EACDC3E7DE] but i don’t know, i can’t figure out why it’s not working.
So when i’m “knocked” when i pass under 175 health (can’t test with someone else actually, i’m on local) , and ped keep attacking me, i see my life going down, but health is going up also, because “SetEntityHealth” is “healing” me…
The mechanic don’t actually work for RP. I also try to combine this script with a script (at the very end of the topic) that reduce the damage deal for MELEE_WEAPON, and STICK originaly take from [[STANDALONE] Remove pistol-whipping, melee and nighstick damage] by @TheYork but both on the same client.lua don’t work.
Can someone help me to figure it out please.
A good thing should be that :
- No damage on fist, low damage on melee weapon you choose, stick, lamp, stc…
- A “chance” to be “Knocked” when you take more than 3, 4, 5, shot, with the chance increase more when your life is going low
- Invincible when you are knocked by referenced weapons or issu from melee fight.
- Life save when you wakeup, no more heal.
I begin with all this things, and i trully know that stuff is higher than my capability.
Thanks for the reading guys, sorry for my English i’m from the Baguette country, tried to do my best.
local wait = 10
local count = 40
Citizen.CreateThread(function()
while true do
Wait(1)
local myPed = GetPlayerPed(-1)
if IsPedInMeleeCombat(myPed) then
if GetEntityHealth(myPed) < 175 then
SetPlayerInvincible(PlayerId(), true)
SetPedToRagdoll(myPed, 1000, 1000, 0, 0, 0, 0)
ShowNotification("~r~You were knocked out!")
wait = 10
knockedOut = true
SetEntityHealth(myPed, 175)
end
end
if knockedOut == true then
SetPlayerInvincible(PlayerId(), true)
DisablePlayerFiring(PlayerId(), true)
SetPedToRagdoll(myPed, 1000, 1000, 0, 0, 0, 0)
ResetPedRagdollTimer(myPed)
if wait >= 0 then
count = count - 1
if count == 0 then
count = 40
wait = wait - 1
SetEntityHealth(myPed, GetEntityHealth(myPed)+4)
end
else
SetPlayerInvincible(PlayerId(), false)
knockedOut = false
end
end
end
end)
function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
Reduce damage on melee
while true do
N_0x4757f00bc6323cfe(GetHashKey("WEAPON_UNARMED"), 0.2)
Wait(0)
N_0x4757f00bc6323cfe(GetHashKey("WEAPON_NIGHTSTICK"), 0.3)
Wait(0)
end
end)```