Skip to content

Commit a438ce5

Browse files
authored
votemanager: added additional resource settings for ban votes (#192)
* votemanager: store empty string for vote reason instead of nil if none is provided Saving nil in a table seems to have odd side effects when further adding key values to it. local tab = {true,false,false,nil,5} tab.cheese = "Yes" local a,b,c,d,e = unpack (tab) outputChatBox(tostring(e)) Should output 5 but instead outputs nil. If I remove the tab.cheese = "Yes" local tab = {true,false,false,nil,5} local a,b,c,d,e = unpack (tab) outputChatBox(tostring(e)) It will correctly output 5 again. However I don't see any easy and clean way to get around it, as votemanager depends on some further modification of the tables and unpacking them later to work properly. Turning the vote reason into an empty string "" sounds like a rather small sacrifice to ensure proper functionality. * votemanager: add additional voteban settings for server owners banPlayer provides a lot of banning options, none of which votemanager currently supports changing. This commit adds settings to the meta.xml for the following settings: voteban_banip true/false (default: true); voteban_banusername true/false (default: false); voteban_banserial true/false (default: false); voteban_duration number in seconds (default: 3600) * votemanager: add additional voteban settings for server owners #2 addendum to previous commit banPlayer provides a lot of banning options, none of which votemanager currently supports changing. This commit adds settings to the meta.xml for the following settings: voteban_banip true/false (default: true); voteban_banusername true/false (default: false); voteban_banserial true/false (default: false); voteban_duration number in seconds (default: 3600) * votemanager: store empty string for vote reason instead of nil if none is provided addendum Removed unnecessary reason == "" from kill votes as it is never used after the initial use. * changed default voteban behavior from IP to serial
1 parent c4e453e commit a438ce5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

[managers]/votemanager/meta.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
<setting name="*voteban_locktime" value="[120]"/>
5050
<setting name="*voteban_percentage" value="[75]"/>
5151
<setting name="*voteban_allowchange" value="[true]"/>
52+
<setting name="*voteban_banip" value="[false]"/>
53+
<setting name="*voteban_banusername" value="[false]"/>
54+
<setting name="*voteban_banserial" value="[true]"/>
55+
<setting name="*voteban_duration" value="[3600]"/>
5256

5357
<setting name="*votekill_enabled" value="[false]"/>
5458
<setting name="*votekill_timeout" value="[15]"/>

[managers]/votemanager/votemanager_polls.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ addEventHandler("onResourceStart", thisResourceRoot,
5858
info.percentage = get(settingsGroup.."_percentage") or nil
5959
info.timeout = get(settingsGroup.."_timeout") or nil
6060
info.allowchange = get(settingsGroup.."_allowchange")
61+
if name == "ban" then
62+
info.banip = get(settingsGroup.."_banip")
63+
info.banusername = get(settingsGroup.."_banusername")
64+
info.banserial = get(settingsGroup.."_banserial")
65+
info.duration = get(settingsGroup.."_duration")
66+
end
6167
info.blockedPlayers = {}
6268
addCommandHandler("vote"..name, vote[name].handler )
6369
end
@@ -426,6 +432,8 @@ function voteKick(player, reason)
426432
local title = "Kick "..getPlayerName(player).."?"
427433
if reason then
428434
title = title.." ("..reason..")"
435+
else
436+
reason = ""
429437
end
430438
return startPoll{
431439
title=title,
@@ -446,14 +454,16 @@ function voteBan(player, reason)
446454
local title = "Ban "..getPlayerName(player).."?"
447455
if reason then
448456
title = title.." ("..reason..")"
457+
else
458+
reason = ""
449459
end
450460
return startPoll{
451461
title=title,
452462
percentage = vote.ban.percentage,
453463
visibleTo = rootElement,
454464
timeout = vote.ban.timeout,
455465
allowchange = vote.ban.allowchange;
456-
[1]={"Yes",banPlayer,player,serverConsole,reason},
466+
[1]={"Yes",banPlayer,player,vote.ban.banip,vote.ban.banusername,vote.ban.banserial,serverConsole,reason,vote.ban.duration},
457467
[2]={"No",outputVoteManager,"voteban: not enough votes to ban "..getPlayerName(player)..".",rootElement,vR,vG,vB;default=true},
458468
}
459469
end

0 commit comments

Comments
 (0)