MasterJiq
Member
- Jul 8, 2016
- 385
- 23
Hello,
I would to release my first (in my life) command edit with Plus Emulator, just playing around with it.
So here is the code, it would be 'AddBadgeCommand.cs' or whatever do you want.
Thanks.
I would to release my first (in my life) command edit with Plus Emulator, just playing around with it.
So here is the code, it would be 'AddBadgeCommand.cs' or whatever do you want.
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Communication.Packets.Outgoing.Catalog;
using Plus.Core;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.HabboHotel.GameClients;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
class AddBadgeCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_add_badge"; }
}
public string Parameters
{
get { return "%variable%"; }
}
public string Description
{
get { return "Insert the new badge"; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
if (!Session.GetHabbo().GetPermissions().HasCommand("command_add_badge"))
{
Session.SendWhisper("Oops, you do not have the permission.");
}
if (Params.Length == 1)
{
Session.SendWhisper("Put the correct badge code, title and description.");
return;
}
string badge = Params[1];
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.SetQuery("INSERT INTO `badge_definitions` (code, required_right) VALUES (@badge, '');");
dbClient.AddParameter("badge", badge);
dbClient.RunQuery();
Session.SendWhisper("Added the badge, please use :update badge_definitions to update the badge.");
}
}
}
}
Thanks.