General > Developers Corner

How to disable ulx motd from displaying for staff

<< < (3/4) > >>

Decicus:
Try to move this:

--- Code: ---if ply:IsAdmin() or ply:IsUserGroup( "moderator" ) then return end
--- End code ---
Below this:

--- Code: ---if showMotd == "1" then -- Assume it's a file
--- End code ---

So your code pretty much looks like this:

--- Code: --- 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" ) )

--- End code ---

Storm:
I tried this and double checked it and it still doesnt work.

Megiddo:
Did you change maps after editing the file? Are you sure you edited the right file? Try adding print statements, if nothing else.

Storm:
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: ---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

--- End code ---

Megiddo:
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 )`.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version