Forum

> > CS2D > Scripts > Server MSG - Help.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Server MSG - Help.

6 replies
To the start Previous 1 Next To the start

old Server MSG - Help.

Cirium
User Off Offline

Quote
Hai all.

I was wondering,
I have a server MSG that comes up every minute, saying its my server.


1
2
3
4
addhook("minute","msjes")
function msjes()
        msg("©222111000Have Fun on my server!")
end

but, I was wondering would it be possible to have this text somewhere in a TXT file, where I could change it at any time and it would change in the server.

or is this not possible.

-Id appreciate any replies, thx u.

old Re: Server MSG - Help.

Hanz
User Off Offline

Quote
use this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if sample==nil then sample={} end
sample.ads={}

--------------------------------------
-- WELCOME MESSAGE ON JOIN          --
--------------------------------------
addhook("join","sample.ads.join")
function sample.ads.join(p)
	msg2(p,"Your message, "..player(p,"name").."!")
end

--------------------------------------
-- ADVERTISING EVERY MINUTE         --
--------------------------------------
addhook("minute","sample.ads.minute")
function sample.ads.minute()
	msg("Your message")
	msg("Your message")
end

old Re: Server MSG - Help.

Cirium
User Off Offline

Quote
Yes, I realize that, but Im finding it complicated on how to put the text in a .txt file, and have it show per minute?

old Re: Server MSG - Help.

Geez
GAME BANNED Off Offline

Quote
Look at e.g. Zombie Plague or NPC vs Zombies LUA scripts, and do it similar

old Re: Server MSG - Help.

DannyDeth
User Off Offline

Quote
Well, here is a basic one which should get the job done:
1
2
3
4
5
6
name_of_text_file = "my_text" -- Do not include '.txt', the script does that for you!
text_file = io.open("sys/lua/"..name_of_txt_file..".txt",r)
addhook("minute","server_message")
function server_message()
	msg(text_file.read("*all")
end
NOTE: Replace "my_text" in the variable name_of_text_file with the name. DO NOT INCLUDE '.txt' ON THE END! THE SCRIPT DOES THAT FOR YOU!

old Re: Server MSG - Help.

Banaan
User Off Offline

Quote
1
2
3
4
5
6
7
name_of_text_file = "my_text" -- Do not include '.txt', the script does that for you!
addhook("minute","server_message")
function server_message()
	for line in io.lines(name_of_text_file .. ".txt") do
		msg(line)
	end
end

A small alteration which will also allow multiple lines.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview