General > Developers Corner

Simple request

(1/1)

AJ-:
It may be simple but I really can't figure out how to do this.

I want to have an array of different messages and have a random one of them print to the chatbox every 90 seconds. I don't know where to start, if somebody can point me in the right direction I would be very grateful.

I know ULX has an advertisement built in, but I want to display random messages and Im pretty sure thats not possible without some modification.

MrPresident:
Yeah, I think ULX gets its adverts sequentially. That being said, maybe it would be a good sugestion to make them display randomly.

This is an easy request, but all I have right now is my phone. Someone here should be able to whip this out for you on no time. If not, I'll do it when I get out of the hospital.

AJ-:

--- Quote from: MrPresident on March 04, 2013, 12:06:29 AM ---Yeah, I think ULX gets its adverts sequentially. That being said, maybe it would be a good sugestion to make them display randomly.

This is an easy request, but all I have right now is my phone. Someone here should be able to whip this out for you on no time. If not, I'll do it when I get out of the hospital.

--- End quote ---

Much appreciated

pazda:
This is untested but should work in autorun


--- Code: ---/* Made by Pazda */
 
// Configuration
 
local MSG_WAITTIME = 90 // seconds between each message
 
// write in some messages.
local MSG_NAMES = {"random message 1","random message 2","and so forth"}
     
local function RandomMsg()
    local msg = table.Random(MSG_NAMES)
ChatPrint( msg )
    timer.Simple(MSG_WAITTIME, RandomMsg)
end
 
RandomMsg()
--- End code ---

nathan736:

--- Quote from: pazda on March 07, 2013, 01:11:46 PM ---This is untested but should work in autorun


--- Code: ---/* Made by Pazda */
 
// Configuration
 
local MSG_WAITTIME = 90 // seconds between each message
 
// write in some messages.
local MSG_NAMES = {"random message 1","random message 2","and so forth"}
     
local function RandomMsg()
    local msg = table.Random(MSG_NAMES)
ChatPrint( msg )
    timer.Simple(MSG_WAITTIME, RandomMsg)
end
 
RandomMsg()
--- End code ---

--- End quote ---
theres probably a better way to do this by having a back up table and removing the string from the table every time you print it then once the table is empty just reset it to what it started at and repeat  that way EVERYTHING gets printed  eventually with in a predictable time limit.

Navigation

[0] Message Index

Go to full version