• Print

Author Topic: Colour staff chat(asay) ?  (Read 4608 times)

0 Members and 1 Guest are viewing this topic.

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
Colour staff chat(asay) ?
« on: April 25, 2015, 12:31:03 pm »
So I change asay to make it a chat for staff members only, is there a way to colour it differently?
Code: Lua
  1. function ulx.asay( calling_ply, message )
  2.         local format
  3.         local me = "/me "
  4.         local nothing = ""
  5.         if message:sub( 1, me:len() ) == me then
  6.                 format = "(Staff)   #P: #s"
  7.                 message = message:sub( me:len() + 1 )
  8.         elseif message:sub(  1, nothing:len() ) then
  9.                 --format = "#P to admins: #s"
  10.                 format = "(Staff)   #P: #s"
  11.                 message = message:sub( nothing:len() + 1 )
  12.         end
  13.  
  14.         local players = player.GetAll()
  15.         for i=#players, 1, -1 do
  16.                 local v = players[ i ]
  17.                 if not ULib.ucl.query( v, seeasayAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
  18.                         table.remove( players, i )
  19.                 end
  20.         end
  21.  
  22.         ulx.fancyLog( players, format, calling_ply, message )
  23. end
  24. local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "#", true, true )
  25. asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  26. asay:defaultAccess( ULib.ACCESS_ADMIN )
  27. asay:help( "Staff chat." )

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Colour staff chat(asay) ?
« Reply #1 on: April 25, 2015, 10:27:32 pm »
Easiest way would be to change the table.insert to use this on each player instead...

http://ulyssesmod.net/docs/files/lua/ulib/shared/messages-lua.html#tsayColor

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
Re: Colour staff chat(asay) ?
« Reply #2 on: April 26, 2015, 09:30:52 pm »
I don't really understand how to change the table.insert to use tsaycolor, if you can help me or at least guide me how to do use it that'd be great.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Colour staff chat(asay) ?
« Reply #3 on: April 26, 2015, 09:40:31 pm »
The very basic idea....
Code: Lua
  1. ULib.tsayColor(v, false, Color(255, 0, 0), "(ADMIN) ", Color(0, 0, 0), "NAME: ", Color(0, 255, 0), message)

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
Re: Colour staff chat(asay) ?
« Reply #4 on: April 27, 2015, 04:48:41 pm »
So my code's like this(works)
Code: Lua
  1. function ulx.asay( calling_ply, message )
  2.         local format
  3.         local nothing = ""
  4.                 local owner = Color(255,74,2)
  5.                 local super = Color(122,0,0)
  6.                 local admin = Color(116,173,0)
  7.                 local mod = Color(68,90,251)
  8.                 local dev = Color(0,255,255)
  9.                
  10.                 message = message:sub( nothing:len() + 1 )
  11.                 if calling_ply:IsUserGroup("Special") or calling_ply:IsUserGroup("disguiseowner") or calling_ply:IsUserGroup("vipdisguise") then
  12.                         ULib.tsayColor(v, false, Color(255, 255, 255), "[", Color(255, 0, 0), "STAFF", Color(255,255,255), "] ", owner ,  "(Owner) ", team.GetColor(calling_ply:Team()), calling_ply:GetName(), Color(255,255,255) , ": " ,  Color(128, 128, 128), message)
  13.                 elseif calling_ply:IsUserGroup("superadmin") or calling_ply:IsUserGroup("disguisesuper") then
  14.                         ULib.tsayColor(v, false, Color(255, 255, 255), "[", Color(255, 0, 0), "STAFF", Color(255,255,255), "] ", super , "(Super)  " ,team.GetColor(calling_ply:Team()), calling_ply:GetName(), Color(255,255,255) , ":" ,  Color(128, 128, 128), message)
  15.                 elseif calling_ply:IsUserGroup("admin") or calling_ply:IsUserGroup("disguiseadmin") then
  16.                         ULib.tsayColor(v, false, Color(255, 255, 255), "[", Color(255, 0, 0), "STAFF", Color(255,255,255), "] ", admin , "(Admin)  " ,team.GetColor(calling_ply:Team()), calling_ply:GetName(), Color(255,255,255) , ":" ,  Color(128, 128, 128), message)
  17.                 elseif calling_ply:IsUserGroup("mod") or calling_ply:IsUserGroup("disguisemod") then
  18.                         ULib.tsayColor(v, false, Color(255, 255, 255), "[", Color(255, 0, 0), "STAFF", Color(255,255,255), "] ", mod , "(Mod)    " ,team.GetColor(calling_ply:Team()), calling_ply:GetName(), Color(255,255,255) , ":" ,  Color(128, 128, 128), message)
  19.                 elseif calling_ply:IsUserGroup("dev") then
  20.                         ULib.tsayColor(v, false, Color(255, 255, 255), "[", Color(255, 0, 0), "STAFF", Color(255,255,255), "] ", dev , "(Dev)     " ,team.GetColor(calling_ply:Team()), calling_ply:GetName(), Color(255,255,255) , ":" ,  Color(128, 128, 128), message)
  21.                 end
  22.  
  23.         local players = player.GetAll()
  24.         for i=#players, 1, -1 do
  25.                 local v = players[ i ]
  26.                 if not ULib.ucl.query( v, seeasayAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
  27.                         table.remove( players, i )
  28.                 end
  29.         end
  30.  
  31.         ulx.fancyLog( players, format, calling_ply, message )
  32. end
  33. local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "#", true, true )
  34. asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  35. asay:defaultAccess( ULib.ACCESS_ADMIN )
  36. asay:help( "Staff chat." )
But I get an error everytime someone uses it
Code: Lua
  1. addons/ulx/lua/ulx/log.lua:450: attempt to index local 'format' (a nil value)
How do I fix this?

  • Print