mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 17:34:33 +01:00
fixes and improvements to give command
This commit is contained in:
@@ -7,7 +7,7 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
{
|
{
|
||||||
[CommandHandler("give", "<sel> [#] [id]", CommandType.Player,
|
[CommandHandler("give", "<sel> [#] [id]", CommandType.Player,
|
||||||
//example commands list
|
//example commands list
|
||||||
"gold 123456789","stigs 1", "weaps", "mats 999 2008", "valks", "outfits"
|
"gold 123456789", "stigs 1", "weaps", "mats 999 2008", "valks", "outfits"
|
||||||
)]
|
)]
|
||||||
internal class GiveCommand : Command
|
internal class GiveCommand : Command
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
public override void Run(Player player, string[] args)
|
public override void Run(Player player, string[] args)
|
||||||
{
|
{
|
||||||
string action = args[0];
|
string action = args[0];
|
||||||
int value = (args.Length > 1 && args[1] is not null) ? int.Parse(args[1]) : -1;
|
int? value = (args.Length >= 2 && args[1] is not null) ? int.Parse(args[1]) : null;
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@@ -91,14 +91,18 @@ namespace PemukulPaku.GameServer.Commands
|
|||||||
case "mats":
|
case "mats":
|
||||||
case "matz":
|
case "matz":
|
||||||
foreach (MaterialDataExcel materialData in MaterialData.GetInstance().All)
|
foreach (MaterialDataExcel materialData in MaterialData.GetInstance().All)
|
||||||
{
|
{
|
||||||
player.Equipment.AddMaterial(materialData.Id, value > 0 || value < -1 ? value : 9999);
|
player.Equipment.AddMaterial(materialData.Id, value is not null && value != 0 ? (int)value : materialData.QuantityLimit);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "material-id":
|
case "material-id":
|
||||||
case "gold":
|
case "gold":
|
||||||
int materialId = args[2] is not null ? int.Parse(args[2]) : 100;
|
int materialId = args.Length >= 3 && args[2] is not null ? int.Parse(args[2]) : 100;
|
||||||
player.Equipment.AddMaterial(materialId, value > 0 || value < -1 ? value : 9999);
|
int? quantityLimit = MaterialData.GetInstance().All.FirstOrDefault(m => m.Id == materialId)?.QuantityLimit;
|
||||||
|
if (quantityLimit is not null)
|
||||||
|
{
|
||||||
|
player.Equipment.AddMaterial(materialId, value is not null && value != 0 ? (int)value : (int)quantityLimit);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "dress":
|
case "dress":
|
||||||
case "outfits":
|
case "outfits":
|
||||||
|
|||||||
Reference in New Issue
Block a user