Noki Posted December 4, 2014 Share Posted December 4, 2014 -- client side function showClock() local h, m = getTime() local sX, sY = guiGetScreenSize() if m < 10 then m = "0"..m end if h < 10 then h = "0"..h end --[[dxDrawText( h..":"..m, 1169, 26, 1299, 83, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, 1169, 24, 1299, 81, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, 1167, 26, 1297, 83, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, 1167, 24, 1297, 81, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, 1168, 25, 1298, 82, tocolor(255, 255, 255, 255), 4.00, "default", "left", "top", false, false, false, true, false ) ]] dxDrawText( h..":"..m, sX * 0.8557, sY * 0.0338, sX * 0.9509, sY * 0.1080, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, sX * 0.8557, sY * 0.0312, sX * 0.9509, sY * 0.1054, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, sX * 0.8543, sY * 0.0338, sX * 0.9494, sY * 0.1080, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, sX * 0.8543, sY * 0.0312, sX * 0.9494, sY * 0.1054, tocolor(0, 0, 0, 255), 4.00, "default", "left", "top", false, false, false, true, false ) dxDrawText( h..":"..m, sX * 0.8550, sY * 0.0325, sX * 0.9502, sY * 0.1067, tocolor(255, 255, 255, 255), 4.00, "default", "left", "top", false, false, false, true, false ) beingDrawn = true end addEvent( "renderClock", true ) addEventHandler( "renderClock", root, function ( ) addEventHandler( "onClientRender", root, showClock ) end ) addEventHandler( "onPlayerLogin", root, function () showPlayerHudComponent( source, "clock", false ) triggerClientEvent( "renderClock", resourceRoot, source ) end ) addEventHandler( "onResourceStart", root, function () triggerClientEvent( "renderClock", resourceRoot, root ) end ) Whenever the resource is started, or restarted, the clock doesn't display. I'm not exactly sure why. Any help would be appreciated. Thanks. Link to comment
MTA Team botder Posted December 4, 2014 MTA Team Share Posted December 4, 2014 The serverside resource starts faster than the clientside > Pointless clientside event triggering @ onResourceStart The players are probably already logged in > onPlayerLogin doesn't get triggered Problem: When the player logs out and then logs in the clock will be rendered multiple times because you don't check if the event is already added. Link to comment
MTA Team 0xCiBeR Posted December 4, 2014 MTA Team Share Posted December 4, 2014 You could use GetEventHandlers to know if the event is already handled and render it if necesary then use an event like onPlayerSpawn to trigger the check. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now