Forum

> > CS2D > Scripts > double chatting [SOLVED]
Forums overviewCS2D overview Scripts overviewLog in to reply

English double chatting [SOLVED]

11 replies
To the start Previous 1 Next To the start

old double chatting [SOLVED]

Salem97
User Off Offline

Quote
hello i madee a script for mod say and its work good but when i say something its be double chatting 1 chat is with script but 2nd one its just say as a normal player the code is here
1
2
3
4
5
6
7
8
9
modlist = {101022}
addhook("say","modsay")
function modsay(id,txt)
for _, usgn in ipairs(modlist) do
if player(id,'usgn') == usgn then
	msg("©000000255"..player(id,"name").." [Mod] "..txt)
end
end
end
hope u help me
edited 1×, last 18.04.15 11:12:10 pm

old Re: double chatting [SOLVED]

Talented Doge
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
modlist = {"101022"}
addhook("say","modsay")
function modsay(id,txt)
for _, usgn in ipairs(modlist) do
if player(id,'usgn') == usgn then
	msg("\169000000255"..player(id,"name").." [Mod] "..txt)
	return 1
end
end
end

In fact I would rather use a ranking table for checking players' rank.
edited 2×, last 17.04.15 01:20:00 pm

old Re: double chatting [SOLVED]

Ajmin
User Off Offline

Quote
Ofcourse it should work!
I mean yuki's code!
The problem might be u r using some other scripts which have a say hook!

Plse search before posting!

old Re: double chatting [SOLVED]

Talented Doge
User Off Offline

Quote
Just posting if you want to make the admin/mod system a better way.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
dir = "sys/lua/data/"
USGN = {}
ranking = {}

addhook("join", "_j")
addhook("say", "_s")

function _j(id)
	USGN[id] = player(id, "usgn")
	loaduser(id)
end

function loaduser(id)
	local file = io.open (dir..USGN[id]..".txt", "r")
	if file then
		local ranking_f = file:read ("*n")
		ranking[id] = ranking_f or 0
	else
		ranking[id] = 0
	end
end

function _s(p, t)
	if ranking[p] > 0 then
		msg("\169000000255"..player(p,"name").." [Mod] "..t)
		return 1
	end
end

This loads data from the directory specified in "dir".
And _s works similar to the code in the above comment.
edited 2×, last 17.04.15 01:31:07 pm

old Re: double chatting [SOLVED]

Salem97
User Off Offline

Quote
here we go the whole code
Spoiler >

old Re: double chatting [SOLVED]

Ajmin
User Off Offline

Quote
Ofcourse this is problem!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
adminlist = {}
modlist = {115684}

addhook("say","ranksay")
function ranksay(id,txt)
for _, usgn in ipairs(adminlist) do
if player(id,'usgn') == usgn then
     msg("©255000000"..player(id,"name").." [Admin] "..txt)
return 1
end
end
for _, usgn in ipairs(modlist) do
if player(id,'usgn') == usgn then
msg("©000000255"..player(id,"name").." [Mod] "..txt)
return 1
end
end
end

∗ Hook merged!

old Re: double chatting [SOLVED]

Mora
User Off Offline

Quote
Don't make double hooks -.-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
adminlist = {114940}
modlist = {}

addhook("say","adminsay")
function adminsay(id,txt)
		for _, usgn in ipairs(adminlist) do
			if player(id,'usgn') == usgn then
msg("\169255000000"..player(id,"name").." [Admin] "..txt)
return 1
			end
		end
		for _, usgnS in ipairs(modlist) do
			if player(id,'usgn') == usgnS then
msg("\169000000255"..player(id,"name").." [Mod] "..txt)
return 1
			end
		end
end

/Ajmin was faster, so - sorry for double.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview