• DarkRP module: /rp (text) displays a coloured message
    2 replies, posted
My purpose is to send a coloured message to everyone using the teamcolor an a yellow color for the message itself. My current code looks like this: local function writeRPMessage(ply, text, team) if starts_with(text, "/rp ") then PrintMessage(3, "(RP) " .. ply:GetName() .. ": " .. string.sub(text, 5)) end end local function starts_with(str, start) return str:sub(1, #start) == start end hook.Add( "PlayerSay", "writeRPMessage", writeRPMessage) I want to have the printed message be coloured but I dont know how I should colour messages?
chat.AddText() allows you to send color like this: chat.AddText(Color(R,G,B), "text here"); Just network that and send it to all players.
I already did it a different way. I wanted to use the server side functionality's. Here is my code for all other people here that could make use of it: local function starts_with(str, start) return str:sub(1, #start) == start end local function writeRPMessage(ply, text, gameteam) if starts_with(text, "/rp ") then if team.GetName(ply:Team()) ~= "Teammitglied im Dienst" then for k,v in pairs(player.GetAll()) do v:PlayerMsg(Color(team.GetColor(ply:Team())["r"], team.GetColor(ply:Team())["g"], team.GetColor(ply:Team())["b"], 255),"(RP) " .. ply:GetName(),Color(255,255,0),": " .. string.sub(text, 5)) end else ply:PrintMessage(3, "Als Teammitglied kannst du dich nicht ins RP einbinden!") end return "" end end hook.Add( "PlayerSay", "writeRPMessage", writeRPMessage)
Sorry, you need to Log In to post a reply to this thread.