Reflex# Posted September 1, 2012 Posted September 1, 2012 Hey all. I want to create dxDrawtText join. But I think that..what I make is not true.. Help me guys g_Root = getRootElement() addEventHandler('onPlayerJoin',g_Root, function () dxDrawText(Server : ' .. getPlayerName(source) .. ' has joined the game ,3,0,10,10,tocolor(0,0,0,200),0.3,"default") end ) Scripting in lua
Renkon Posted September 1, 2012 Posted September 1, 2012 g_Root = getRootElement() addEventHandler('onPlayerJoin',g_Root, function () dxDrawText('Server : ' .. getPlayerName(source) .. ' has joined the game ',3,0,10,10,tocolor(0,0,0,200),0.3,"default") end )
ernst Posted September 1, 2012 Posted September 1, 2012 onPlayerJoin is a server sided event, and dxDrawText must use "onClientRender" event.
Anderl Posted September 1, 2012 Posted September 1, 2012 (edited) onPlayerJoin is a server sided event, and dxDrawText must use "onClientRender" event. And event is also server-side, but dxDrawText is client-side. Client-side: __dxDrawText = dxDrawText local _aDraws = { } function dxDrawText( ... ) if( ... ) then _aDraws[{ ... }] = true return true end return false end addEventHandler( 'onClientRender', root, function( ) for arg,v in pairs( _aDraws ) do while true do if( arg[1] == localPlayer ) then __dxDrawText( #arg => 2 and arg[2] or false, #arg => 3 and arg[3] or false, #arg => 4 and arg[4] or false, #arg => 5 and arg[5] or false, #arg => 6 and arg[6] or false, #arg => 7 and arg[7] or false, #arg => 8 and arg[8] or false, #arg => 9 and arg[9] or false, #arg => 10 and arg[10] or false, #arg => 11 and arg[11] or false, #arg => 12 and arg[12] or false, #arg => 13 and arg[13] or false, #arg => 14 and arg[14] or false, #arg => 15 and arg[15] or false, #arg => 16 and arg[16] or false; ) end break end end ) -- addEventHandler( 'onPlayerJoin', root, function( ) dxDrawText( root, 'Server: ' .. getPlayerName( source ) .. ' has joined the game!', 3, 0, 10, 10, tocolor( 0, 0, 0, 200 ), 0.3, 'default' ) end ) Server-side: addEventHandler( 'onPlayerJoin', root, function( ) triggerClientEvent( root, 'onPlayerJoin', source ) end ) Not tested. Edited September 1, 2012 by Guest "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Guest Guest4401 Posted September 1, 2012 Posted September 1, 2012 What's stopping you from using onClientPlayerJoin?
Castillo Posted September 1, 2012 Posted September 1, 2012 I don't really understand why you had to do all that Anderl . local playerJoined addEventHandler ( "onClientPlayerJoin", root, function ( ) if ( isTimer ( removeTimer ) ) then killTimer ( removeTimer ) end removeEventHandler ( "onClientRender", root, drawJoinMessage ) playerJoined = source addEventHandler ( "onClientRender", root, drawJoinMessage ) removeTimer = setTimer ( function ( ) removeEventHandler ( "onClientRender", root, drawJoinMessage ) playerJoined = nil end ,4000, 1 ) end ) function drawJoinMessage ( ) if ( playerJoined and isElement ( playerJoined ) ) then dxDrawText ( "Server: ".. getPlayerName ( playerJoined ) .." has joined the game", 3, 0, 10, 10, tocolor ( 0, 0, 0, 200 ), 0.3, "default" ) end end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted September 1, 2012 Posted September 1, 2012 I don't really understand why you had to do all that Anderl . local playerJoined addEventHandler ( "onClientPlayerJoin", root, function ( ) if ( isTimer ( removeTimer ) ) then killTimer ( removeTimer ) end removeEventHandler ( "onClientRender", root, drawJoinMessage ) playerJoined = source addEventHandler ( "onClientRender", root, drawJoinMessage ) removeTimer = setTimer ( function ( ) removeEventHandler ( "onClientRender", root, drawJoinMessage ) playerJoined = nil end ,4000, 1 ) end ) function drawJoinMessage ( ) if ( playerJoined and isElement ( playerJoined ) ) then dxDrawText ( "Server: ".. getPlayerName ( playerJoined ) .." has joined the game", 3, 0, 10, 10, tocolor ( 0, 0, 0, 200 ), 0.3, "default" ) end end Because it will be easier than making lots of functions for different texts or declaring lots of variables. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Jaysds1 Posted September 1, 2012 Posted September 1, 2012 is the problem solved? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Reflex# Posted September 2, 2012 Author Posted September 2, 2012 ye guys all work thanks to Solid and Anerl Scripting in lua
Castillo Posted September 2, 2012 Posted September 2, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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