John_Scott Posted November 25, 2013 Posted November 25, 2013 Hi! I would like to write or get a Automatic Message script to my server. This script write a random text to the chat in every 5 minutes. Can someone help me? Thanks!
Tete omar Posted November 25, 2013 Posted November 25, 2013 setTimer math.random outputChatBox And use a table for texts.
codeluaeveryday Posted November 25, 2013 Posted November 25, 2013 Hello John! The current script will only work on the server side: local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } addEventHandler('onClientResourceStart', resourceRoot, function() setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], localPlayer, mRed, mGreen, mBlue, true) end ) If you want to use this client sided change line 16 to: setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], mRed, mGreen, mBlue, true) Enjoy, please learn from it.
John_Scott Posted November 25, 2013 Author Posted November 25, 2013 Hello John!The current script will only work on the server side: local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } addEventHandler('onClientResourceStart', resourceRoot, function() setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], localPlayer, mRed, mGreen, mBlue, true) end ) If you want to use this client sided change line 16 to: setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], mRed, mGreen, mBlue, true) Enjoy, please learn from it. Thank you very much!
codeluaeveryday Posted November 25, 2013 Posted November 25, 2013 You are welcome John! If you ever need a paid scripter, just add me on skype: chrisinater22.
John_Scott Posted November 25, 2013 Author Posted November 25, 2013 You are welcome John! If you ever need a paid scripter, just add me on skype: chrisinater22. Where are u from? And your script doesn't work.
Tete omar Posted November 25, 2013 Posted November 25, 2013 Hello John!The current script will only work on the server side: local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } addEventHandler('onClientResourceStart', resourceRoot, function() setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], localPlayer, mRed, mGreen, mBlue, true) end ) If you want to use this client sided change line 16 to: setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], mRed, mGreen, mBlue, true) Enjoy, please learn from it. client-sided outputChatBox does not have a 'visibleTo' param, also there is no need for onClientResourceStart. local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } setTimer ( outputChatBox, 1000 * 60 * 5, 0, theMessages [ math.random ( #theMessages ) ], mRed, mGreen, mBlue, true )
John_Scott Posted November 25, 2013 Author Posted November 25, 2013 Hello John!The current script will only work on the server side: local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } addEventHandler('onClientResourceStart', resourceRoot, function() setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], localPlayer, mRed, mGreen, mBlue, true) end ) If you want to use this client sided change line 16 to: setTimer(outputChatBox, 300000, 0, theMessages[math.random(#theMessages)], mRed, mGreen, mBlue, true) Enjoy, please learn from it. client-sided outputChatBox does not have a 'visibleTo' param, also there is no need for onClientResourceStart. local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } setTimer(outputChatBox, 1000 * 60 * 5, 0, theMessages[math.random(#theMessages)], mRed, mGreen, mBlue, true) Not working too, what start the function?
Tete omar Posted November 25, 2013 Posted November 25, 2013 local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } setTimer ( outputChatBox, 1000 * 60 * 5, 0, theMessages [ math.random ( #theMessages ) ], root, mRed, mGreen, mBlue, true )
TAPL Posted November 25, 2013 Posted November 25, 2013 local mRed = 255 local mGreen = 255 local mBlue = 255 local theMessages = { 'Message 1', 'Message 2', 'Message 3', 'Message 4', 'Message 5', 'Message 6' } setTimer(function() outputChatBox(theMessages[math.random(#theMessages)], root, mRed, mGreen, mBlue, true) end, 1000 * 60 * 5, 0)
Tete omar Posted November 25, 2013 Posted November 25, 2013 Well, it worked for me just fine, you'll just have to wait 5 minutes. edit: Also TAPLET's code didn't differ mine.
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