CheiN Posted August 16, 2012 Posted August 16, 2012 function Moon ( ) dxDrawText ( ..User.. Joined, 44, screenHeight -41, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1.10, "pricedown" ) end addEventHandler ( "onPlayerJoin", getRootElement(), Moon ) The thing: ¿IM GOOD? Thx for your time
AMARANT Posted August 16, 2012 Posted August 16, 2012 Of course you're not. You can't use client-side function server-side.
TAPL Posted August 16, 2012 Posted August 16, 2012 Where did User and Joined defined? You should use event onClientResourceStart.
CheiN Posted August 16, 2012 Author Posted August 16, 2012 function Moon ( startedResource ) local ..User.. = getPlayerName if ..User.. = getPlayerName and onPlayerJoin then dxDrawText ( ..User.. Joined, 44, screenHeight -41, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1.10, "pricedown" ) end addEventHandler ( "onClientResourceStart", getRootElement(), Moon ) again, im good?
Anderl Posted August 16, 2012 Posted August 16, 2012 No, it's all wrong. startedResource parameter is useless. You can't use symbols on variable names. You didn't call a function, you are assigning getPlayerName function to "..User.." The statement is all wrong. No need for "and onPlayerJoin then" dxDrawText must be used with onClientRender.
CheiN Posted August 16, 2012 Author Posted August 16, 2012 function Moon ( ) local visitor = getPlayerName dxDrawText ( "visitor" Joined, 44, screenHeight -41, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1.10, "pricedown" ) end addEventHandler ( "onClientRender", root, Moon )
Anderl Posted August 16, 2012 Posted August 16, 2012 Server-side: addEventHandler( 'onPlayerJoin', root, function( ) triggerClientEvent( 'onPlayerJoin', source ) end ) Client-side: local newUser addEvent( 'onPlayerJoin', true ) addEventHandler( 'onPlayerJoin', root, function( ) addEventHandler( 'onClientRender', root, drawText ) newUser = getPlayerName( source ) setTimer( removeEventHandler, 10000, 1, 'onClientRender', root, drawText ) end ) function drawText( ) dxDrawText( newUser .. ' joined!', 44, screenHeight - 41, screenWidth, screenHeight, tocolor( 255, 255, 255, 255 ), 1.1, "pricedown" ) end
TAPL Posted August 16, 2012 Posted August 16, 2012 -- Client Side -- local newUser = "" local screenWidth, screenHeight = guiGetScreenSize() addEventHandler('onClientPlayerJoin', root, function() newUser = getPlayerName(source).." joined!" if isTimer(tt) then killTimer(tt) end tt = setTimer(function() newUser = "" end,10000,1) end ) function drawText() dxDrawText(newUser, 44, screenHeight - 41, screenWidth, screenHeight, tocolor(255, 255, 255, 255), 1.1, "pricedown") end addEventHandler('onClientRender', root, drawText)
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