patriot Posted December 24, 2012 Posted December 24, 2012 Hi guys, I need a clientside function that creates a dxText using parameters, for example: function dxText(string text, local time) Parameters: string text = the text of the dxDrawtext. local time = the time, in milliseconds for setTimer until the text disappears. Basically, the function creates a dxDrawText for a specified time. Thanks!
Anderl Posted December 24, 2012 Posted December 24, 2012 Don't expect people to make things for you. Also, that is really easy to do. "[...] 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
patriot Posted December 24, 2012 Author Posted December 24, 2012 I can actually make it myself, but I don't know why that thing isn't working. Once I know what's the error in the following code, I will be able to make what I mentioned above. function outPutFunc(string text) outputChatBox ( text ) end outPutFunc("Test")
Alen141 Posted December 24, 2012 Posted December 24, 2012 you don't have commandhandler there EDIT: or atleast trigger
patriot Posted December 24, 2012 Author Posted December 24, 2012 I put "outPutFunc("Test")" under onClientRender.
Alen141 Posted December 24, 2012 Posted December 24, 2012 use this ban example and try to fix it function announceBan( theBan ) if getElementType( source ) then --Check if a player banned the IP/Serial outputChatBox( getPlayerName( source ) .. " banned " .. ( getBanSerial(theBan) or getBanIP(theBan) ) ) --Output to the chatbox saying the player has banned the IP/Serial end end addEventHandler( "onBan", root, announceBan ) --Adds the event handler for 'onBan' and must be bound to root
DiSaMe Posted December 24, 2012 Posted December 24, 2012 function outPutFunc(string text) should be changed to function outPutFunc(text) -
patriot Posted December 24, 2012 Author Posted December 24, 2012 All I wanted to know. How do I make a bool parameter inside a function? As far as I see when writing a LUA function there is no need to specifcy whether the parameter is a string ot int, but what when it comes to bool?
Castillo Posted December 24, 2012 Posted December 24, 2012 function testFunction ( argument ) outputChatBox ( "Argument value is '".. ( argument and "true" or "false" ) .."'" ) end testFunction ( true ) testFunction ( false ) Is that what you meant? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted December 24, 2012 Posted December 24, 2012 (edited) All I wanted to know.How do I make a bool parameter inside a function? As far as I see when writing a LUA function there is no need to specifcy whether the parameter is a string ot int, but what when it comes to bool? It's exactly the same. local variable = 2; print( type( variable ) ); -- 'number' variable = "Something is wrong over there..."; print( type( variable ) ); -- 'string' variable = true; print( type( variable ) ); -- 'boolean' In Lua, you can change variable types by simply changing to a value of the type you want. In C++, for example, the type of the variables are "constant" - they're set at compile time and you can't change them at runtime ( well, actually you can but you might lose precision ). Edited December 24, 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
patriot Posted December 24, 2012 Author Posted December 24, 2012 Nevermind, got this already. However, I tried to make the function that I wanted: function dxText( text, timer ) setTimer ( function() dxDrawText ( .... ) end, timer, 1 ) end addCommandHandler("showtext",function() dxGameText("Text test", 2000) end) But the text shows only after the specificed time and then disappears right away...
Anderl Posted December 24, 2012 Posted December 24, 2012 You gotta draw the text right after calling the function and then create a timer to remove it, not create a timer to draw it first. "[...] 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
Castillo Posted December 24, 2012 Posted December 24, 2012 dxDrawText requires the 'onClientRender' event in order to work. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
patriot Posted December 24, 2012 Author Posted December 24, 2012 Okay then, I will simply handle a dxDrawText with no text at all ("") and change it everytime by setting a varaiable which stores the text. Then I will create a timer to reset the text ("") and I guess problem sorted out. Sorry for being so LUA newbie.
Castillo Posted December 24, 2012 Posted December 24, 2012 You could always use GUI-labels. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted December 24, 2012 Posted December 24, 2012 A more efficient way ( you won't notice it, but if you add more texts it may starting lagging ) is to create an "onClientRender" event and call it when you want to draw the text. You'll still need variables, though. "[...] 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
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