mark1234
Member
- Aug 7, 2015
- 52
- 1
Hello people. i have a question you know in plusemu you have a ban command like this: :ban %username% %length% %reason% but what i want is that the %lengt% automatic is 24H so you only need to fill :ban %username% %reason% for the one who need it i put the command beneeth here:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Utilities;
using Plus.HabboHotel.Users;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Moderation;
using Plus.Database.Interfaces;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
class BanCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_ban"; }
}
public string Parameters
{
get { return "%username% %length% %reason% "; }
}
public string Description
{
get { return "Ban a player."; ; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
if (Params.Length == 1)
{
Session.SendWhisper("dont forget the username ;).");
return;
}
Habbo Habbo = PlusEnvironment.GetHabboByUsername(Params[1]);
if (Habbo == null)
{
Session.SendWhisper("cant find that user in database.");
return;
}
if (Habbo.GetPermissions().HasRight("mod_soft_ban") && !Session.GetHabbo().GetPermissions().HasRight("mod_ban_any"))
{
Session.SendWhisper("Oops, cant ban this user :).");
return;
}
Double Expire = 0;
string Hours = Params[2];
if (String.IsNullOrEmpty(Hours) || Hours == "perm")
Expire = PlusEnvironment.GetUnixTimestamp() + 78892200;
else
Expire = (PlusEnvironment.GetUnixTimestamp() + (Convert.ToDouble(Hours) * 3600));
string Reason = null;
if (Params.Length >= 4)
Reason = CommandManager.MergeParams(Params, 3);
else
Reason = "er is geen reden ingevoerd.";
string Username = Habbo.Username;
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
dbClient.RunQuery("UPDATE `user_info` SET `bans` = `bans` + '1' WHERE `user_id` = '" + Habbo.Id + "' LIMIT 1");
}
PlusEnvironment.GetGame().GetModerationManager().BanUser(Session.GetHabbo().Username, ModerationBanType.USERNAME, Habbo.Username, Reason, Expire);
GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Username);
if (TargetClient != null)
TargetClient.Disconnect();
Session.SendWhisper("Je hebt '" + Username + "' gebant voor " + Hours + " uur met de reden '" + Reason + "'!");
}
}
}