Jump to content

Bit of help :)


manve1

Recommended Posts

I tried making that when a player exits a vehicle, a certain label gets set to nil ( by nill i mean like to what it was when created )

vehHealth = guiCreateLabel( 0.48, 0.965, 0.3, 0.1, 'Vehicle Health: N/A', true ) 
  
function vehHealthIThink() 
local vehicleHealth = getPedOccupiedVehicle ( localPlayer ) 
if ( vehicleHealth ) then 
setTimer( function() 
local vehicleHlt = getElementHealth ( vehicleHealth ) 
guiSetText ( vehHealth, 'Vehicle Health: ' .. math.ceil( vehicleHlt ) ) 
end, 50, 0 
) 
end 
end 
addEventHandler ( "onClientVehicleEnter", root, vehHealthIThink ) 
  
addEventHandler ( "onClientVehicleExit", root, 
function() 
guiSetText ( vehHealth, 'Vehicle Health: ' ) 
end 
) 

Link to comment

You forgot the event arguments.

Client-side

local vehHealth = guiCreateLabel(0.48, 0.965, 0.3, 0.1, "Vehicle Health: N/A", true) 
  
addEventHandler("onClientVehicleEnter", root, 
function(player, seat) 
local vehicleHealth = getPedOccupiedVehicle(player) 
if vehicleHealth then 
hpTimer = setTimer(function(player) 
if isPedInVehicle(player) then 
guiSetText(vehHealth, "Vehicle Health: " .. math.ceil(getElementHealth(vehicleHealth))) 
else 
killTimer(hpTimer) 
end 
end, 50, 0, player) 
  
end 
end 
) 
  
addEventHandler("onClientVehicleExit", root, 
function(player, seat) 
guiSetText(vehHealth, "Vehicle Health: N/A") 
if isTimer(hpTimer) then 
killTimer(hpTimer) 
end 
end 
) 

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...