Jump to content

Problem with timed message script


Bazim

Recommended Posts

Hello i have this script

-- define function to be called 
  
function delayedChat ( text ) 
        outputChatBox ( "Delayed text: " .. text ) 
end 
  
-- set a timer so the function is called after 1 second 
setTimer ( delayedChat, 1000, 1, "Hello, World!" ) 

And any sec. is to do send text Delayed text: Hello, World! but there's nothing doing.

Link to comment

I did this instead, so I could test from the console, and it worked fine for me.

function delayedChat ( text ) 
        print( text ) 
end 
setTimer( delayedChat, 1000, 1, "Hello, World!" ) 

I have no idea why it wouldn't for you. Whatever the problem is, it's not in the code you posted.

Link to comment
thx, I see. That message is sending every second just once.

1) How can i set up. sending message to infinite?

2) Can be message colored?

for infinite calls use 0 in setTimer, and yes you can use colors ;)

function delayedChat ( text, showTo, r, g, b ) 
        outputChatBox ( "Delayed text: " .. text, showTo, r, g, b ) 
end 
  
setTimer ( delayedChat, 1000, 0, "Hello, World!", getRootElement(), 255, 0, 0 ) 

Link to comment
thx, I see. That message is sending every second just once.

1) How can i set up. sending message to infinite?

2) Can be message colored?

for infinite calls use 0 in setTimer, and yes you can use colors ;)

function delayedChat ( text, showTo, r, g, b ) 
        outputChatBox ( "Delayed text: " .. text, showTo, r, g, b ) 
end 
  
setTimer ( delayedChat, 1000, 0, "Hello, World!", getRootElement(), 255, 0, 0 ) 

You can also put the timer inside the function that is called by the timer itself, and call the function simply 1 time :)

Then everytime the function is executed, it starts the timer again, which starts the function again, etc....

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