Jump to content

[HELP]-Random Messages


Exoogen

Recommended Posts

yes, it works fine :D and thanks.

Can you explain me why that script isn't written like another normal script ?

Usually in a script there are a function with the function name, istruction and an EventHandler.

In this case the function and instructions are written together..

PS: Sorry for my very bad english, i'm italian

Link to comment

Here's how it would look otherwise.

local messages = {"hello","hi","hey"} 
local time = 5000 
  
function pickMessage() 
    local whatMessage = math.random(1,#messages) 
    return messages[whatMessage] 
end 
  
function outputRandomMessage() 
    local message = pickMessage 
    outputChatBox(message) 
end 
  
function resourceStart() 
    setTimer(outputRandomMessage,time,0) 
end 
  
addEventHandler("onResourceStart", resourceRoot, resourceStart) 

That's an overly unnecessary way to do it essentially :P

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