Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Command Success reports #205

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/ulx/modules/sh/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions lua/ulx/modules/sh/rcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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()
Expand Down
48 changes: 24 additions & 24 deletions lua/ulx/modules/sh/teleport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
60 changes: 34 additions & 26 deletions lua/ulx/modules/sh/user.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand All @@ -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 )
Expand Down Expand Up @@ -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 )
Expand All @@ -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 }
Expand Down
10 changes: 5 additions & 5 deletions lua/ulx/modules/sh/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down
Loading