Skip to content

Commit 9f48a98

Browse files
committed
exiled ammo limit methods
1 parent 129914d commit 9f48a98

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Exiled.API.Enums;
2+
using Exiled.API.Features;
3+
using JetBrains.Annotations;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.MethodSystem.BaseMethods;
7+
using SER.Code.MethodSystem.Structures;
8+
using SER.Code.ValueSystem;
9+
10+
namespace SER.Code.MethodSystem.Methods.PlayerMethods;
11+
12+
[UsedImplicitly]
13+
public class GetAmmoLimitMethod : ReturningMethod<NumberValue>, IExiledMethod
14+
{
15+
public override string Description => "Gets the player's limit on a certain ammunition type";
16+
17+
public override Argument[] ExpectedArguments { get; } =
18+
[
19+
new PlayerArgument("player to get the limit from"),
20+
new EnumArgument<AmmoType>("ammo type")
21+
];
22+
23+
public override void Execute()
24+
{
25+
var ammoType = Args.GetEnum<AmmoType>("ammo type");
26+
var player = Args.GetPlayer("player to get the limit from");
27+
28+
ReturnValue = Player.Get(player).GetAmmoLimit(ammoType);
29+
}
30+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Exiled.API.Enums;
2+
using Exiled.API.Features;
3+
using JetBrains.Annotations;
4+
using SER.Code.ArgumentSystem.Arguments;
5+
using SER.Code.ArgumentSystem.BaseArguments;
6+
using SER.Code.MethodSystem.BaseMethods;
7+
using SER.Code.MethodSystem.Structures;
8+
9+
namespace SER.Code.MethodSystem.Methods.PlayerMethods;
10+
11+
[UsedImplicitly]
12+
public class SetAmmoLimitMethod : SynchronousMethod, IExiledMethod
13+
{
14+
public override string Description => "Sets the players' limit on a certain ammunition type";
15+
16+
public override Argument[] ExpectedArguments { get; } =
17+
[
18+
new PlayersArgument("players to set the limit to"),
19+
new EnumArgument<AmmoType>("ammo type"),
20+
new IntArgument("limit", 0, 65535)
21+
{
22+
Description = "The min and max are there so the whole thing doesn't crash from int -> ushort conversion :trollface:"
23+
}
24+
];
25+
26+
public override void Execute()
27+
{
28+
var ammoType = Args.GetEnum<AmmoType>("ammo type");
29+
var limit = (ushort) Args.GetInt("limit");
30+
var labApiPlayers = Args.GetPlayers("players to set the limit to");
31+
labApiPlayers.ForEach(plr => Player.Get(plr).SetAmmoLimit(ammoType, limit));
32+
}
33+
}

0 commit comments

Comments
 (0)