I've thought of it, but couldn't write one.
Forum
CS2D Scripts Possibilities of making a mute for player script?Possibilities of making a mute for player script?
21 repliesI've thought of it, but couldn't write one.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
muted={} addhook("say","s") function s(id,txt) if txt:lower():sub(1,5) == "!mute" then if player(id,"usgn")==your usgn id then m = txt:sub(6) muted[m]=1 if muted[id]==1 then 		msg2(id,"©255000000You are muted@C") 		return "1" 	 end 	end end end
edited 1×, last 01.04.15 12:46:56 pm
Anyway i will worth a try
I tried much but gives error.
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
-- Preview muted_ones = {{3},{1,3},{1}} addhook("say", "_say") function _say(id, msg) 	for _, i in pairs(player(0,"table")) do 		for j = 1, #muted_ones[id] do 			if muted_ones[id][j] ~= i then msg2(i, "ID#"..id.." said: "..msg) end 		end 	end 	return 1 end
There is an array allocated to each player, which contains those IDs he's muted
edited 1×, last 01.04.15 01:26:40 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
muted={} addhook("say","s") function s(id,txt) if txt:lower():sub(1,5) == "!mute" then m = txt:sub(6) muted[m]=id end if muted[id]>0 then msg2(Exept muted ids value,"player(id,"name" "..txt) return "1" end end idk how to get players id exept muted id. Plse add it if u know.
Edit: Ryal already helped u.
So dnt care.
@ Ajmin, I know, but I wanted the muted[id] can be modified with unlimited length...
Possibly using initarray? I know nothing about arrays
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
muted_ones = {{3},{1},{1}} addhook("say", "_say") function _say(id, msg) for _, i in pairs(player(0,"table")) do 	if not _is_muted(i, id) then msg2(i, msg) end end return 1 end -- if A is muted by B function _is_muted(B, A) 	for j = 1, #muted_ones[B] do 		if muted_ones[B][j] == A then return true end 	end 	return false end
All you need to do now is to create a commands table which allows you to edit "muted_ones". !mute <id>, !unmute<id>, etc.
1
muted_ones = {{3},{1},{1}}
1
2
3
4
5
6
2
3
4
5
6
muted_ones = { {3,5,12,17}, <--ID#1 has muted these ones {1,5,8}, <--ID#2 has muted these ones {}, <-- ID#3 has muted no one ...And so on }
so this one means, id 1 muted id 3, id 2 and 3 muted id 1?
But i hoped the player who was ignored may get unignored too.
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
29
30
31
32
33
34
35
36
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
29
30
31
32
33
34
35
36
colorTeam = {"\169255000000", "\169015020200"} -- Edit it, I don't know the team colors perfectly (I have a file about them somewhere in my PC but I'm lazy to search) colorNormal = "\169128128000" -- Same here ignorelist = {} for current = 1, 32 do ignorelist[current] = {} end addhook("say", "_") function _(id, text) 	if text:sub(1, 7) == "!ignore" then 		local target = tonumber(text:sub(9)) 		table.insert(ignorelist[id], target) 		return 1 	end 	if text:sub(1, 7) == "!listen" then 		local target = tonumber(text:sub(9)) 		for _, ignored in ipairs(ignorelist[id]) do 			if ignored == target then table.remove(ignorelist[id], _) break end 			if _ == #ignorelist then msg2(id, colorTeam[1].."Error, target not found") end 		end 		return 1 	end 	for _, current in ipairs(player(0, "table")) do 		if player(id, "health") > 0 then 			local ignore = false 			for __, target in ipairs(ignorelist[current]) do if target == id then ignore = true break end end 			if not ignore then msg2(current, colorTeam[player(id, "team")]..player(id,"name")..": "..colorNormal..text) end 		elseif player(current, "health") < 0 then 			local ignore = false 			for __, target in ipairs(ignorelist[current]) do if target == id then ignore = true break end end 			if not ignore then msg2(current, colorTeam[player(id, "team")]..player(id,"name").." (DEAD): "..colorNormal..text) end 		end 	end 	return 1 end
Thanks to _Yank
edited 1×, last 01.04.15 03:55:02 pm
Thank eledah and Infinite Rain