Skip to content

Commit

Permalink
warn when insufficient args are given for some commands
Browse files Browse the repository at this point in the history
for pac_healthbar, pac_event, +pac_event and pac_proxy

and added help texts as well
  • Loading branch information
pingu7867 committed Jul 14, 2024
1 parent 696f4d5 commit c518459
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lua/pac3/core/client/parts/health_modifier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ concommand.Add("pac_healthbar", function(ply, cmd, args)
net.WriteInt(num, 16)
net.SendToServer()
end
end, nil, "changes your health modifier's extra health value. arguments:\nuid or name: the unique ID or the name of the part\naction: add, subtract, refill, replenish, remove, set\nnumber")
if args[2] == nil then ply:PrintMessage(HUD_PRINTCONSOLE, "\nthis command needs at least two arguments.\nuid or name: the unique ID or the name of the part\naction: add, subtract, refill, replenish, remove, set\nnumber\n\nexample: pac_healthbar my_healthmod add 50\n") end
end, nil, "changes your health modifier's extra health value. arguments:\nuid or name: the unique ID or the name of the part\naction: add, subtract, refill, replenish, remove, set\nnumber\n\nexample: pac_healthbar my_healthmod add 50")

BUILDER:Register()
25 changes: 19 additions & 6 deletions lua/pac3/core/server/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ end)

-- event
concommand.Add("pac_event", function(ply, _, args)
if not args[1] then return end
if args[1] == nil then
ply:PrintMessage(HUD_PRINTCONSOLE, "\npac_event needs at least one argument.\nname: any name, preferably without spaces\nmode: a number.\n\t0 turns off\n\t1 turns on\n\t2 toggles on/off\n\twithout a second argument, the event is a single-shot\n\ne.g. pac_event light 2\n")
return
end

local event = args[1]
local extra = tonumber(args[2]) or 0
Expand All @@ -35,10 +38,13 @@ concommand.Add("pac_event", function(ply, _, args)
ply.pac_command_events = ply.pac_command_events or {}
ply.pac_command_events[event] = ply.pac_command_events[event] or {}
ply.pac_command_events[event] = {name = event, time = pac.RealTime, on = extra}
end)
end, nil, "pac_event triggers command events. it needs at least one argument.\nname: any name, preferably without spaces\nmode: a number.\n\t0 turns off\n\t1 turns on\n\t2 toggles on/off\n\twithout a second argument, the event is a single-shot\n\ne.g. pac_event light 2")

concommand.Add("+pac_event", function(ply, _, args)
if not args[1] then return end
if not args[1] then
ply:PrintMessage(HUD_PRINTCONSOLE, "+pac_event needs a name argument, and the toggling argument. e.g. +pac_event hold_light 2\nwithout the toggling arg, implicitly adds _on to the command name, like running \"pac_event name_on\", and \"pac_event name_off\" when released")
return
end

if args[2] == "2" or args[2] == "toggle" then
local event = args[1]
Expand All @@ -56,10 +62,13 @@ concommand.Add("+pac_event", function(ply, _, args)
net.WriteString(args[1] .. "_on")
net.Broadcast()
end
end)
end, nil, "activates a command event when bound. \ne.g. \"+pac_event name\" will run \"pac_event name_on\" when the button is held, \"pac_event name_off\" when the button is held. Take note these are instant commands, they would need a command event with duration.\nmeanwhile, \"+pac_event name 2\" will run \"pac_event name 1\" when the button is held, \"pac_event name 0\" when the button is held. Take note these are held commands.")

concommand.Add("-pac_event", function(ply, _, args)
if not args[1] then return end
if not args[1] then
ply:PrintMessage(HUD_PRINTCONSOLE, "-pac_event needs a name argument, and the toggling argument. e.g. +pac_event hold_light 2\nwithout the toggling arg, implicitly adds _on to the command name, like running \"pac_event name_off\"")
return
end

if args[2] == "2" or args[2] == "toggle" then
local event = args[1]
Expand All @@ -81,6 +90,10 @@ end)
-- proxy
concommand.Add("pac_proxy", function(ply, _, args)
str = args[1]
if args[1] == nil then
ply:PrintMessage(HUD_PRINTCONSOLE, "\npac_proxy needs at least two arguments.\nname\nnumber, or a series of numbers for a vector. increment notation is available, such as ++1 or --1.\ne.g. pac_proxy myvector 1 2 3\ne.g. pac_proxy value ++5")
return
end

if ply:IsValid() then
ply.pac_proxy_events = ply.pac_proxy_events or {}
Expand Down Expand Up @@ -125,4 +138,4 @@ concommand.Add("pac_proxy", function(ply, _, args)
net.Broadcast()

--PrintTable(ply.pac_proxy_events[str])
end)
end, nil, "pac_proxy sets the number of a command function in a proxy. it is typically accessed as command(\"value\") needs at least two arguments.\nname: any name, preferably without spaces\nnumbers: a number, or a series of numbers for a vector. increment notation is available, such as ++1 and --1.\ne.g. pac_proxy myvector 1 2 3\ne.g. pac_proxy value ++5")

0 comments on commit c518459

Please sign in to comment.