Forum

> > CS2D > Scripts > saycolor can be on/off
Forums overviewCS2D overview Scripts overviewLog in to reply

English saycolor can be on/off

11 replies
To the start Previous 1 Next To the start

old saycolor can be on/off

ReVoltage
User Off Offline

Quote
hello us player
i want to make say color lua, but able to on/off,
example :
when i say "!say off" then the say color is off,and when i say "!say on" then the say color is on.
can anyone make it for me?
thx before

old Re: saycolor can be on/off

EP
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
colors = {}
for i = 1,32 do
	colors[i] = false
end

addhook("join","_join")
function _join(id)
	colors[id] = false
end

addhook("say","_say")
function _say(id,txt)	
	if txt:sub(1,1) == "!" then	
		if txt:lower():sub(2,4) == "say" then
			local p = txt:lower():sub(6,8)
			if p == "on" then
				colors[id] = true
				msg2(id,"Color message activated")
			elseif p == "off" then
				colors[id] = false
				msg2(id,"Color message deactivated")
			end
			return 1
		end
	else
		if colors[id] == true then
			msg("©255255255"..player(id,"name")..": "..txt)
			return 1
		end
	end
end

Works perfect

old Re: saycolor can be on/off

sheeL
User Off Offline

Quote
Soon i make one script to you
i removed because I'll shorten it
edited 2×, last 13.12.12 02:10:34 am

old Better

Gajos
BANNED 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
admins = {108942};
Colors = {
	[1] = "255000000";
	[2] = "255100000";
	[3] = "000000255";
	[4] = "000255000";
	[5] = "000000000";
	[6] = "255255255";
	[7] = "255255000";
};


colors = {};
Player = {};
addhook("join","onJoin")
function onJoin(id)
	Player[id] = {};
	Player[id].color = 0;
end

addhook("serveraction","onServeraction")
function onServeraction(id, key)
	for _, i in ipairs(admins) do
		if player(id,"usgn") == i then
			if key == 1 then
				menu(id,"Select color,Red Color,Orange color,Blue Color,Green Color,Black Color,White Color,Neutral Color,Disable")
			end
		end
	end
end

addhook("menu","onMenu")
function onMenu(id, t, b)
	if t == "Select color" then
		if b > 0 and b < 8 then
			Player[id].color = b;
		elseif b == 8 then
			Player[id].color = 0;
		end
	end
end

addhook("say","onSay",1)
function onSay(id, txt)
	for _, i in ipairs(admins) do
		if player(id,"usgn") == i then
			if Player[id].color ~= 0 then
				msg("©".. Colors[Player[id].color] .. player(id,"name") .." [Admin]: ".. txt);
				return 1;
			end
		end
	end
end

old Re: saycolor can be on/off

sheeL
User Off Offline

Quote
user EP has written
@user sheeL: Check your serveraction function, dude. Also, there are many ways to shorten your code


Looks, I got on the internet ...

PS = Evening'll edit and make a better script
edited 1×, last 12.12.12 09:06:33 pm

old Re: saycolor can be on/off

ReVoltage
User Off Offline

Quote
@user EP: thx for the script man, works everytime
but can i hide the !say ?
so when i type "!say on" it wont be visible to all player?
sorry im noob of lua, only can edit lua

old Re: saycolor can be on/off

Gajos
BANNED Off Offline

Quote
user ReVoltage has written
@user EP: thx for the script man, works everytime
but can i hide the !say ?
so when i type "!say on" it wont be visible to all player?
sorry im noob of lua, only can edit lua

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
command == "!say";

player = {};
addhook("join","_join")
function _join(id)
	player[id] = {};
	player[id].text = true;
end

addhook("say","_say")
function _say(id, txt)
	if txt == command then
		if not player[id].text then
			player[id].text = true;
			msg2(id,"©000255000Color message activated");
		else
			player[id].text = false;
			msg2(id,"©255000000Color message deactivated");
		end
		return 1;
	elseif player[id].text then
		msg("©255255255"..player(id,"name")..": "..txt);
		return 1;
	end
end

If you have question, ask me then I help you.
cs2d lua hook say
edited 3×, last 13.12.12 10:45:17 pm

old Re: saycolor can be on/off

sheeL
User Off Offline

Quote
user ReVoltage has written
@user EP: thx for the script man, works everytime
but can i hide the !say ?
so when i type "!say on" it wont be visible to all player?
sorry im noob of lua, only can edit lua


@user ReVoltage: I tested the script, and does not appear in chat , because he used "return 1", Do not mix with other script, why we advise you to use menu

@user Gajos: Your script don't works, have many error


@user ReVoltage: This Works
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
command = "!say";
admins = {45813,xxxxx}; -- YOUR USGN ID HERE
color = {};

addhook("join","Onjoin")
function Onjoin(id)
     color[id] = 0;
end;

addhook("say","OnSay")
function OnSay(id,txt)
for _, k in ipairs(admins) do
  if player(id,"usgn") == k then
     if txt:lower() == ""..command.." on" then
      color[id]=1;
      msg2(id,"©000255000Say Color Enabled");
    return 1;
        elseif txt:lower() == ""..command.." off" then
        color[id]=0;
        msg2(id,"©255000000Say Color Disabled");
     return 1;
         elseif color[id] == 1 then
             msg("©255255255"..player(id,"name").."/Admin/ : "..txt);
                return 1;
             end;
         end;
    end;
end
edited 4×, last 13.12.12 11:52:36 pm

old Re: saycolor can be on/off

Gajos
BANNED Off Offline

Quote
user ReVoltage has written
@user EP: and @user sheeL: thx to you two guys
you are the best

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
command = "!say";

Player = {};
addhook("join","_join")
function _join(id)
	Player[id] = {};
	Player[id].text = true;
end

addhook("say","_say")
function _say(id, txt)
	if txt == command then
		if not Player[id].text then
			Player[id].text = true;
			msg2(id,"©000255000Color message activated");
		else
			Player[id].text = false;
			msg2(id,"©255000000Color message deactivated");
		end
		return 1;
	elseif Player[id].text then
		msg("©255255255"..player(id,"name")..": "..txt);
		return 1;
	end
end

old Re: saycolor can be on/off

sheeL
User Off Offline

Quote
user Gajos has written
user ReVoltage has written
@user EP: and @user sheeL: thx to you two guys
you are the best

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
command = "!say";

Player = {};
addhook("join","_join")
function _join(id)
	Player[id] = {};
	Player[id].text = true;
end

addhook("say","_say")
function _say(id, txt)
	if txt == command then
		if not Player[id].text then
			Player[id].text = true;
			msg2(id,"©000255000Color message activated");
		else
			Player[id].text = false;
			msg2(id,"©255000000Color message deactivated");
		end
		return 1;
	elseif Player[id].text then
		msg("©255255255"..player(id,"name")..": "..txt);
		return 1;
	end
end


@user Gajos: , the issue has already been resolved because still posting?
@user ReVoltage: if you need help, send pm to me...
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview