drk Posted October 23, 2011 Share Posted October 23, 2011 Hi guys ! I am creating a resource that when a player joins set the text in DX label with 'BLABLABLA has joined the Server !'. But I don't know how to set a variable to the DX label and how to set the text on the label when a player joins. Can anyone help me ? Link to comment
12p Posted October 23, 2011 Share Posted October 23, 2011 You mean you use ... ? outputChatBox Then take this as example, if the value you are trying to use is a NUMBER: outputChatBox ( "Some message is number "..tostring ( 5 ).. " and works fine" ) But if it is a STRING, just use: outputChatBox ( "Some message is number "..value.. " and works fine" ) If you don't use outputChatBox... Anyway the example will work but applied to dxDrawText. Link to comment
DakiLLa Posted October 23, 2011 Share Posted October 23, 2011 By 'dx label ' you mean dxDrawText? If so, then: local textVar = "BlaBlaBlah" addEventHandler( "onClientRender", root, function() dxDrawText( textVar, sx, sy, sx, sy ) end ) addEventHandler( "onClientPlayerJoin", root, function() textVar = getPlayerName( source ).." has joined the game!" end ) Link to comment
drk Posted October 23, 2011 Author Share Posted October 23, 2011 Yes, it is. Thanks DakiLLA. Link to comment
drk Posted October 24, 2011 Author Share Posted October 24, 2011 And how to set a Timer to hide the Text ( no the label ) ? I've tried but don't work ;S The code: --[[--------------------------------- --client/server script --@author iMortal --@description server side main script ---------------------------------]]-- local textJoin = " " local textQuit = " " addEventHandler("onClientRender",root, function() dxDrawText( textQuit, 959.0, 246.0, 1227.0, 264.0, tocolor(0,0,0,255), 0.6, "bankgothic", "left", "top", false, false, false ) dxDrawText( textQuit, 956.0, 243.0, 1224.0, 261.0, tocolor(255,0,0,255), 0.6, "bankgothic", "left", "top", false, false, false ) dxDrawText( textJoin,943.0,217.0,1211.0,235.0,tocolor(0,0,0,255),0.6,"bankgothic","left","top",false,false,false) dxDrawText( textJoin,939.0,213.0,1207.0,231.0,tocolor(0,255,0,255),0.6,"bankgothic","left","top",false,false,false) end ) addEventHandler( "onClientPlayerJoin", root, function() textJoin = getPlayerName( source ).." entrou no Servidor !" setTimer ( function () local textJoin = " " end, 9000, 1 ) end ) Link to comment
Castillo Posted October 24, 2011 Share Posted October 24, 2011 (edited) addEventHandler( "onClientPlayerJoin", root, function() textJoin = getPlayerName( source ).." entrou no Servidor !" setTimer ( function () textJoin = "" end, 9000, 1 ) end ) Edited October 24, 2011 by Guest Link to comment
drk Posted October 24, 2011 Author Share Posted October 24, 2011 Thanks very much Solidskane14 and DakiLLa ! It worked perfectly ! EDIT: When a player quit the server don't appear '-' the code: addEventHandler( "onClientPlayerQuit", root, function() textQuit = getPlayerName( source ).." saiu do Servidor !" setTimer ( function () textQuit = "" end, 7000, 1 ) end ) Link to comment
12p Posted October 24, 2011 Share Posted October 24, 2011 addEventHandler( "onClientPlayerQuit", root, function() textJoin = getPlayerName( source ).." saiu do Servidor !" setTimer ( function () textJoin = "" end, 7000, 1 ) end ) That should work, but I don't know is that is what you want. Link to comment
karlis Posted October 25, 2011 Share Posted October 25, 2011 don't just set text to zero, but remove the onClientRender event handler. it is extremely inefficent when it comes to leaving dx drawing when its not needed. Link to comment
drk Posted October 25, 2011 Author Share Posted October 25, 2011 LOL, if I remove the onClientRender event, when a other player left the server, don't appear anymore -.- Link to comment
12p Posted October 25, 2011 Share Posted October 25, 2011 (edited) You can do that easily! Client: text = "" function drawMyText ( ) dxDrawText ( arguments..., text, ...arguments ) --You add the position, size, font, scale, etc arguments! end function createDXText ( t, timeToDestroy ) text = t addEventHandler ( "onClientRender", getRootElement ( ), drawMyText ) setTimer ( removeEventHandler, timeToDestroy, 1, "onClientRender", getRootElement ( ), drawMyText ) end addEvent ( "onDXText", true ) addEventHandler ( "onDXText", getRootElement ( ), function ( thetext ) create3DText ( thetext, someTime ) end ) Server addEventHandler ( "onPlayerQuit", getRootElement ( ), function ( ) triggerClientEvent ( getRootElement ( ), "onDXText", source, getPlayerName ( source ).." has left the server!" ) end ) And it should work! But there will be some issues if more than 1 player leaves I suggest you to make it easier and just use outputChatBox. May be too mainstream and simple but is easier and probably will take you out more than 1 headache. Edited October 25, 2011 by Guest Link to comment
Castillo Posted October 25, 2011 Share Posted October 25, 2011 Why you need to trigger from server side? using onClientPlayerJoin, onClientPlayerQuit should work. Link to comment
drk Posted October 27, 2011 Author Share Posted October 27, 2011 I don't know but I hate the chat box ahahah' I want to create in DX. And thanks for all that have tried to help. I've solved the problem. Easy Sorry for my FUCK english Link to comment
12p Posted October 27, 2011 Share Posted October 27, 2011 Why you need to trigger from server side? using onClientPlayerJoin, onClientPlayerQuit should work. Lol right. I think in the moment I had a reason to use the server side, now I don't remember it. Okay iMortal. If you need more help, just ask 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