• Timed/Automatic Server Chat Text
    20 replies, posted
Hey Guys, So i want to make a script that automatically sends messages in the server chat, with [HELP] Laaaalaaallaaa . Something like that, and I have no idea where to start. Can you assist me please? Thanks, CharbelK.
-snip-
[QUOTE=JasonMan34;48140391]-snip-[/QUOTE] ??
[lua] timer.Create( "blah", 180, 0, function() //Run every 3 minutes forever RunConsoleCommand( "say", "adkasdjasdas" ); end ); [/lua]
Or use chat.AddText since you can have pretty colors and it's all clientside rather than being serverside for no reason. Same code as above, just replace RunConsoleCommand with [lua]chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." )[/lua] If you want a server only print then replace the chat.AddText with [lua]print( "Damnit right, it's better than yours" )[/lua] And make that shit serverside only, meaning no players will see it but you can see it in your server's console.
[QUOTE=Greetings;48140846][lua] timer.Create( "blah", 180, 0, function() //Run every 3 minutes forever RunConsoleCommand( "say", "adkasdjasdas" ); end ); [/lua][/QUOTE] Oh ok, i never knew you could put RunConsoleCommand("") in it. Thanks [editline]8th July 2015[/editline] [QUOTE=YourStalker;48141134]Or use chat.AddText since you can have pretty colors and it's all clientside rather than being serverside for no reason. Same code as above, just replace RunConsoleCommand with [lua]chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." )[/lua] If you want a server only print then replace the chat.AddText with [lua]print( "Damnit right, it's better than yours" )[/lua] And make that shit serverside only, meaning no players will see it but you can see it in your server's console.[/QUOTE] Yea. Could i put a timer on your code? So for example from this: [lua]chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." )[/lua] To This: [lua] timer.Create( chat.AddText, 180, 0, function() chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." ) end ); [/lua] or wouldn't that work?
[QUOTE=CharbelK;48144158]Oh ok, i never knew you could put RunConsoleCommand("") in it. Thanks [editline]8th July 2015[/editline] Yea. Could i put a timer on your code? So for example from this: [lua]chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." )[/lua] To This: [lua] timer.Create( chat.AddText, 180, 0, function() chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." ) end ); [/lua] or wouldn't that work?[/QUOTE] Just replace the first argument in the timer.Create function with a unique string (the identifer) instead of putting in a function and it should work okay. Just make sure it's clientside.
[QUOTE=AK to Spray;48144210]Just replace the first argument in the timer.Create function with a unique string (the identifer) instead of putting in a function and it should work okay. Just make sure it's clientside.[/QUOTE] So like this? [lua] timer.Create( AutoText, 180, 0, function() chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." ) end ); [/lua]
[QUOTE=CharbelK;48144244]So like this? [lua] timer.Create( AutoText, 180, 0, function() chat.AddText( Color( 255, 255, 255 ), "My milkshakes brings all the boys to the yard." ) end ); [/lua][/QUOTE] You need to make it a string by putting single or double quotes around it ([[ is more commonly used for multi-line quotes, although it will work). Right now it is trying to refer to a variable that does not exist.
[QUOTE=AK to Spray;48144291]You need to make it a string by putting single or double quotes around it ([[ is more commonly used for multi-line quotes, although it will work). Right now it is trying to refer to a variable that does not exist.[/QUOTE] Sorry, im new to lua. Could you give me an example? Would it be like: [lua] timer.Create( [[AutoText]], 180, 0, function() [/lua] ?
Yes, but you could also cast it. [CODE] -- Not cast to an alarm. stringNameMy = "AutoText" timer.Create( tostring( stringNameMy ), 180, 0, function() -- String has been cast to an alarm. . . . end ) [/CODE] [editline]7th July 2015[/editline] That way it's more secure from hacker attacks.
[QUOTE=circuitbawx;48144322]Yes, but you could also cast it. [CODE] -- Not cast to an alarm. stringNameMy = "AutoText" timer.Create( tostring( stringNameMy ), 180, 0, function() -- String has been cast to an alarm. . . . end ) [/CODE] [editline]7th July 2015[/editline] That way it's more secure from hacker attacks.[/QUOTE] Yea ok, seems simple now that i look at it. Thanks. Would this go in lua/autorun/client?
[QUOTE=CharbelK;48144362]Yea ok, seems simple now that i look at it. Thanks. Would this go in lua/autorun/client?[/QUOTE] Sure but this is simply supplemental to the stuff that someone said up there. There is no code to add the text to the chat... but now there is. Huzzah! Do this: [CODE] local colro = 255 stringNameMy = "AutoText" timer.Create( tostring( stringNameMy ), 180, 0, function() -- String has been cast to an alarm. chat.AddText( Color( tonumber( colro ), tonumber( colro ), tonumber( colro ) ), "My milkshakes brings all the boys to the yard." ) end ) [/CODE]
[QUOTE=circuitbawx;48144383]Sure but this is simply supplemental to the stuff that someone said up there. There is no code to add the text to the chat... but now there is. Huzzah! Do this: [CODE] local colro = 255 stringNameMy = "AutoText" timer.Create( tostring( stringNameMy ), 180, 0, function() -- String has been cast to an alarm. chat.AddText( Color( tonumber( colro ), tonumber( colro ), tonumber( colro ) ), "My milkshakes brings all the boys to the yard." ) end ) [/CODE][/QUOTE] I dont understand, what does the 'colro' point out? Then you mentioned it here again [lua]( Color( tonumber( colro ), tonumber( colro ), tonumber( colro ) )[/lua]
That's for security. The code works.
[QUOTE=circuitbawx;48144502]That's for security. The code works.[/QUOTE] Ok ill try this out, this is client side correct? so i make a text.lua file in lua/autorun/client ?
[QUOTE=CharbelK;48144551]Ok ill try this out, this is client side correct? so i make a text.lua file in lua/autorun/client ?[/QUOTE] circuitbawx is being a douche and playing off your lack of Lua knowledge. There isn't any reason to be using tostring and tonumber there, it does nothing for 'security' [lua] local color = Color(255,255,255) timer.Create( "AutoText", 180, 0, function() chat.AddText( color, "My milkshakes brings all the boys to the yard." ) end )[/lua] And yes it goes in lua/autorun/client
[QUOTE=wh1t3rabbit;48144746]circuitbawx is being a douche and playing off your lack of Lua knowledge. There isn't any reason to be using tostring and tonumber there, it does nothing for 'security' [lua] local color = Color(255,255,255) timer.Create( "AutoText", 180, 0, function() chat.AddText( color, "My milkshakes brings all the boys to the yard." ) end )[/lua] And yes it goes in lua/autorun/client[/QUOTE] Wow! ok thanks for that buddy. help alot
would this work? [lua] local color = Color(255,63,255) local color1 = Color(255,43,255) timer.Create( "AutoText", 30, 0, function() chat.AddText( color, "[HELP]"; color1,"The text here" ) end ) [/lua] ???
[QUOTE=CharbelK;48147951]would this work? [lua] local color = Color(255,63,255) local color1 = Color(255,43,255) timer.Create( "AutoText", 30, 0, function() chat.AddText( color, "[HELP]"; color1,"The text here" ) end ) [/lua] ???[/QUOTE] Change the semicolon after "[HELP]" to a comma, and it should be fine.
Ok thanks buddy so it would be like this: [lua] local color = Color(255,63,255) local color1 = Color(255,43,255) timer.Create( "AutoText", 30, 0, function() chat.AddText( color, "[HELP]", color1,"The text here" ) end ) [/lua]
Sorry, you need to Log In to post a reply to this thread.