Version 2.0:
--CLIENT
local res = getResourceRootElement( getThisResource() )
local tick
function startStuff()
tick = getTickCount()
end
addEventHandler( "onClientResourceStart", res, startStuff )
function renderStuff()
local now = getTickCount()
if ( now - tick >= 7000 ) then
triggerServerEvent( "onTime", localPlayer, localPlayer )
tick = getTickCount()
end
end
addEventHandler( "onClientRender", root, renderStuff )
--SERVER
addEvent( "onTime", true )
function handleTime( thePlayer )
if ( thePlayer ) then
local a = getPlayerAccount( thePlayer )
if ( a ) then
local b = getAccountData( a, "regen" )
if ( b == true ) then
local hp = getElementHealth( thePlayer )
if ( hp < 100 ) then
local n_hp = ( hp + 5 > 100 ) and 100 or hp + 5
setElementHealth( thePlayer, n_hp )
end
end
end
end
end
addEventHandler( "onTime", root, handleTime )