MayoMayn
BestDev
- Oct 18, 2016
- 1,423
- 683
Basically I want a command that gives an user an item of x amount.
Currently I can only insert it through the cms and reload all inventories through rcon, which isn't what I want.
As I haven't gotten into the source code of Plus Emulator or the weird structure it would take too long to for me figure out.
This is as far as I've gotten:
@Sledmore wrote something about using ItemFactory instead of
Here's the code snippet for now:
Currently I can only insert it through the cms and reload all inventories through rcon, which isn't what I want.
As I haven't gotten into the source code of Plus Emulator or the weird structure it would take too long to for me figure out.
This is as far as I've gotten:
@Sledmore wrote something about using ItemFactory instead of
Code:
client.GetHabbo().GetInventoryComponent().AddNewItem(0, itemId)
Here's the code snippet for now:
PHP:
using System;
using Plus.HabboHotel.GameClients;
using Plus.Database.Interfaces;
//using Plus.HabboHotel.Users.Inventory
namespace Plus.Communication.RCON.Commands.User
{
class GiveUserItemCommand : IRCONCommand
{
public string Description
{
get { return "This command is used to give a user a specific item."; }
}
public string Parameters
{
get { return "%userId% %itemId% %amount%"; }
}
public bool TryExecute(string[] parameters)
{
int userId = 0;
if (!int.TryParse(parameters[0].ToString(), out userId))
return false;
GameClient client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(userId);
if (client == null || client.GetHabbo() == null)
return false;
int itemId = 0;
if (!int.TryParse(parameters[1].ToString(), out itemId))
return false;
int amount = 0;
if (!int.TryParse(parameters[2].ToString(), out amount))
amount = 1;
while (amount > 0) {
client.GetHabbo().GetInventoryComponent().AddNewItem(0, itemId)
amount--;
}
return true;
}
}
}
Last edited: