Forum

> > CS2D > Scripts > Possibilities of making a mute for player script?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Possibilities of making a mute for player script?

21 replies
Page
To the start Previous 1 2 Next To the start

old Possibilities of making a mute for player script?

Talented Doge
User Off Offline

Quote
Yes, I know muting a player is freaking easy, but I want to know, if there are any possibilities of making a mute for specific player script? Means, for example, !mfm 1 let you mute id 1 for yourself but not for other players.

I've thought of it, but couldn't write one.

old Re: Possibilities of making a mute for player script?

Ajmin
User Off Offline

Quote
1
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

old Re: Possibilities of making a mute for player script?

eledah
User Off Offline

Quote
It is possible, you just need to use cs2d lua cmd msg2 in order to send messages.

1
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

old Re: Possibilities of making a mute for player script?

Ajmin
User Off Offline

Quote
1
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.

old Re: Possibilities of making a mute for player script?

eledah
User Off Offline

Quote
1
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.

old Re: Possibilities of making a mute for player script?

Ajmin
User Off Offline

Quote
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
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
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview