Forum

> > CS2D > Scripts > custom color when player say
Forums overviewCS2D overview Scripts overviewLog in to reply

English custom color when player say

5 replies
To the start Previous 1 Next To the start

old custom color when player say

massiveguy
User Off Offline

Quote
i need script which if player say @color 255000000 then his chat message color will be change to Red. like this one is this really hard to make?
i tried to make it but i have no idea to make it. please help me.

old Re: custom color when player say

Avo
User Off Offline

Quote
How about this one:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Color = {}
addhook("say", "HookSay")
HookSay = function (id, txt)
	if txt:sub(1, 6) == "@color" then
		local clr = tostring(txt:sub(8,17))
		if #clr == 9 then
			Color[id] = clr
			msg2(id, "Color has been changed!")
		else
			msg2(id, "Color is wrong!")
		end
	else
		msg((Color[id] and "\169"..Color[id] or "")..player(id, "name")..": "..txt)
	end
	return 1
end

old Lua Methodology

KimKat
GAME BANNED Off Offline

Quote
function TColor(t,c,m,C)
     t=t or '';c=c or '000000000';C=C or '@C'
     if (m==0) then
          return "\169"..c..t..C
     elseif (m==1) then
          return (string.char(169))..c..t..C
     else
          return "\xA9"..c..t..C
     end
end
t="Text message";c=255255255
print (TColor()) -- ©000000000
print (TColor(t)) -- ©000000000Text message
print (TColor(t,c)) -- ©255255255Text message
print (TColor(t,c,0)) -- ©255255255Text message
print (TColor(t,c,1)) -- ©255255255Text message
print (TColor(t,c,1,"")) -- ©255255255Text message

I coded this to attach text color to text via 3 methods, merry christmas.

old Thanks You

Kantos
BANNED Off Offline

Quote
Thanks KitKat for merry christmas , need 2 days and Christmas coming to our Country

old Re: custom color when player say

mafia_man
User Off Offline

Quote
@user KimKat:
Your code is not going to work properly.
1
2
3
t="Text message"
c=001255255
print (TColor(t,c))
Result:
1
©1255255Text message@C
It should be:
1
©001255255Text message@C
Use quotes on variable c value:
1
2
3
t="Text message"
c="001255255"
print (TColor(t,c))
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview