• Хостинг игровых серверов

    Максимальная производительность для ваших игровых серверов!

    Заказать сейчас
VZ2SvMJ.png

IPAPI_CreateItem - creates and returns an enhanced item using the details fed into the method. If shortname is left blank, it will pick a random valid item. If api_perks is null it will pick random perk(s) and add them.
Returns Item

[HookMethod("IPAPI_CreateItem")]
public object IPAPI_CreateItem(string shortname = null, ulong skin = 0, Dictionary<string, float> api_perks = null)
{
List<KeyValuePair<Perk, float>> perks = Pool.GetList<KeyValuePair<Perk, float>>();
foreach (var perk in api_perks)
{
Perk _perk;
if (parsedEnums.TryGetValue(perk.Key, out _perk)) perks.Add(new KeyValuePair<Perk, float>(_perk, perk.Value));
}
var result = CreateItem(shortname, skin, perks);

Pool.FreeList(ref perks);
// Returns an Item class
return result;
}
Example usage:

[ChatCommand("testipapi")]
void TestIPAPI(BasePlayer player)
{
Dictionary<string, float> perks = new Dictionary<string, float>()
{
["Prospector"] = 1f,
["Lumberjack"] = 1f,
["Butcher"] = 1f,
["Horticulture"] = 0.5f
};

var item = (Item)ItemPerks.Call("IPAPI_CreateItem", "hammer.salvaged", (ulong)2830083288, perks);

if (item == null)
{
Puts("Failed");
return;
}

item.name = "tool of the trade";

player.GiveItem(item);
}