ULX

Author Topic: How to disable ulx motd from displaying for staff  (Read 8063 times)

0 Members and 1 Guest are viewing this topic.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
How to disable ulx motd from displaying for staff
« on: February 05, 2014, 04:31:58 AM »
Is there some code I can add to disable the motd from displaying and having to click "ok" for ulx groups (moderator, admin, etc)?

Offline Tarado

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: How to disable ulx motd from displaying for staff
« Reply #1 on: February 05, 2014, 07:59:36 AM »
Im sure you can add a "ply.CheckGroup" script to the lua file for the motd.

Code: [Select]
Not Tested, just theoretical .

...
local url

function StaffDisplay()
    if ply:CheckGroup("admin") then
        ply:ulx.motd_exists(false)
    elseif ply:CheckGroup("moderator") then
        ply:ulx.motd_exists(false)
    elseif ply:CheckGroup("superadmin") then
        ply:ulx.motd_exists(false)
    end
end

« Last Edit: February 05, 2014, 09:15:53 AM by Tarado »

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #2 on: February 06, 2014, 05:08:02 PM »
Thanks but this didnt seem to work. Does anyone else have any other ideas?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How to disable ulx motd from displaying for staff
« Reply #3 on: February 06, 2014, 07:30:23 PM »
Comment out gmod/data/ulx/config.txt "motdfile", then make sure your script or server.cfg is setting the motdfile convar to something other than what it used to have for ULX.
If you've not reset it on the server, it's likely the same.


"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #4 on: February 07, 2014, 04:55:53 AM »
Thanks but how does this make it not display for just mods and admins?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How to disable ulx motd from displaying for staff
« Reply #5 on: February 07, 2014, 09:21:19 PM »
Sorry, got your question mixed up with someone else trying to stop motd totally.
It was late. I was tired. I'll go find that thread and post my same answer there. :D
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How to disable ulx motd from displaying for staff
« Reply #6 on: February 09, 2014, 04:14:40 PM »
Before
`if showMotd == "1" then`
in menus.lua

add
`if ply:IsAdmin() then return end` (or whatever logic you need for the groups you're exempting)
Experiencing God's grace one day at a time.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #7 on: February 10, 2014, 04:47:14 AM »
Thanks so much! Does inheritance work with this? If I put moderator, will it work for all groups above?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: How to disable ulx motd from displaying for staff
« Reply #8 on: February 10, 2014, 06:41:35 AM »
Thanks so much! Does inheritance work with this? If I put moderator, will it work for all groups above?
IsAdmin() will work for groups that inherit from the default "admin" group. If it's only moderator you're worried about (and there's no group between "moderator" and "admin" or "moderator" and "user") that you want to disable the MOTD for, you can do something like this:
Code: [Select]
if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end(This is just an edit from Megiddo's suggestion)
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #9 on: February 10, 2014, 09:36:09 AM »
Thanks. This is what I now have in that file:

Code: [Select]
local function sendMotd( ply, showMotd )
    if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
if showMotd == "1" then -- Assume it's a file
if ply.ulxHasMotd then return end -- This player already has the motd
if not ULib.fileExists( GetConVarString( "motdfile" ) ) then return end -- Invalid
local f = ULib.fileRead( GetConVarString( "motdfile" ) )

For some reason this has no effect (the motd still comes up for all groups.) Can you tell me what I am doing wrong?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: How to disable ulx motd from displaying for staff
« Reply #10 on: February 10, 2014, 12:50:45 PM »
Try to move this:
Code: [Select]
if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return endBelow this:
Code: [Select]
if showMotd == "1" then -- Assume it's a file
So your code pretty much looks like this:
Code: [Select]
local function sendMotd( ply, showMotd )
if showMotd == "1" then -- Assume it's a file
        if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
if ply.ulxHasMotd then return end -- This player already has the motd
if not ULib.fileExists( GetConVarString( "motdfile" ) ) then return end -- Invalid
local f = ULib.fileRead( GetConVarString( "motdfile" ) )
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #11 on: February 10, 2014, 01:08:33 PM »
I tried this and double checked it and it still doesnt work.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How to disable ulx motd from displaying for staff
« Reply #12 on: February 10, 2014, 03:15:02 PM »
Did you change maps after editing the file? Are you sure you edited the right file? Try adding print statements, if nothing else.
Experiencing God's grace one day at a time.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: How to disable ulx motd from displaying for staff
« Reply #13 on: February 10, 2014, 04:23:42 PM »
I restarted the server twice and I double checked the file that was on the server after it didnt work. I edited the menus.lua file. The following is what is on the server.

Code: [Select]
local CATEGORY_NAME = "Menus"

if ULib.fileExists( "lua/ulx/modules/cl/motdmenu.lua" ) or ulx.motdmenu_exists then
CreateConVar( "motdfile", "ulx_motd.txt" ) -- Garry likes to add and remove this cvar a lot, so it's here just in case he removes it again.
local function sendMotd( ply, showMotd )
if showMotd == "1" then -- Assume it's a file
if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
if ply.ulxHasMotd then return end -- This player already has the motd
if not ULib.fileExists( GetConVarString( "motdfile" ) ) then return end -- Invalid
local f = ULib.fileRead( GetConVarString( "motdfile" ) )

ULib.clientRPC( ply, "ulx.rcvMotd", false, f )

ply.ulxHasMotd = true

else -- Assume URL
ULib.clientRPC( ply, "ulx.rcvMotd", true, showMotd )
ply.ulxHasMotd = nil
end
end

local function showMotd( ply )
local showMotd = GetConVarString( "ulx_showMotd" )
if showMotd == "0" then return end
if not ply:IsValid() then return end -- They left, doh!

sendMotd( ply, showMotd )
ULib.clientRPC( ply, "ulx.showMotdMenu", ply:SteamID() ) -- Passing it because they may get it before LocalPlayer() is valid
end
hook.Add( "PlayerInitialSpawn", "showMotd", showMotd )

function ulx.motd( calling_ply )
if not calling_ply:IsValid() then
Msg( "You can't see the motd from the console.\n" )
return
end

if GetConVarString( "ulx_showMotd" ) == "0" then
ULib.tsay( ply, "The MOTD has been disabled on this server." )
return
end

showMotd( calling_ply )
end
local motdmenu = ulx.command( CATEGORY_NAME, "ulx motd", ulx.motd, "!motd" )
motdmenu:defaultAccess( ULib.ACCESS_ALL )
motdmenu:help( "Show the message of the day." )
if SERVER then ulx.convar( "showMotd", "1", " <0/1/(url)> - Shows the motd to clients on startup. Can specify URL here.", ULib.ACCESS_ADMIN ) end
end
« Last Edit: February 10, 2014, 04:28:52 PM by Storm »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: How to disable ulx motd from displaying for staff
« Reply #14 on: February 10, 2014, 05:19:54 PM »
Okay, I think I flubbed on remembering my own functions. ;)

Try putting `if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end` right after `local function showMotd( ply )`.
Experiencing God's grace one day at a time.