Jump to content

Requesting function help.


patriot

Recommended Posts

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!

Link to comment

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

Link to comment

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 

Link to comment
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 by Guest
Link to comment

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

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