i am trying to make script for bandage that heals you for amount of hp but i don’t think the script i wrote it’s right and makes sense but i am new to this, any chances for helping me doing it right? and how i need to add and icon to my inventory just a script and i will do the other thing
Cluent lua
RegisterNetEvent(‘esx_bandage:bandage’)
AddEventHandler(‘esx_bandage:bandage’, function()
local playerPed = GetPlayerPed(-1)
Citizen.CreateThread(function()
local Medkit = AttachEntityToPed('prop_med_bag_01',60309, 0,0,0, 0,0,0)
PlayAnim(GetPlayerPed(-1),'anim@heists@box_carry@','base',4,3000)
Citizen.Wait(time)
StopAnimTask(GetPlayerPed(-1), 'anim@heists@box_carry@walk','idle_c',2.0)
DeleteEntity(Medkit)
local newHealth = (health + 25)
health = GetEntityHealth(GetPlayerPed(-1))
SetEntityHealth(GetPlayerPed(-1), health + 25)
end
end)
end)
Server lua
ESX = nil
ESX.RegisterUsableItem(‘bandage’, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(‘bandage’, 1)
TriggerClientEvent(‘esx_bandage:bandage’, source)
end)