John_Scott Posted November 25, 2013 Share 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! Link to comment
Tete omar Posted November 25, 2013 Share Posted November 25, 2013 setTimer math.random outputChatBox And use a table for texts. Link to comment
codeluaeveryday Posted November 25, 2013 Share 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. Link to comment
John_Scott Posted November 25, 2013 Author Share 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! Link to comment
codeluaeveryday Posted November 25, 2013 Share Posted November 25, 2013 You are welcome John! If you ever need a paid scripter, just add me on skype: chrisinater22. Link to comment
John_Scott Posted November 25, 2013 Author Share 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. Link to comment
Tete omar Posted November 25, 2013 Share 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 ) Link to comment
John_Scott Posted November 25, 2013 Author Share 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? Link to comment
Tete omar Posted November 25, 2013 Share Posted November 25, 2013 Are you sure you put it client-side? Link to comment
John_Scott Posted November 25, 2013 Author Share Posted November 25, 2013 I want to this on server-side Link to comment
Tete omar Posted November 25, 2013 Share 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 ) Link to comment
John_Scott Posted November 25, 2013 Author Share Posted November 25, 2013 Doesn't work... Link to comment
TAPL Posted November 25, 2013 Share 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) Link to comment
John_Scott Posted November 25, 2013 Author Share Posted November 25, 2013 Not working... Link to comment
Tete omar Posted November 25, 2013 Share 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. Link to comment
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