forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminSpawnItemRange.cs
More file actions
50 lines (43 loc) · 1.38 KB
/
Copy pathAdminSpawnItemRange.cs
File metadata and controls
50 lines (43 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Threading.Tasks;
using L2dotNET.Attributes;
using L2dotNET.Models.Items;
using L2dotNET.Models.Player;
using L2dotNET.Tables;
using Microsoft.Extensions.DependencyInjection;
namespace L2dotNET.Commands.Admin
{
[Command(CommandName = "summon3")]
class AdminSpawnItemRange : AAdminCommand
{
private readonly ItemTable _itemTable;
public AdminSpawnItemRange(IServiceProvider serviceProvider) : base(serviceProvider)
{
_itemTable = serviceProvider.GetService<ItemTable>();
}
protected internal override async Task UseAsync(L2Player admin, string alias)
{
int idmin = int.Parse(alias.Split(' ')[1]);
int idmax = int.Parse(alias.Split(' ')[2]);
if ((idmax - idmin) > 200)
{
await admin.SendMessageAsync("Too big id range.");
return;
}
bool x = false;
for (int i = idmin; i <= idmax; i++)
{
ItemTemplate item = _itemTable.GetItem(i);
if (item == null)
await admin.SendMessageAsync($"Item with id {i} not exists.");
else
{
admin.AddItem(i, 1);
x = true;
}
}
if (x)
admin.SendItemList(true);
}
}
}