Ulysses

General => Developers Corner => Topic started by: Storm on February 05, 2014, 04:31:58 AM

Title: How to disable ulx motd from displaying for staff
Post by: Storm 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)?
Title: Re: How to disable ulx motd from displaying for staff
Post by: Tarado 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

Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm on February 06, 2014, 05:08:02 PM
Thanks but this didnt seem to work. Does anyone else have any other ideas?
Title: Re: How to disable ulx motd from displaying for staff
Post by: JamminR 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.


Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm on February 07, 2014, 04:55:53 AM
Thanks but how does this make it not display for just mods and admins?
Title: Re: How to disable ulx motd from displaying for staff
Post by: JamminR 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
Title: Re: How to disable ulx motd from displaying for staff
Post by: Megiddo 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)
Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm 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?
Title: Re: How to disable ulx motd from displaying for staff
Post by: Decicus 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)
Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm 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?
Title: Re: How to disable ulx motd from displaying for staff
Post by: Decicus 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" ) )
Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm on February 10, 2014, 01:08:33 PM
I tried this and double checked it and it still doesnt work.
Title: Re: How to disable ulx motd from displaying for staff
Post by: Megiddo 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.
Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm 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
Title: Re: How to disable ulx motd from displaying for staff
Post by: Megiddo 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 )`.
Title: Re: How to disable ulx motd from displaying for staff
Post by: Storm on February 11, 2014, 05:09:00 AM
Hmm well yes now it doesn't come up when staff joins, the only problem is that staff can't access the motd at all now (!motd is disabled). We do copy rules from there and post them in chat when questioned.