Jump to content

Calling client event


Noki

Recommended Posts

-- 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

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

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...