Hi i added various item to esx_basicneeds to increase health like bandage, morphin and other but i dont know how to set it to add health to player somebody can help me ?
1 Like
you can use the base of the “bend” and the “medikit” that is in the esx_ambulancejob" …
First you go to “client.lua” and put this:
RegisterNetEvent('cosasvariadas:tuitem')
AddEventHandler('cosasvariadas:tuitem', function()
local playerPed = PlayerPedId()
local vida = GetEntityHealth(playerPed)
local vidallena = GetEntityMaxHealth(playerPed)
if vida >0 and vida < vidallena then
local vidanueva = math.min(vidallena, math.floor(vida + vidallena / 16))
print("se curo un 1/4 de vida ")
if vida > vidallena then
vida = vidallena
print("esta la vida llena")
end
SetEntityHealth(playerPed, vidanueva)
print("se curo 1")
end
end)
Then you go to “server.lua” and put this:
ESX.RegisterUsableItem('tuitem', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem('tuitem', 1)
TriggerClientEvent('cosasvariadas:tuitem', source)
end)
remember to change “tuitem” to the item you’re wearing, that is, its name.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.