sup u doods
i need help about my chatbox..
i want to make my chatbox support darkrp prefix, i mean to show (OOC) (yell) tags in the chat
heres the full code
[CODE]if SERVER then AddCSLuaFile() return end
local oldCF = surface.CreateFont
function surface.CreateOldFont( font_name, osize, oweight, aa, oadditive, new_font_name, drop_shadow, outlined, oblur, scanline )
oldCF( new_font_name, { font = font_name, size = osize, weight = oweight, antialias = aa or false, additive = oadditive, shadow = drop_shadow or false, outline = outlined or false, blursize = oblur or 0, scanlines = scanline or 0 } )
end
function surface.CreateFont( font_name, osize, oweight, aa, oadditive, new_font_name, drop_shadow, outlined, oblur, scanline )
if type(osize) == "number" then
return surface.CreateOldFont( font_name, osize, oweight, aa, oadditive, new_font_name, drop_shadow, outlined, oblur, scanline )
else
return oldCF( font_name, osize )
end
end
surface.CreateFont( "Trebuchet18",
{
font = "Trebuchet MS",
size = 20,
weight = 300,
antialias = true,
shadow = false
})
function DrawText( text, font, x, y, col, align1, align2 )
draw.SimpleText( text, font, x, y, col, align1, align2 )
end
local chatshow = false
local history = {}
local spacing = 20
local chatmessage = ""
function textsize(t, f) local w = surface.GetTextSize(t, f); return w; end
local function SendText(text, msg)
local hist = {
Text = text,
Time = RealTime()+7,
Msg = msg
}
table.insert( history, 1, hist )
table.remove( history, 21 )
end
local y = ScrH()-130
local x = 150
hook.Add("HUDPaint", "ChatPaint", function()
for k, v in pairs( history ) do
if v.Time > RealTime() or chatshow then
DrawText(v.Text, "Trebuchet18", x+1, (y-k*spacing)+1, Color(0, 0, 0, 255), TEXT_ALIGN_LEFT)
DrawText(v.Text, "Trebuchet18", x, y-k*spacing, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)
DrawText(v.Msg, "Trebuchet18", x+1, (y-k*spacing)+1, Color(0, 0, 0, 255), TEXT_ALIGN_RIGHT)
DrawText(v.Msg, "Trebuchet18", x, y-k*spacing, Color(0, 195, 25, 255), TEXT_ALIGN_RIGHT)
else
end
end
if chatshow then
draw.RoundedBox(0, x-67, y+4, 60, 20, Color( 25, 25, 25, 255 ))
surface.SetDrawColor( 25, 25, 25, 255 )
surface.SetTexture(surface.GetTextureID("gui/gradient"))
surface.DrawTexturedRect(x+489, y+4, 100, 20)
draw.RoundedBox(0, x-9, y+4, 499, 20, Color( 25, 25, 25, 255 ))
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetTexture(surface.GetTextureID("gui/gradient"))
surface.DrawTexturedRect(x+489, y+5, 100, 18)
draw.RoundedBox(0, x-9, y+5, 498, 18, Color( 255, 255, 255, 255 ))
DrawText( "Chat>", "Trebuchet18", x-20, y+5, Color( 255, 255, 255, 255 ), TEXT_ALIGN_RIGHT )
DrawText( chatmessage, "Default", x-7, y+8, Color( 25, 25, 25, 255 ), TEXT_ALIGN_LEFT )
end
end)
hook.Add("OnPlayerChat", "PlayerChat", function( pl, text, teamtext, alive, ulx )
if (IsValid(pl)) then
SendText(text, pl:Nick().."> ")
else
SendText(text, "JcChatbox>> ")
end
end)
hook.Add("ChatText", "ChatText", function( filter, name, text, ulx )
if (filter == 0) then
SendText(text, "JcChatbox>> ")
end
end)
hook.Add("StartChat", "StartChat", function() chatshow = true return true end)
hook.Add("FinishChat", "FinishChat", function() chatshow = false return true end)
hook.Add("ChatTextChanged", "TextChanged", function(text) chatmessage = text end)
if (SERVER) then
AddCSLuaFile()
local Tag = ""
local R = 0
local G = 0
local B = 0
function CustomChat_ChatMessage( name, String, bool, R, G, B) -- ChatMessage(rgb, name, rgb2, String)
umsg.Start( "CustomChat_ChatMsg" )
umsg.String(name)
umsg.String(String)
umsg.String(bool)
umsg.Long(R)
umsg.Long(G)
umsg.Long(B)
umsg.End()
end
concommand.Add( "chat_alert", function( ply, cmd, args )
if args[1] then // We're seeing if there are any arguments, arguments are stored on a table, so you will have to use args[index].
if ply:IsAdmin() then
CustomChat_ChatMessage( "ALERT", "> "..string.gsub(args[1], "_", " "), "" , 255, 0, 0)
else
ply:PrintMessage(HUD_PRINTCONSOLE,"You are not Admin")
Msg("--Player "..ply:Nick().." is not admin and tryed to use alert chat.\n")
end
end
end )
function CustomChat_Checker( ply, text, teamonly )
--/*
if ply:IsUserGroup("MOD") then
Tag = "[Mod]"
R = 0
G = 255
B = 0
elseif ply:IsVIP() then
Tag = "[Vip]"
R = 255
G = 255
B = 0
elseif ply:IsSuperAdmin() then
Tag = "[SuperAdmin]"
R = 255
G = 0
B = 0
elseif ply:IsAdmin() then
Tag = "[Admin]"
R = 0
G = 255
B = 255
elseif ply:IsUserGroup("Owner") then
Tag= "[Owner]"
R = 255
G = 0
B = 255
elseif ply:IsUserGroup("M-VIP") then
Tag = "[MVip]"
R = 189
G = 15
B = 255
elseif ply:IsUserGroup("T-VIP") then
Tag = "[TVip]"
R = 77
G = 83
B = 85
end
--*/
/*
if ply:IsSuperAdmin() then
Tag = "[Admin]"
R = 255
G = 0
B = 0
elseif ply:IsAdmin() then
Tag = "[Mod]"
R = 0
G = 206
B = 209
elseif ply:IsUserGroup("vip") then
Tag = "[Vip]"
R = 0
G = 0
B = 255
else
Tag = "[User]"
R = 238
G = 221
B = 130
end
*/
CustomChat_ChatMessage(ply:Nick(), "> "..text, Tag, R, G, B)
return ""
end
hook.Add("PlayerSay", "WordCheck", CustomChat_Checker)
------------------------------------------
else --- client code --
------------------------------------------
usermessage.Hook("CustomChat_ChatMsg", function( um, ply )
local name = um:ReadString()
local String = um:ReadString()
local Tag = um:ReadString()
local R = um:ReadLong()
local G = um:ReadLong()
local B = um:ReadLong()
chat.AddText(Color(R, G, B, 255), Tag..name, Color(255, 255, 255, 255), String)
end)
end-- final end[/CODE]
i dont really know what to add/remove i tried to remove/edit some code about my player tags and few functions but its still not working
(i have 0 experience about darkrp stuff)
I'm pretty sure DarkRP handles this itself. Just don't return in the OnPlayerChat hook.
[QUOTE=code_gs;48137397]I'm pretty sure DarkRP handles this itself. Just don't return in the OnPlayerChat hook.[/QUOTE]
eh yea its not working.. i heard i have to add something spacial to make it work right
[IMG]http://images.akamai.steamusercontent.com/ugc/436071025131184337/8520C8E7DB9F3A567298DB54041D66430942D10F/[/IMG]
[IMG]http://images.akamai.steamusercontent.com/ugc/436071025131184692/F914676485DF177D78FE26AC2D2DD6B7D2352F5B/[/IMG]
help?
Sorry, you need to Log In to post a reply to this thread.