Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Plus] Command and more [wired]

u20

Newbie Spellweaver
Joined
Sep 27, 2016
Messages
26
Reaction score
5
Hi dear.
I'm here to release my command "telephone". It works like the respects: you've 10 messages per day to send.
The idea is good, I think the execution too. I don't know, you'll judge.
The idea is that an user can send a message to another user who have the telephone enabled.
So, we can start.Oh, I'm italian -> texts are in italian.

Go to habbo.cs and add a bool:
Code:
public bool Telefono = false;
Always in habbo.cs search for that:
Code:
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())         
   {                
dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @[I][B][URL="http://forum.ragezone.com/members/1335.html"]user[/URL][/B][/I]_id LIMIT 1");                dbClient.AddParameter("user_id", Id);                StatRow = dbClient.getRow();                if (StatRow == null)//No row, add it yo                {                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + Id + "')");                    dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @[I][B][URL="http://forum.ragezone.com/members/1335.html"]user[/URL][/B][/I]_id LIMIT 1");                    dbClient.AddParameter("user_id", Id);                    StatRow = dbClient.getRow();              
  }
Add the end of the two SELECT (after `forum_posts`) add:
Code:
`messaggi`

Then search below:
Code:
try                
{                    
this._habboStats = new HabboStats(Convert.ToInt32(StatRow["roomvisits"]), Convert.ToDouble(StatRow["onlineTime"]), Convert.ToInt32(StatRow["respect"]), Convert.ToInt32(StatRow["respectGiven"]), Convert.ToInt32(StatRow["giftsGiven"]),                        Convert.ToInt32(StatRow["giftsReceived"]), Convert.ToInt32(StatRow["dailyRespectPoints"]), Convert.ToInt32(StatRow["dailyPetRespectPoints"]), Convert.ToInt32(StatRow["AchievementScore"]),                        Convert.ToInt32(StatRow["quest_id"]), Convert.ToInt32(StatRow["quest_progress"]), Convert.ToInt32(StatRow["groupid"]), Convert.ToString(StatRow["respectsTimestamp"]), Convert.ToInt32(StatRow["forum_posts"]));
and at the end add:
Code:
Convert.ToInt32(StatRow["messaggi"])
(with a comma after forum_posts!).Then, where are:
Code:
this._habboStats.DailyRespectPoints = DailyRespects;              
          this._habboStats.DailyPetRespectPoints = DailyRespects;
add below
Code:
int Messaggi = 10;
this._habboStats.Messaggi = Messaggi;
and below that there is a query that UPDATE the user_stats, add:
Code:
`messaggi` = '" + Messaggi + "'

Then, always in habbo.cs, search for:
Code:
public string GetQueryString        {           
 get            {               
 this._habboSaved = true;
and edit the query adding:
Code:
`messaggi` = '" + this._habboStats.Messaggi + "'
same thing in:
Code:
if (!this._habboSaved)            {                this._habboSaved = true;                
using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())            
 {
edit the update with:
Code:
`messaggi` = '" + this._habboStats.Messaggi + "'
Then go to HabboStats.cs and add (below "forum_posts"):
Code:
public int Messaggi { get; set; }
then replace the HabboStats with that:
Code:
public HabboStats(int roomVisits, double onlineTime, int Respect, int respectGiven, int giftsGiven, int giftsReceived, int dailyRespectPoints, int dailyPetRespectPoints, int achievementPoints, int questID, int questProgress, int groupID, string RespectsTimestamp, int ForumPosts, int Messaggi)       
 {            
this.RoomVisits = roomVisits;           
this.OnlineTime = onlineTime;     
this.Respect = Respect;       
this.RespectGiven = respectGiven;           
this.GiftsGiven = giftsGiven;           
this.GiftsReceived = giftsReceived;            
this.DailyRespectPoints = dailyRespectPoints;            
this.DailyPetRespectPoints = dailyPetRespectPoints;            
this.AchievementPoints = achievementPoints;            
this.QuestID = questID;            
this.QuestProgress = questProgress;            
this.FavouriteGroupId = groupID;            
this.RespectsTimestamp = RespectsTimestamp;            
this.ForumPosts = ForumPosts;            
this.Messaggi = Messaggi; 
}

Go in ProcessComponent.cs and search:
Code:
#region Respect checking                if (this._player.GetStats().RespectsTimestamp != DateTime.Today.ToString("MM/dd"))                {                    this._player.GetStats().RespectsTimestamp = DateTime.Today.ToString("MM/dd");
Replace the query below with that:

Code:
dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20) + "', `dailyPetRespectPoints` = '" + (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20) + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "', `messaggi` = '10'  WHERE `id` = '" + this._player.Id + "' LIMIT 1");
Then we have the command
Code:
using System;
using Plus.HabboHotel.GameClients;
namespace Plus.HabboHotel.Rooms.Chat.Commands
{
    internal class Telefono : IChatCommand
    {
        public string Description {
            get { return "Invia un messaggio ad un amico!"; }
        }


        public string Parameters { get { return "%username% + %messaggio%"; } }
        public string PermissionRequired { get { return "command_telefono"; } }
        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            if (Params.Length == 1 && Session.GetHabbo().Telefono == false)
            {


                //this enable the telephone of user.                
                Session.GetHabbo().Telefono = true;
                Session.SendWhisper("Hai attivato il tuo telefono. Per spegnerlo digita :telefono spento");
            }            if(Params.Length == 2 && Params[1].ToString() == "spento")
            {


                //this disable the telephone of user.                
                Session.GetHabbo().Telefono = false;
                Session.SendWhisper("Hai disattivato il tuo telefono!");
            }
            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);


            // here we've the target, we check if the target exists           
            if (TargetClient == null)
            {
                Session.SendWhisper("Utente non trovato"); // user not found        


                return;
            }
            if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)
            {
                Session.SendWhisper("Non puoi applicare questo comando su di te!");


                // you can't send message at yourself               
                return;
            }


                if (Session.GetHabbo().GetStats().Messaggi == 0)
                {


                // if user has 0 messages => whisper "you don't have message for today"      
                Session.SendWhisper("Hai terminato i messaggi per oggi.");
                return;
            }


                    // here we check if the target client has the telephone enable, and the session has > 0 messages.


                    if (TargetClient.GetHabbo().Telefono == false && Session.GetHabbo().GetStats().Messaggi > 0)
                    {
                        Session.SendWhisper("L'utente da te selezionato ha il telefono spento!"); TargetClient.SendWhisper("L'utente " + Session.GetHabbo().Username + " ha provato ad inviarti un messaggio, ma hai il telefono spento! Per attivarlo digita :telefono.");
                // here we send a whisper to the target client to advice him that X user tried to send to him a message, if you want you can delete that.           
                }
             string Message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(CommandManager.MergeParams(Params, 2));
            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (Session.GetHabbo().GetStats().Messaggi > 0 && TargetClient.GetHabbo().Telefono == true)
            {


                        TargetClient.SendWhisper(Session.GetHabbo().Username + " ti ha inviato un messaggio: " + Message); //here we send the message;    
                Session.SendWhisper("Hai inviato il messaggio a " + TargetClient.GetHabbo().Username);
                ThisUser.CarryItem(1072); // we give the telephone, is so cool.             
                Session.GetHabbo().GetStats().Messaggi -= 1; // delete one message.               
                Session.SendWhisper("Ti rimangono: " + Session.GetHabbo().GetStats().Messaggi + " messaggi per oggi"); // send a whisper to count the message           
            }
        }
    }
}

So, this is the command.
Oh, I forgot the query:
Code:
ALTER TABLE user_stats ADD messaggi int(11) DEFAULT 10;
I want to share to you also another thing. A little wired coded by me some months ago. It allows the user to go to another room enabling a wired effect..

Go in WiredBoxType and add:
Code:
TeleportIntoRoom,
then go WiredBoxTypeUtility.cs and add:
Code:
case 65:                   
 return WiredBoxType.TeleportIntoRoom;
oh, for me the case was 65 for you can be different at 99,9999%.
Then below that there is
Code:
public static int GetWiredId(WiredBoxType Type)
add:
Code:
case WiredBoxType.TeleportIntoRoom:                    
return 7;
then in WiredComponent.cs add:

Code:
case WiredBoxType.TeleportIntoRoom:                   
 return new TeleportIntoRoom(_room, Item);
Create a new class for teleportintoroom wired and paste that:
Code:
using System;
using System.Collections.Concurrent;
using Plus.Communication.Packets.Incoming;
using Plus.HabboHotel.Items;
using Plus.HabboHotel.Items.Wired;
using Plus.HabboHotel.Users;


namespace Plus.HabboHotel.Rooms.Instance
{
    internal class TeleportIntoRoom : IWiredItem
    {
        private Room _room;


        public TeleportIntoRoom(Room _room, Item item)
        {
            {
                this._room = _room;
                this.Item = item;
                this.SetItems = new ConcurrentDictionary<int, Item>();
            }
        }
        public bool BoolData { get; set; }


        public Room Instance { get; set; }
        public Item Item { get; set; }
        public string ItemsData { get; set; }
        public ConcurrentDictionary<int, Item> SetItems { get; set; }
        public string StringData { get; set; }
        public WiredBoxType Type { get { return WiredBoxType.TeleportIntoRoom; } }
        public void HandleSave(ClientPacket Packet)
        {
            int Unknown = Packet.PopInt();
            string Point = Packet.PopString();


            this.StringData = Point;
        }
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
                return false;
            Habbo Owner = PlusEnvironment.GetHabboById(Item.UserID);
      
            Habbo Player = (Habbo)Params[0];
            if (Player == null || Player.GetClient() == null)
                return false;


            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);
            if (User == null)
                return false;


            if (String.IsNullOrEmpty(StringData))
                return false;
            int stanza = Convert.ToInt32(StringData);
            Player.GetClient().GetHabbo().PrepareRoom(stanza, "");
            return true;
        }
    }
}

Ok, it's all. Bye dear
 
Last edited:
Back
Top