-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add GM command to ban or unban players from using /yell
- Loading branch information
Tal Ben-Eliezer
committed
May 16, 2024
1 parent
bbdffc8
commit d598014
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
----------------------------------- | ||
-- func: yell | ||
-- desc: Bans a specified player from using /yell. | ||
----------------------------------- | ||
local commandObj = {} | ||
|
||
commandObj.cmdprops = | ||
{ | ||
permission = 1, | ||
parameters = 'ssi' | ||
} | ||
|
||
local function error(player, msg) | ||
player:printToPlayer(msg) | ||
player:printToPlayer('!yell <ban/unban> (player) <days>') | ||
end | ||
|
||
commandObj.onTrigger = function(player, value, target, days) | ||
-- validate value | ||
if | ||
value ~= 'ban' or | ||
value ~= 'unban' | ||
then | ||
error(player) | ||
return | ||
end | ||
|
||
-- validate target | ||
target = GetPlayerByName(target) | ||
if target == nil then | ||
error(player, 'Invalid target specified') | ||
return | ||
end | ||
|
||
if value == 'unban' then | ||
target:setCharVar('[YELL]Banned', 0) | ||
player:printToPlayer(string.format('%s has been unbanned from using the /yell command.', target:getName())) | ||
elseif value == 'ban' then | ||
-- validate duration | ||
if | ||
days == nil or | ||
days < 1 | ||
then | ||
-- indefinite ban | ||
error(player, 'Invalid duration specified, defaulting to indefinite ban.') | ||
days = 0 | ||
end | ||
|
||
target:setCharVar('[YELL]Banned', 1, os.time() + utils.days(days)) | ||
player:printToPlayer(string.format('%s has been banned from using the /yell command.', target:getName())) | ||
else | ||
error(player, 'Invalid value specified.') | ||
end | ||
end | ||
|
||
return commandObj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters