Ulysses

General => Developers Corner => Topic started by: Sloth Armstronk on November 10, 2015, 12:06:03 PM

Title: a "who" modification (Updated)
Post by: Sloth Armstronk 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." )
Title: Re: a "who" modification (Updated)
Post by: Timmy on November 10, 2015, 01:44:08 PM
You're trying to run a client-side function (chat.AddText (https://wiki.garrysmod.com/page/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 (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 (https://wiki.garrysmod.com/page/Net_Library_Usage)
Title: Re: a "who" modification (Updated)
Post by: JamminR on November 10, 2015, 03:49:30 PM
*cringe*
I hate chat clutter.
Title: Re: a "who" modification (Updated)
Post by: Bite That Apple 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.