English Random chat-not all msg...

5 replies
Goto Page
To the start Previous 1 Next To the start
21.04.14 04:57:42 pm
Up
Mora_rus
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
addhook("say","rainbow")
function rainbow(id,txt)
local r,g,b = math.random(0,255), math.random(0,255), math.random(0,255)
local special
for n=1, #string.len(txt) do
special=''..special..'©'..r..''..g..''..b..' '..string.sub(txt,n,n+1)..''
end
msg(""..player(id,"name").."[Owner]: "..special.."")
return 1
end


hello all, please, someone can fix that?
edited 1×, last 21.04.14 05:27:31 pm
21.04.14 05:28:44 pm
Up
Alpha Beta
User
Offline Off
Just wrote this for you:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("say","rainbow")
function rainbow(id,txt)
     if (player(id, "usgn") == 6681) then
          playername = string.char(169)..'255215100'..player(id,"name")..' [Owner]: '
          colortext = ''

          for i = 0, string.len(txt), 1 do
               local r = math.random(100,255)
               local g = math.random(100,255)
               local b = math.random(100,255)

               colortext = colortext..''..string.char(169)..''..r..''..g..''..b..''..string.sub(txt, i, i)
          end

          msg(playername..''..colortext)

          return 1
     end
end


You have to replace the USGN number, though.
But it has some bugs. Let me check.
edited 1×, last 21.04.14 05:39:17 pm
21.04.14 05:45:36 pm
Up
Mora_rus
User
Offline Off
@user Alpha Beta: thanks you, but one
sometimes message i writte just hide:
if i writte 1 symbol
if i writte 2 symbol`s
if i wri...
sometimes symbols copy:
if i writte "skrillex" then it will sometimes:
"krillex"
"sskrillex"
"skrillexx"
it work, but this just kill me, also my nickname is always yellow(+some white)
and i think better be:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
usertxt = {114940}

("say","rainbow")
function rainbow(id,txt)
     for _,user in ipairs(usertxt) do 
      if player(id,"usgn")==user then
          playername = string.char(169)..'255215100'..player(id,"name")..' [Owner]: '
          colortext = ''

          for i = 0, string.len(txt), 1 do
               local r = math.random(100,255)
               local g = math.random(100,255)
               local b = math.random(100,255)

               colortext = colortext..''..string.char(169)..''..r..''..g..''..b..''..string.sub(txt, i, i)
          end

          msg(playername..''..colortext)

          return 1
      end
     end
end
edited 1×, last 21.04.14 05:47:24 pm
21.04.14 05:46:07 pm
Up
Alpha Beta
User
Offline Off
Copy new code. And I think the msg function has a limit for the given string length, that's why it doesn't show parts of the msg when you write too long text. That sucks.
21.04.14 05:53:21 pm
Up
Mora_rus
User
Offline Off
@user Alpha Beta: thank you so much for help me, you`re good, i got it
edited 1×, last 21.04.14 06:10:57 pm
22.04.14 07:20:40 am
Up
MikuAuahDark
User
Offline Off
Code:
1
2
3
4
5
6
7
function RandomColor()
     return string.format("%03d%03d%03d",math.random(0,255),math.random(0,255),math.random(0,255))
end

msg("\169"..RandomColor().."Random color 1")
msg("\169"..RandomColor().."Random color 2")
msg("\169"..RandomColor().."Random color 3")
file cs2d LuaJIT for Dedicated Server (11) JIT POWER! | Know your Lua errors! | Draw stuff at Pixelize Art --xx-- server!
To the start Previous 1 Next To the start