Ulysses
General => Developers Corner => Topic started 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)?
-
Im sure you can add a "ply.CheckGroup" script to the lua file for the motd.
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
-
Thanks but this didnt seem to work. Does anyone else have any other ideas?
-
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.
-
Thanks but how does this make it not display for just mods and admins?
-
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
-
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)
-
Thanks so much! Does inheritance work with this? If I put moderator, will it work for all groups above?
-
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:
if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
(This is just an edit from Megiddo's suggestion)
-
Thanks. This is what I now have in that file:
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?
-
Try to move this:
if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
Below this:
if showMotd == "1" then -- Assume it's a file
So your code pretty much looks like this:
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" ) )
-
I tried this and double checked it and it still doesnt work.
-
Did you change maps after editing the file? Are you sure you edited the right file? Try adding print statements, if nothing else.
-
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.
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
-
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 )`.
-
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.