Author Topic: a "who" modification (Updated)  (Read 1876 times)

0 Members and 1 Guest are viewing this topic.

Offline Sloth Armstronk

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
  • Space. Space is.. Scary as
a "who" modification (Updated)
« on: November 10, 2015, 12:06:03 PM »
Hi, I posted a thread a while ago about this and the script worked like I wanted it too but I want to change the chat output to chat.AddText or something like that instead of printmessage, but whenever I do that it says nothing.

Code: [Select]
function ulx.staff( calling_ply )
 
  for k, ply in pairs( player.GetAll() ) do
    if ULib.ucl.query( ply, "is_staff" ) then
      local id = tostring( ply:UserID() )
      local nick = ply:Nick()
      local group = ply:GetUserGroup()
  local group = string.gsub(" "..group, "%W%l", string.upper):sub(2)
 
calling_ply:PrintMessage( 3, "" .. nick .. ": " .. group )
    end
  end
 
end
local staff = ulx.command( CATEGORY_NAME, "ulx staff", ulx.staff, "!staff" )
staff:defaultAccess( ULib.ACCESS_ALL )
staff:help( "See information about currently online staff members." )

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: a "who" modification (Updated)
« Reply #1 on: November 10, 2015, 01:44:08 PM »
You're trying to run a client-side function (chat.AddText) on the server-side.

Here's what you can do instead:

Use ULib to dispatch your message
ULib contains some useful functions that can handle messaging for you!
See: https://ulyssesmod.net/docs/files/lua/ulib/shared/messages-lua.html

Use the Net Library to dispatch your message
Net messages can be used to trigger a bit of client-side code from the server.
See: https://wiki.garrysmod.com/page/Net_Library_Usage
« Last Edit: July 11, 2018, 12:17:55 AM by Timmy »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: a "who" modification (Updated)
« Reply #2 on: November 10, 2015, 03:49:30 PM »
*cringe*
I hate chat clutter.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: a "who" modification (Updated)
« Reply #3 on: November 11, 2015, 02:58:43 PM »
*cringe*
I hate chat clutter.

But you hate like everything.. this is just one of your many other hates.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.