diff --git a/lua/ulx/modules/sh/chat.lua b/lua/ulx/modules/sh/chat.lua index d59ec9d..46ea9c3 100644 --- a/lua/ulx/modules/sh/chat.lua +++ b/lua/ulx/modules/sh/chat.lua @@ -5,7 +5,7 @@ CATEGORY_NAME = "Chat" function ulx.psay( calling_ply, target_ply, message ) if calling_ply:GetNWBool( "ulx_muted", false ) then ULib.tsayError( calling_ply, "You are muted, and therefore cannot speak! Use asay for admin chat if urgent.", true ) - return + return false end ulx.fancyLog( { target_ply, calling_ply }, "#P to #P: " .. message, calling_ply, target_ply ) @@ -77,7 +77,7 @@ local lasttimeusage = -waittime function ulx.thetime( calling_ply ) if lasttimeusage + waittime > CurTime() then ULib.tsayError( calling_ply, "I just told you what time it is! Please wait " .. waittime .. " seconds before using this command again", true ) - return + return false end lasttimeusage = CurTime() diff --git a/lua/ulx/modules/sh/rcon.lua b/lua/ulx/modules/sh/rcon.lua index 2e05d84..189ff2a 100644 --- a/lua/ulx/modules/sh/rcon.lua +++ b/lua/ulx/modules/sh/rcon.lua @@ -48,7 +48,7 @@ function ulx.exec( calling_ply, config ) if string.sub( config, -4 ) ~= ".cfg" then config = config .. ".cfg" end if not ULib.fileExists( "cfg/" .. config ) then ULib.tsayError( calling_ply, "That config does not exist!", true ) - return + return false end ULib.execFile( "cfg/" .. config ) @@ -84,7 +84,7 @@ function ulx.ent( calling_ply, classname, params ) -- Make sure it's a valid ent if not newEnt or not newEnt:IsValid() then ULib.tsayError( calling_ply, "Unknown entity type (" .. classname .. "), aborting.", true ) - return + return false end local trace = calling_ply:GetEyeTrace() diff --git a/lua/ulx/modules/sh/teleport.lua b/lua/ulx/modules/sh/teleport.lua index 01458b7..694c14f 100644 --- a/lua/ulx/modules/sh/teleport.lua +++ b/lua/ulx/modules/sh/teleport.lua @@ -82,17 +82,17 @@ function ulx.bring( calling_ply, target_plys ) if ulx.getExclusive( calling_ply, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( calling_ply, calling_ply ), true ) - return + return false end if not calling_ply:Alive() then ULib.tsayError( calling_ply, "You are dead!", true ) - return + return false end if calling_ply:InVehicle() then ULib.tsayError( calling_ply, "Please leave the vehicle first!", true ) - return + return false end local t = { @@ -104,7 +104,7 @@ function ulx.bring( calling_ply, target_plys ) if tr.Hit then ULib.tsayError( calling_ply, "Can't teleport when you're inside the world!", true ) - return + return false end local teleportable_plys = {} @@ -169,33 +169,33 @@ bring:help( "Brings target(s) to you." ) function ulx.goto( calling_ply, target_ply ) if not calling_ply:IsValid() then Msg( "You may not step down into the mortal world from console.\n" ) - return + return false end if ulx.getExclusive( calling_ply, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( calling_ply, calling_ply ), true ) - return + return false end if not target_ply:Alive() then ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true ) - return + return false end if not calling_ply:Alive() then ULib.tsayError( calling_ply, "You are dead!", true ) - return + return false end if target_ply:InVehicle() and calling_ply:GetMoveType() ~= MOVETYPE_NOCLIP then ULib.tsayError( calling_ply, "Target is in a vehicle! Noclip and use this command to force a goto.", true ) - return + return false end local newpos = playerSend( calling_ply, target_ply, calling_ply:GetMoveType() == MOVETYPE_NOCLIP ) if not newpos then ULib.tsayError( calling_ply, "Can't find a place to put you! Noclip and use this command to force a goto.", true ) - return + return false end if calling_ply:InVehicle() then @@ -218,17 +218,17 @@ goto:help( "Goto target." ) function ulx.send( calling_ply, target_from, target_to ) if target_from == target_to then ULib.tsayError( calling_ply, "You listed the same target twice! Please use two different targets.", true ) - return + return false end if ulx.getExclusive( target_from, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( target_from, calling_ply ), true ) - return + return false end if ulx.getExclusive( target_to, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( target_to, calling_ply ), true ) - return + return false end local nick = target_from:Nick() -- Going to use this for our error (if we have one) @@ -238,18 +238,18 @@ function ulx.send( calling_ply, target_from, target_to ) nick = target_to:Nick() end ULib.tsayError( calling_ply, nick .. " is dead!", true ) - return + return false end if target_to:InVehicle() and target_from:GetMoveType() ~= MOVETYPE_NOCLIP then ULib.tsayError( calling_ply, "Target is in a vehicle!", true ) - return + return false end local newpos = playerSend( target_from, target_to, target_from:GetMoveType() == MOVETYPE_NOCLIP ) if not newpos then ULib.tsayError( calling_ply, "Can't find a place to put them!", true ) - return + return false end if target_from:InVehicle() then @@ -273,23 +273,23 @@ send:help( "Goto target." ) function ulx.teleport( calling_ply, target_ply ) if not calling_ply:IsValid() then Msg( "You are the console, you can't teleport or teleport others since you can't see the world!\n" ) - return + return false end if ulx.getExclusive( target_ply, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true ) - return + return false end if not target_ply:Alive() then ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true ) - return + return false end local pos = calling_ply:GetEyeTrace().HitPos if target_ply == calling_ply and pos:Distance( target_ply:GetPos() ) < 64 then -- Laughable distance - return + return false end target_ply.ulx_prevpos = target_ply:GetPos() @@ -314,22 +314,22 @@ teleport:help( "Teleports target." ) function ulx.retrn( calling_ply, target_ply ) if not target_ply:IsValid() then Msg( "Return where? The console may never return to the mortal realm.\n" ) - return + return false end if not target_ply.ulx_prevpos then ULib.tsayError( calling_ply, target_ply:Nick() .. " does not have any previous locations to send them to.", true ) - return + return false end if ulx.getExclusive( target_ply, calling_ply ) then ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true ) - return + return false end if not target_ply:Alive() then ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true ) - return + return false end if target_ply:InVehicle() then diff --git a/lua/ulx/modules/sh/user.lua b/lua/ulx/modules/sh/user.lua index 36a5c13..d23ebd4 100644 --- a/lua/ulx/modules/sh/user.lua +++ b/lua/ulx/modules/sh/user.lua @@ -138,6 +138,7 @@ function ulx.userallow( calling_ply, target_ply, access_string, access_tag ) local success = ULib.ucl.userAllow( id, accessTable ) if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" already has access to \"%s\"", target_ply:Nick(), access_string ), true ) + return false else if not access_tag or access_tag == "" then ulx.fancyLogAdmin( calling_ply, "#A granted access #q to #T", access_string, target_ply ) @@ -176,12 +177,13 @@ function ulx.userallowid( calling_ply, id, access_string, access_tag ) local name = (ULib.ucl.authed[ id ] and ULib.ucl.authed[ id ].name) or (ULib.ucl.users[ id ] and ULib.ucl.users[ id ].name) or id if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" already has access to \"%s\"", name, access_string ), true ) + return false + end + + if not access_tag or access_tag == "" then + ulx.fancyLogAdmin( calling_ply, "#A granted access #q to #s", access_string, name ) else - if not access_tag or access_tag == "" then - ulx.fancyLogAdmin( calling_ply, "#A granted access #q to #s", access_string, name ) - else - ulx.fancyLogAdmin( calling_ply, "#A granted access #q with tag #q to #s", access_string, access_tag, name ) - end + ulx.fancyLogAdmin( calling_ply, "#A granted access #q with tag #q to #s", access_string, access_tag, name ) end end local userallowid = ulx.command( CATEGORY_NAME, "ulx userallowid", ulx.userallowid, nil, false, false, true ) @@ -198,17 +200,19 @@ function ulx.userdeny( calling_ply, target_ply, access_string, should_use_neutra end if should_use_neutral then - if success then - ulx.fancyLogAdmin( calling_ply, "#A made access #q neutral to #T", access_string, target_ply ) - else + if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" isn't denied or allowed access to \"%s\"", target_ply:Nick(), access_string ), true ) + return false end + + ulx.fancyLogAdmin( calling_ply, "#A made access #q neutral to #T", access_string, target_ply ) else if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" is already denied access to \"%s\"", target_ply:Nick(), access_string ), true ) - else - ulx.fancyLogAdmin( calling_ply, "#A denied access #q to #T", access_string, target_ply ) + return false end + + ulx.fancyLogAdmin( calling_ply, "#A denied access #q to #T", access_string, target_ply ) end end local userdeny = ulx.command( CATEGORY_NAME, "ulx userdeny", ulx.userdeny, nil, false, false, true ) @@ -236,17 +240,19 @@ function ulx.userdenyid( calling_ply, id, access_string, should_use_neutral ) local name = (ULib.ucl.authed[ id ] and ULib.ucl.authed[ id ].name) or (ULib.ucl.users[ id ] and ULib.ucl.users[ id ].name) or id if should_use_neutral then - if success then - ulx.fancyLogAdmin( calling_ply, "#A made access #q neutral to #s", access_string, name ) - else + if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" isn't denied or allowed access to \"%s\"", name, access_string ), true ) + return false end + + ulx.fancyLogAdmin( calling_ply, "#A made access #q neutral to #s", access_string, name ) else if not success then ULib.tsayError( calling_ply, string.format( "User \"%s\" is already denied access to \"%s\"", name, access_string ), true ) - else - ulx.fancyLogAdmin( calling_ply, "#A denied access #q to #s", access_string, name ) + return false end + + ulx.fancyLogAdmin( calling_ply, "#A denied access #q to #s", access_string, name ) end end local userdenyid = ulx.command( CATEGORY_NAME, "ulx userdenyid", ulx.userdenyid, nil, false, false, true ) @@ -259,12 +265,12 @@ userdenyid:help( "Remove from a user's access." ) function ulx.addgroup( calling_ply, group_name, inherit_from ) if ULib.ucl.groups[ group_name ] ~= nil then ULib.tsayError( calling_ply, "This group already exists!", true ) - return + return false end if not ULib.ucl.groups[ inherit_from ] then ULib.tsayError( calling_ply, "The group you specified for inheritence doesn't exist!", true ) - return + return false end ULib.ucl.addGroup( group_name, _, inherit_from ) @@ -279,7 +285,7 @@ addgroup:help( "Create a new group with optional inheritance." ) function ulx.renamegroup( calling_ply, current_group, new_group ) if ULib.ucl.groups[ new_group ] then ULib.tsayError( calling_ply, "The target group already exists!", true ) - return + return false end ULib.ucl.renameGroup( current_group, new_group ) @@ -328,12 +334,13 @@ function ulx.groupallow( calling_ply, group_name, access_string, access_tag ) local success = ULib.ucl.groupAllow( group_name, accessTable ) if not success then ULib.tsayError( calling_ply, string.format( "Group \"%s\" already has access to \"%s\"", group_name, access_string ), true ) + return false + end + + if not access_tag or access_tag == "" then + ulx.fancyLogAdmin( calling_ply, "#A granted access #q to group #s", access_string, group_name ) else - if not access_tag or access_tag == "" then - ulx.fancyLogAdmin( calling_ply, "#A granted access #q to group #s", access_string, group_name ) - else - ulx.fancyLogAdmin( calling_ply, "#A granted access #q with tag #q to group #s", access_string, access_tag, group_name ) - end + ulx.fancyLogAdmin( calling_ply, "#A granted access #q with tag #q to group #s", access_string, access_tag, group_name ) end end local groupallow = ulx.command( CATEGORY_NAME, "ulx groupallow", ulx.groupallow, nil, false, false, true ) @@ -352,11 +359,12 @@ function ulx.groupdeny( calling_ply, group_name, access_string ) end local success = ULib.ucl.groupAllow( group_name, access_string, true ) - if success then - ulx.fancyLogAdmin( calling_ply, "#A revoked access #q to group #s", access_string, group_name ) - else + if not success then ULib.tsayError( calling_ply, string.format( "Group \"%s\" doesn't have access to \"%s\"", group_name, access_string ), true ) + return false end + + ulx.fancyLogAdmin( calling_ply, "#A revoked access #q to group #s", access_string, group_name ) end local groupdeny = ulx.command( CATEGORY_NAME, "ulx groupdeny", ulx.groupdeny, nil, false, false, true ) groupdeny:addParam{ type=ULib.cmds.StringArg, completes=ulx.group_names, hint="group", error="invalid group \"%s\" specified", ULib.cmds.restrictToCompletes } diff --git a/lua/ulx/modules/sh/util.lua b/lua/ulx/modules/sh/util.lua index 61c83af..4119f20 100644 --- a/lua/ulx/modules/sh/util.lua +++ b/lua/ulx/modules/sh/util.lua @@ -64,7 +64,7 @@ map:help( "Changes map and gamemode." ) function ulx.kick( calling_ply, target_ply, reason ) if target_ply:IsListenServerHost() then ULib.tsayError( calling_ply, "This player is immune to kicking", true ) - return + return false end if reason and reason ~= "" then @@ -86,7 +86,7 @@ kick:help( "Kicks target." ) function ulx.ban( calling_ply, target_ply, minutes, reason ) if target_ply:IsListenServerHost() or target_ply:IsBot() then ULib.tsayError( calling_ply, "This player is immune to banning", true ) - return + return false end local time = "for #s" @@ -109,7 +109,7 @@ function ulx.banid( calling_ply, steamid, minutes, reason ) steamid = steamid:upper() if not ULib.isValidSteamID( steamid ) then ULib.tsayError( calling_ply, "Invalid steamid." ) - return + return false end local name, target_ply @@ -124,7 +124,7 @@ function ulx.banid( calling_ply, steamid, minutes, reason ) if target_ply and (target_ply:IsListenServerHost() or target_ply:IsBot()) then ULib.tsayError( calling_ply, "This player is immune to banning", true ) - return + return false end local time = "for #s" @@ -151,7 +151,7 @@ function ulx.unban( calling_ply, steamid ) steamid = steamid:upper() if not ULib.isValidSteamID( steamid ) then ULib.tsayError( calling_ply, "Invalid steamid." ) - return + return false end name = ULib.bans[ steamid ] and ULib.bans[ steamid ].name diff --git a/lua/ulx/modules/sh/vote.lua b/lua/ulx/modules/sh/vote.lua index 2123766..a756220 100644 --- a/lua/ulx/modules/sh/vote.lua +++ b/lua/ulx/modules/sh/vote.lua @@ -130,7 +130,7 @@ end function ulx.vote( calling_ply, title, ... ) if ulx.voteInProgress then ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true ) - return + return false end ulx.doVote( title, { ... }, voteDone ) @@ -146,7 +146,7 @@ vote:help( "Starts a public vote." ) function ulx.stopVote( calling_ply ) if not ulx.voteInProgress then ULib.tsayError( calling_ply, "There is no vote currently in progress.", true ) - return + return false end ulx.voteDone( true ) @@ -217,13 +217,13 @@ function ulx.votemap2( calling_ply, ... ) if ulx.voteInProgress then ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true ) - return + return false end for i=2, #argv do if ULib.findInTable( argv, argv[ i ], 1, i-1 ) then ULib.tsayError( calling_ply, "Map " .. argv[ i ] .. " was listed twice. Please try again" ) - return + return false end end @@ -299,12 +299,12 @@ end function ulx.votekick( calling_ply, target_ply, reason ) if target_ply:IsListenServerHost() then ULib.tsayError( calling_ply, "This player is immune to kicking", true ) - return + return false end if ulx.voteInProgress then ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true ) - return + return false end local msg = "Kick " .. target_ply:Nick() .. "?" @@ -379,12 +379,12 @@ end function ulx.voteban( calling_ply, target_ply, minutes, reason ) if target_ply:IsListenServerHost() or target_ply:IsBot() then ULib.tsayError( calling_ply, "This player is immune to banning", true ) - return + return false end if ulx.voteInProgress then ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true ) - return + return false end local msg = "Ban " .. target_ply:Nick() .. " for " .. minutes .. " minutes?"