Hey, I just suck with LuaSend functions..
I can't get this line to work
[lua]v:SendLua([[chat.AddText(Color(255,165,0), "(OOC)",]]ply:Name(), col2.. args[[)]])[/lua]
col2 = Players team color :)
Your strings are just kind of thrown in there. You need to actually do something with them:
[code]v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", "]] .. ply:Name() .. "\", Color( " .. col2.r .. "," .. col2.g .. "," .. col2.b .. "), \"" .. table.concat(args," ") .. "\"" )[/code]
I think that'll work. SendLua's a bitch to work with - I would use usermessages, especially since string injections mean you could easily crash everyone on the server with this.
I just played around with this in hours.. And I finally came to:
[lua]
v:SendLua([[chat.AddText(Color(255,165,0), "(OOC) "]]..ply:Name(), Color(255,255,255,255) , args..[[)]])
[/lua]
But it doesn't print a shit lol xD
EDIT: Testing your
EDIT 2:
[lua]v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", "]] .. ply:Name() .. "\", Color(255,255,255), \"" .. table.concat(args," ") .. "\"" )[/lua]
[code]
16:05:08 L 03/21/2010 - 15:05:03: Lua Error: ERROR: GAMEMODE:'PlayerSay' Failed: DarkRP\gamemode\main.lua:1504: bad argument #1 to 'concat' (table expected, got string)
16:05:08 L 03/21/2010 - 15:05:03: Lua Error: Error: hook->PlayerSay returned a non-string![/code]
It seems args is already a string, no need to table.concat it then.
Remove concat then?
If args is a string, then yes.
[code] :1: ')' expected near '<eof>' [/code]
[lua] v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", "]] .. ply:Name() .. "\", Color(255,255,255), \"" .. args .. "\"" ) [/lua]
This is what I get
[QUOTE=Blt950;20874967][code] :1: ')' expected near '<eof>' [/code]
[lua] v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", "]] .. ply:Name() .. "\", Color(255,255,255), \"" .. args .. "\"" ) [/lua]
This is what I get[/QUOTE]
What are you doing.
[lua] v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", ply:Name() .. "\"", Color(255,255,255), "\"" .. args .. "\"")]] ) [/lua]
[QUOTE=Vicis;20875126]What are you doing.
[lua] v:SendLua( [[chat.AddText( Color(255,165,0), "(OOC) ", ply:Name() .. "\"", Color(255,255,255), "\"" .. args .. "\"")]] ) [/lua][/QUOTE]
What are you doing?
Okey that works. But I'm sorry. I need help to insert the "col" (color code from players team)
into right after (OOC). Then I'll be done :D
And yes, it's right.. SendLua is a pain of ass :S
It's a variable
local col = team.GetColor(ply:Team())
Then it has to be outside the " " i think
It is.
So I replace Color() there you placed it with "col" And i'm done?
[lua]v:SendLua("chat.AddText( Color(255,165,0), \"(OOC)\", col, \""..ply:Name().." \", Color(255,255,255), \""..args.."\")")[/lua]
That doesn't work. Since col is defined "outside" the SendLua. In the line right over it
No, you just use the code I gave you.
[editline]04:34PM[/editline]
[lua]local col = team.GetColor(ply:Team())
v:SendLua("chat.AddText( Color(255,165,0), \"(OOC)\", Color("..col.r..", "..col.g..", "..col.b..", "..col.a.."), \""..ply:Name().." \", Color(255,255,255), \""..args.."\")")[/lua]
Okey, I test. But just so you know, I haven't defined any color.g etc
Edit: WORKED! Haha xD Thank you all :D
You're welcome.
Sorry, you need to Log In to post a reply to this thread.