• Need some help
    13 replies, posted
Im editing some of DarkRP for my server im getting and i cant figure out how to change the color of a certain part of this: this is what im trying to do [lua] TalkToPerson(v, col2, "(AllTalk) ", col,..ply:Name(), col2, text, ply) [/lua] I know why that wont work but i don't know what to do to make it work :( Here is some of the surrounding code. Code: [lua] local function OOC(ply, args) if GetConVarNumber("ooc") == 0 then Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "OOC", "")) return "" end local DoSay = function(text) if text == "" then return "" end local col = team.GetColor(ply:Team()) local col2 = Color(255,255,255,255) if not ply:Alive() then col2 = Color(255,200,200,255) col = col2 end for k,v in pairs(player.GetAll()) do TalkToPerson(v, col, "(AllTalk) "..ply:Name(), col2, text, ply) end end return args, DoSay end [/lua] this was all taken from the main.lua of DarkRP. Also how do i make a code box on here ?
For code boxes, well lua boxes, use [ lua] and [ /lua]
Thanks. Any one got anything on the other part?
[QUOTE=pyroboytodumax;23358809]Im editing some of DarkRP for my server im getting and i cant figure out how to change the color of a certain part of this: this is what im trying to do [lua] TalkToPerson(v, col2, "(AllTalk) ", col,..ply:Name(), col2, text, ply) [/lua] I know why that wont work but i don't know what to do to make it work :( Here is some of the surrounding code. Code: [lua] local function OOC(ply, args) if GetConVarNumber("ooc") == 0 then Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "OOC", "")) return "" end local DoSay = function(text) if text == "" then return "" end local col = team.GetColor(ply:Team()) local col2 = Color(255,255,255,255) if not ply:Alive() then col2 = Color(255,200,200,255) col = col2 end for k,v in pairs(player.GetAll()) do TalkToPerson(v, col, "(AllTalk) "..ply:Name(), col2, text, ply) end end return args, DoSay end [/lua] this was all taken from the main.lua of DarkRP. Also how do i make a code box on here ?[/QUOTE] [lua] TalkToPerson(v, [b]col2[/b], "(AllTalk) ", [b]col[b],..ply:Name(), col2, text, ply) [/lua] col2 is the white colour of the players text. col is the colour of the players team Above that it sets col2 and col: [lua] local col = team.GetColor(ply:Team()) local col2 = Color(255,255,255,255) [/lua] In the code change those variables to what you want the colours to be.
I know that but the thing is that i want the "(AllTalk)" part to be white (col2) and the name to be the team color (col) and then the text to be white again (col2).
[QUOTE=pyroboytodumax;23370270]I know that but the thing is that i want the "(AllTalk)" part to be white (col2) and the name to be the team color (col) and then the text to be white again (col2).[/QUOTE] That's slightly more difficult, you'd have to edit the TalkToPerson and DarkRPChat functions as well to have the third colour in them, is there a problem with just having (AllTalk) PlayersName all as the team colour then the text white?
Thats how it is now im just trying to customize it a little more. I dont HAVE to have it. im sure i can get along fine without it. would it be any easyer to add something on to the end in the team name color?
Ok. Well i found the function. [lua] function TalkToPerson(receiver, col1, text1, col2, text2, sender) umsg.Start("DarkRP_Chat", receiver) umsg.Short(col1.r) umsg.Short(col1.g) umsg.Short(col1.b) umsg.String(text1) if sender then umsg.Entity(sender) end if col2 and text2 then umsg.Short(col2.r) umsg.Short(col2.g) umsg.Short(col2.b) umsg.String(text2) end umsg.End() end [/lua] not sure how to edit that though
Okay, use this as the OOC function: [lua] local function OOC(ply, args) if GetConVarNumber("ooc") == 0 then Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "OOC", "")) return "" end local DoSay = function(text) if text == "" then return "" end local col = team.GetColor(ply:Team()) local col2 = Color(255,255,255,255) if not ply:Alive() then col2 = Color(255,200,200,255) col = col2 end for k,v in pairs(player.GetAll()) do TalkToPerson(v, col, ply:Name(), col2, text, ply) end end return args, DoSay end [/lua] Then in cl_init.lua, line 997 should be the AddToChat function, replace it with this: [lua] local function AddToChat(msg) local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local name = msg:ReadString() local ply = msg:ReadEntity() local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local text = msg:ReadString() if text and text ~= "" then chat.AddText(col2, "(AllTalk) ", col1, name, col2, ": "..text) if ValidEntity(ply) then hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive()) end else chat.AddText(col1, name) hook.Call("ChatText", GM, "0", name, name, "none") end chat.PlaySound() end usermessage.Hook("DarkRP_Chat", AddToChat) [/lua] That should work. Sorry I didn't think of this before, it's actually way simpler than I first made it out to be, I'd just got up xD
Ok. Thanks ill give that a try. [editline]05:58PM[/editline] Thanks a tone :D it works perfect.
[QUOTE=pyroboytodumax;23382874]Ok. Thanks ill give that a try. [editline]05:58PM[/editline] Thanks a tone :D it works perfect.[/QUOTE] No problem =]
One thing i just noticed is that it does it when you use all types of chat not just "AllTalk" or "OOC" :(
[QUOTE=pyroboytodumax;23386416]One thing i just noticed is that it does it when you use all types of chat not just "AllTalk" or "OOC" :([/QUOTE] Okay, try this: (I presume you know where each function goes by now..) [lua] local function AddToChat(msg) local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local name = msg:ReadString() local ply = msg:ReadEntity() local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort()) local text = msg:ReadString() local isooc = msg:ReadBool() if text and text ~= "" then if isooc then chat.AddText(col2, "(AllTalk) ", col1, name, col2, ": "..text) else chat.AddText(col1, name, col2, ": "..text) end if ValidEntity(ply) then hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive()) end else chat.AddText(col1, name) hook.Call("ChatText", GM, "0", name, name, "none") end chat.PlaySound() end usermessage.Hook("DarkRP_Chat", AddToChat) local function OOC(ply, args) if GetConVarNumber("ooc") == 0 then Notify(ply, 1, 4, string.format(LANGUAGE.disabled, "OOC", "")) return "" end local DoSay = function(text) if text == "" then return "" end local col = team.GetColor(ply:Team()) local col2 = Color(255,255,255,255) if not ply:Alive() then col2 = Color(255,200,200,255) col = col2 end for k,v in pairs(player.GetAll()) do TalkToPerson(v, col, ply:Name(), col2, text, ply, true) end end return args, DoSay end function TalkToPerson(receiver, col1, text1, col2, text2, sender, isooc) umsg.Start("DarkRP_Chat", receiver) umsg.Short(col1.r) umsg.Short(col1.g) umsg.Short(col1.b) umsg.String(text1) if sender then umsg.Entity(sender) end if col2 and text2 then umsg.Short(col2.r) umsg.Short(col2.g) umsg.Short(col2.b) umsg.String(text2) umsg.Bool( isooc ) end umsg.End() end [/lua]
Yup that works perfectly :) thanks a bunch
Sorry, you need to Log In to post a reply to this thread.