Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
BUGFIX:
Browse files Browse the repository at this point in the history
dynprop:: isnipe_antiknife
command:: !unlimitedammo <on/off> --> !unlimitedammo <on/off/auto>
command:: !moab <<player | all> --> !moab <<player | *filter*>
  • Loading branch information
FredericaBernkastel committed Aug 31, 2017
1 parent efd00f5 commit f2a05e0
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 31 deletions.
46 changes: 28 additions & 18 deletions BernAdmin/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3198,19 +3198,31 @@ select Command.GetString("dbsearch", "message_found").Format(new Dictionary<stri
}));
}));

// unlimitedammo <on/off>
// unlimitedammo <on/off/auto>
CommandList.Add(new Command("unlimitedammo", 1, Command.Behaviour.Normal,
(sender, arguments, optarg) =>
{
if (UTILS_ParseBool(arguments[0]))
if (arguments[0] == "auto")
{
UTILS_SetDvar("unlimited_ammo", "1");
UTILS_UnlimitedAmmo(true);

} else
UTILS_SetDvar("unlimited_ammo", "0");
AfterDelay(200, () => {
UTILS_SetDvar("unlimited_ammo", "2");
UTILS_UnlimitedAmmo();
});
}
else
{
if (UTILS_ParseBool(arguments[0]))
{
UTILS_SetDvar("unlimited_ammo", "1");
UTILS_UnlimitedAmmo(true);

WriteChatToAll(Command.GetString("unlimitedammo", UTILS_ParseBool(arguments[0]) ? "message_on" : "message_off").Format(
}
else
UTILS_SetDvar("unlimited_ammo", "0");
}

WriteChatToAll(Command.GetString("unlimitedammo", (arguments[0] == "auto") ? "message_auto" : (UTILS_ParseBool(arguments[0]) ? "message_on" : "message_off")).Format(
new Dictionary<string, string>()
{
{"<issuer>", sender.Name},
Expand All @@ -3223,7 +3235,7 @@ select Command.GetString("dbsearch", "message_found").Format(new Dictionary<stri
CommandList.Add(new Command("moab", 1, Command.Behaviour.Normal,
(sender, arguments, optarg) =>
{
if (arguments[0] == "all")
if (arguments[0] == "*all*")
{
foreach (Entity player in Players)
nuke.NukeFuncs.giveNuke(player);
Expand All @@ -3235,19 +3247,17 @@ select Command.GetString("dbsearch", "message_found").Format(new Dictionary<stri
}
else
{
Entity target = FindSinglePlayer(arguments[0]);
if (target == null)
List<Entity> targets = FindSinglePlayerXFilter(arguments[0]);

foreach (Entity target in targets)
{
WriteChatToPlayer(sender, Command.GetMessage("NotOnePlayerFound"));
return;
nuke.NukeFuncs.giveNuke(target);
}

nuke.NukeFuncs.giveNuke(target);

WriteChatToPlayer(sender, Command.GetString("moab", "message").Format(new Dictionary<string, string>()
{
{"<player>", target.Name}
}));
WriteChatToPlayer(sender, Command.GetMessage("Filters_message").Format(new Dictionary<string, string>()
{
{"<count>", targets.Count.ToString() }
}));
}
}));

Expand Down
18 changes: 13 additions & 5 deletions BernAdmin/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public partial class DGAdmin
{"command_votecancel_error", "^1Error: ^3There is no voting" },
{"command_votecancel_message", "^3Voting cancelled by ^2<issuer>" },

{"command_moab_usage", "^1Usage: !moab <<player | all>"},
{"command_moab_usage", "^1Usage: !moab <<player | *filter*>"},
{"command_moab_message", "^7A ^1MOAB ^3given to ^2<player>"},
{"command_moab_message_all", "^7A ^1MOAB ^3given to ^1Everyone by ^2<issuer>"},

Expand All @@ -492,9 +492,10 @@ public partial class DGAdmin
{"command_fx_message_on", "^3Fx ^2applied."},
{"command_fx_message_off", "^3Fx ^1disabled."},

{"command_unlimitedammo_usage", "^1Usage: !unlimitedammo <on/off>"},
{"command_unlimitedammo_usage", "^1Usage: !unlimitedammo <on/off/auto>"},
{"command_unlimitedammo_message_on", "^3Unlimited ammo ^2enabled ^7by <issuerf>"},
{"command_unlimitedammo_message_off", "^3Unlimited ammo ^1disabled ^7by <issuerf>"},
{"command_unlimitedammo_message_auto", "^3Unlimited ammo set to ^5auto ^7by <issuerf>"},

{"command_@admins_usage", "^1Usage: !@admins" },

Expand Down Expand Up @@ -771,15 +772,22 @@ public void CFG_Dynprop_Apply()
InitChatAlias();
}

if (ConfigValues.ISNIPE_SETTINGS.ANTIKNIFE)
if (ConfigValues.ISNIPE_MODE && ConfigValues.ISNIPE_SETTINGS.ANTIKNIFE)
{
DisableKnife();
WriteLog.Debug("Disable knife");
}
else
{
EnableKnife();
WriteLog.Debug("Enable knife");
}

Call("setdvarifuninitialized", "unlimited_ammo", "2");

if (ConfigValues.settings_unlimited_ammo)
if (ConfigValues.settings_unlimited_ammo || (UTILS_GetDvar("unlimited_ammo") == "1"))
{
WriteLog.Debug("Initializing Unlimited Ammo...");
Call("setdvarifuninitialized", "unlimited_ammo", "1");
UTILS_UnlimitedAmmo();
}

Expand Down
7 changes: 4 additions & 3 deletions BernAdmin/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ public DGAdmin()
InitChatAlias();
}

if (ConfigValues.ISNIPE_SETTINGS.ANTIKNIFE)
if (ConfigValues.ISNIPE_MODE && ConfigValues.ISNIPE_SETTINGS.ANTIKNIFE)
DisableKnife();
else
EnableKnife();

if (ConfigValues.settings_unlimited_ammo)
Call("setdvarifuninitialized", "unlimited_ammo", "2");

if (ConfigValues.settings_unlimited_ammo || (UTILS_GetDvar("unlimited_ammo") == "1"))
{
WriteLog.Debug("Initializing Unlimited Ammo...");
Call("setdvarifuninitialized", "unlimited_ammo", "1");
UTILS_UnlimitedAmmo();
}

Expand Down
24 changes: 19 additions & 5 deletions BernAdmin/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,16 +1152,27 @@ public void UTILS_BetterBalance(Entity player, Entity inflictor, Entity attacker

public void UTILS_UnlimitedAmmo(bool force = false)
{
if ((!ConfigValues.settings_unlimited_ammo || Call<string>("getdvar", "g_gametype") == "infect") && !force)
return;
string state = UTILS_GetDvar("unlimited_ammo");
switch (state)
{
case "0":
return;
case "1":
break;
case "2":
if ((!ConfigValues.settings_unlimited_ammo || Call<string>("getdvar", "g_gametype") == "infect") && !force)
return;
break;
}

if (ConfigValues.unlimited_ammo_active)
return;
ConfigValues.unlimited_ammo_active = true;

OnInterval(50, () =>
{
if(UTILS_GetDvar("unlimited_ammo") == "1")
foreach(Entity player in from player in Players where player.IsAlive select player)
if ((UTILS_GetDvar("unlimited_ammo") == "1") || (UTILS_GetDvar("unlimited_ammo") == "2"))
foreach (Entity player in from player in Players where player.IsAlive select player)
{
var Currwep = player.CurrentWeapon;
var offhandAmmo = player.Call<string>("getcurrentoffhand");
Expand All @@ -1173,7 +1184,10 @@ public void UTILS_UnlimitedAmmo(bool force = false)
player.Call("setweaponammoclip", Currwep, 99, "left");
player.Call("setweaponammoclip", Currwep, 99, "right");
}
return true;
else
ConfigValues.unlimited_ammo_active = false;

return ConfigValues.unlimited_ammo_active;
});
}

Expand Down
Binary file modified BernAdmin/bin/Debug/DGAdmin.dll
Binary file not shown.
Binary file modified BernAdmin/bin/Release/DGAdmin.dll
Binary file not shown.

0 comments on commit f2a05e0

Please sign in to comment.