ULX

Author Topic: ulx massages wont show (prefix)  (Read 1465 times)

0 Members and 1 Guest are viewing this topic.

Offline PizzaDox

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
ulx massages wont show (prefix)
« on: October 09, 2015, 02:57:07 PM »
hey
you know when open up the team chat and type @ <massage> to type something to the admins? so the massages wont show in the chat, but you can see them thru the console
well i dont know why but i cant get my chat to read the ulx massages can you help me with that? (i marked the code that maybe related to this)


if SERVER then AddCSLuaFile() return end

surface.CreateFont( "Trebuchet21",
                    {
                    font    = "Trebuchet MS",
                    size    = 21,
                    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()-145
local x = 250
hook.Add("HUDPaint", "ChatPaint", function()
for k, v in pairs( history ) do
   if v.Time > RealTime() or chatshow then
      DrawText(v.Text, "Trebuchet21", x+1, (y-k*spacing)+1, Color(0, 0, 0, 255), TEXT_ALIGN_LEFT)
      DrawText(v.Text, "Trebuchet21", x, y-k*spacing, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT)

      DrawText(v.Msg, "Trebuchet21", x+1, (y-k*spacing)+1, Color(0, 0, 0, 255), TEXT_ALIGN_RIGHT)
      DrawText(v.Msg, "Trebuchet21", 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>", "Trebuchet21", 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, prefixText, ulx )
   if (IsValid(pl)) then
      SendText(text, prefixText.."> ")
   else
      SendText(text, "JcChatbox>> ")
   end
end)

hook.Add("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("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, prefixText )
      --/*
      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
      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(prefixText, "> "..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

-- Admin > flamedog: words
-- SAdmin > flamedog: words
-- Console > words
« Last Edit: October 09, 2015, 02:59:41 PM by PizzaDox »