INACTIVE PlusEMU RP Versio

Status
Not open for further replies.
May 1, 2015
467
152
Hello,
I've decided to start working on an RP Emulator - This wont be anything spectacular it'll just be a basic roleplay emulator.
It will have basic functions like:
- Jobs
- a few furniture interactions (may code farming, you can suggest other ideas)
- Jail System
and a few more things.

I would like some c# developers to step up and comment below if they'd like to be apart of the project.

I just started this 30 minutes ago, and have some of the user manager coded.
Code:
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Threading;

using log4net;

using Plus.Core;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Groups;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Achievements;
using Plus.HabboHotel.Users.Badges;
using Plus.HabboHotel.Users.Inventory;
using Plus.HabboHotel.Users.Messenger;
using Plus.HabboHotel.Users.Relationships;
using Plus.HabboHotel.Users.UserDataManagement;

using Plus.HabboHotel.Users.Process;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;


using Plus.HabboHotel.Users.Navigator.SavedSearches;
using Plus.HabboHotel.Users.Effects;
using Plus.HabboHotel.Users.Messenger.FriendBar;
using Plus.HabboHotel.Users.Clothing;
using Plus.Communication.Packets.Outgoing.Navigator;
using Plus.Communication.Packets.Outgoing.Rooms.Engine;
using Plus.Communication.Packets.Outgoing.Rooms.Session;
using Plus.Communication.Packets.Outgoing.Handshake;
using Plus.Database.Interfaces;
using Plus.HabboHotel.Rooms.Chat.Commands;
using Plus.HabboHotel.Users.Permissions;
using Plus.HabboHotel.Subscriptions;
using Plus.HabboHotel.Users.Calendar;

namespace Plus.HabboHotel.Users
{
    public class Roleplay
    {
        private static readonly ILog Log = LogManager.GetLogger("Plus.HabboHotel.Users.Roleplay");

        // User Information
        public int UserId;
        public string Motto;
        GameClient user;

        // Health
        public int Health;

        // Taxi System
        public int GoingToId;

        // Police System
        public bool Wanted;
        public bool InJail;
        public int JailTime;

        // Load The Data.
        private void LoadUserData()
        {
            if (this.UserId > 0)
            {
                int health = 100;
                bool injail = false;
                int jailtime = 0;

                using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    Adapter.SetQuery("SELECT * FROM rp_data WHERE userid @id");
                    Adapter.AddParameter("id", this.UserId);

                    DataRow Row = Adapter.getRow();
                    if (Row != null)
                    {
                        health = Convert.ToInt32(Row["health"]);
                        injail = PlusEnvironment.EnumToBool(Row["in_jail"].ToString());
                        jailtime = Convert.ToInt32(Row["jail_time"]);
                    }
                    else
                    {
                        // New User
                        Adapter.SetQuery("INSERT INTO rp_data (userid) VALUES @id");
                        Adapter.AddParameter("id", this.UserId);
                        Adapter.RunQuery();
                    }
                }

                this.Health = health;
                this.InJail = false;
                this.JailTime = jailtime;
                this.Motto = "Citizen";
            }
        }

        public Roleplay(int Id)
        {
            this.UserId = Id;
            this.LoadUserData();
        }

        public void Chat(string msg)
        {
            GameClient User = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId);
            User.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(User.GetHabbo().Username).OnChat(0, msg, false);
        }

        public GameClient GetClient
        {
            get { return PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId); }
        }

    
        public void CallTaxi(int ID)
        {
            this.GoingToId = ID;
            RoomData Room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(ID);
            if (Room == null)
                return;

            this.Chat("*Whistles for a taxi to " + Room.Name + "*");

            new Thread(() =>
            {
                Thread.Sleep(10000);
                this.GetClient.GetHabbo().Credits -= 15;
                this.GetClient.SendMessage(new CreditBalanceComposer(this.GetClient.GetHabbo().Credits));
                this.GetClient.GetHabbo().PrepareRoom(ID, "");
            }).Start();
        }
    }
}
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class TaxiCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_taxi"; }
        }
        public string Parameters
        {
            get { return "%roomid%"; }
        }
        public string Description
        {
            get { return "Call a taxi to another room"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Session.GetHabbo().Roleplay.GoingToId > 0)
            {
                Session.GetHabbo().Roleplay.Chat("*Cancels their taxi*");
                return;
            }

            if (Session.GetHabbo().Roleplay.InJail)
                return;

            int Id = Convert.ToInt32(Params[1]);

            if (Id == Session.GetHabbo().CurrentRoomId)
                return;

            if (Session.GetHabbo().Credits < 15)
            {
                Session.SendWhisper("You cannot afford the taxi! ($15)");
                return;
            }

            Session.GetHabbo().Roleplay.CallTaxi(Id);
        }
    }
}
I don't have time to be contributing a lot everyday, or spending several hours on end but i do promise a fully functioning RP Emulator.
Thanks, please comment feedback to improve the code or suggest ideas :)
 
Last edited:

SOUL

┼ ┼ ┼
Nov 10, 2015
224
45
Hello,
I've decided to start working on an RP Emulator - This wont be anything spectacular it'll just be a basic roleplay emulator.
It will have basic functions like:
- Jobs
- a few furniture interactions (may code farming, you can suggest other ideas)
- Jail System
and a few more things.

I would like some c# developers to step up and comment below if they'd like to be apart of the project.

I just started this 30 minutes ago, and have some of the user manager coded.
Code:
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Threading;

using log4net;

using Plus.Core;
using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Groups;
using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Achievements;
using Plus.HabboHotel.Users.Badges;
using Plus.HabboHotel.Users.Inventory;
using Plus.HabboHotel.Users.Messenger;
using Plus.HabboHotel.Users.Relationships;
using Plus.HabboHotel.Users.UserDataManagement;

using Plus.HabboHotel.Users.Process;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;


using Plus.HabboHotel.Users.Navigator.SavedSearches;
using Plus.HabboHotel.Users.Effects;
using Plus.HabboHotel.Users.Messenger.FriendBar;
using Plus.HabboHotel.Users.Clothing;
using Plus.Communication.Packets.Outgoing.Navigator;
using Plus.Communication.Packets.Outgoing.Rooms.Engine;
using Plus.Communication.Packets.Outgoing.Rooms.Session;
using Plus.Communication.Packets.Outgoing.Handshake;
using Plus.Database.Interfaces;
using Plus.HabboHotel.Rooms.Chat.Commands;
using Plus.HabboHotel.Users.Permissions;
using Plus.HabboHotel.Subscriptions;
using Plus.HabboHotel.Users.Calendar;

namespace Plus.HabboHotel.Users
{
    public class Roleplay
    {
        private static readonly ILog Log = LogManager.GetLogger("Plus.HabboHotel.Users.Roleplay");

        // User Information
        public int UserId;
        public string Motto;
        GameClient user;

        // Health
        public int Health;

        // Taxi System
        public int GoingToId;

        // Police System
        public bool Wanted;
        public bool InJail;
        public int JailTime;

        // Load The Data.
        private void LoadUserData()
        {
            if (this.UserId > 0)
            {
                int health = 100;
                bool injail = false;
                int jailtime = 0;

                using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    Adapter.SetQuery("SELECT * FROM rp_data WHERE userid @id");
                    Adapter.AddParameter("id", this.UserId);

                    DataRow Row = Adapter.getRow();
                    if (Row != null)
                    {
                        health = Convert.ToInt32(Row["health"]);
                        injail = PlusEnvironment.EnumToBool(Row["in_jail"].ToString());
                        jailtime = Convert.ToInt32(Row["jail_time"]);
                    }
                    else
                    {
                        // New User
                        Adapter.SetQuery("INSERT INTO rp_data (userid) VALUES @id");
                        Adapter.AddParameter("id", this.UserId);
                        Adapter.RunQuery();
                    }
                }

                this.Health = health;
                this.InJail = false;
                this.JailTime = jailtime;
                this.Motto = "Citizen";
            }
        }

        public Roleplay(int Id)
        {
            this.UserId = Id;
            this.LoadUserData();
        }

        public void Chat(string msg)
        {
            GameClient User = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId);
            User.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(User.GetHabbo().Username).OnChat(0, msg, false);
        }

        public GameClient GetClient
        {
            get { return PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId); }
        }

  
        public void CallTaxi(int ID)
        {
            this.GoingToId = ID;
            RoomData Room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(ID);
            if (Room == null)
                return;

            this.Chat("*Whistles for a taxi to " + Room.Name + "*");

            new Thread(() =>
            {
                Thread.Sleep(10000);
                this.GetClient.GetHabbo().Credits -= 15;
                this.GetClient.SendMessage(new CreditBalanceComposer(this.GetClient.GetHabbo().Credits));
                this.GetClient.GetHabbo().PrepareRoom(ID, "");
            }).Start();
        }
    }
}
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
    class TaxiCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_taxi"; }
        }
        public string Parameters
        {
            get { return "%roomid%"; }
        }
        public string Description
        {
            get { return "Call a taxi to another room"; }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Session.GetHabbo().Roleplay.GoingToId > 0)
            {
                Session.GetHabbo().Roleplay.Chat("*Cancels their taxi*");
                return;
            }

            if (Session.GetHabbo().Roleplay.InJail)
                return;

            int Id = Convert.ToInt32(Params[1]);

            if (Id == Session.GetHabbo().CurrentRoomId)
                return;

            if (Session.GetHabbo().Credits < 15)
            {
                Session.SendWhisper("You cannot afford the taxi! ($15)");
                return;
            }

            Session.GetHabbo().Roleplay.CallTaxi(Id);
        }
    }
}
I don't have time to be contributing a lot everyday, or spending several hours on end but i do promise a fully functioning RP Emulator.
Thanks, please comment feedback to improve the code or suggest ideas :)

User manager reminds me of Amp -> if you're using it as reference it's always nice to leave credits!

Goodluck
 
May 1, 2015
467
152
User manager reminds me of Amp -> if you're using it as reference it's always nice to leave credits!

Goodluck
All I used from amp was the loading of the user (loaduserdata method) I don't mean to diss jonteh but he's not the best when it comes to emulators.
 

SOUL

┼ ┼ ┼
Nov 10, 2015
224
45
All I used from amp was the loading of the user (loaduserdata method) I don't mean to diss jonteh but he's not the best when it comes to emulators.

His code does follow bad practices although doesn't damage the performance of the emulator.
OT: Use Task.Delay over thread sleeps , no need to block the current thread to delay a task.
I.e. (Snippet from MSDN) ->

Code:
var t = Task.Run(async delegate
            {
                await Task.Delay(5000);
                // Code
            });
            t.Wait();
          
        }
 

Platinum

Hello!
Sep 2, 2012
295
282
@Altercationz Has been working on another project, and we've watched him code certain functions without having to copy code from elsewhere; I can promise you this. We TV him quite often! @HighlySkilledHabbo Feel more than free to join the TV session whenever you like, I've pasted the ID & PW in the Habbo ShoutBox from time to time. All are welcome :)
 

SOUL

┼ ┼ ┼
Nov 10, 2015
224
45
Curious why are self explanatory things documented such as integers?
 

Zenuyasha

</Dev>
Dec 5, 2016
170
48
I don't even use rz anymore and haven't for months.
Like i said, please find the exploits because there aren't any, I'll wait.
Being the nice guy i am, i went and grabbed the only commands that i released and these were several months ago and not even for sledmore's edit of plus emulator, please point out the exploits!

Code:
public void balance()
       {
           int Credits = Session.GetHabbo().Credits;
           int Pixels = Session.GetHabbo().ActivityPoints;
           uint Rank = Session.GetHabbo().Rank;
           string Output = String.Empty;


           using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().getQueryreactor())
           {
               Adapter.runFastQuery("SELECT credits, activity_points, rank FROM users WHERE username = @Me");
               Adapter.addParameter("Me", Session.GetHabbo().Username);


               DataTable Table = Adapter.getTable();
               if (Table != null)
               {
                   Output += "Account Balance for " + Session.GetHabbo().Username + "\r";
                   Output += "--------------------------------\r";
                   Output += "Credits: " + Credits.ToString() + "\r";
                   Output += "Pixels: " + Pixels.ToString() + "\r";
                   Output += "Rank: " + Rank.ToString() + "\r";


                   Session.SendNotifWithScroll(Output);
               }
           }
       }
Code:
public void hug(string[] Params)
       {
           string text = MergeParams(Params, 1);


           Habbo Habbo1 = this.Session.GetHabbo();
           if (Habbo1.CurrentRoom != null)
           {
               RoomUser User1 = Habbo1.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Habbo1.Id);
               if (User1 != null)
               {
                   RoomUser User2 = Habbo1.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(text);
                   if (User2 == null)
                   {
                       this.Session.SendWhisper("Open your eyes! " + text + " is not in the room.");
                       return;
                   }
                   else if (new Vector2D(User1.Coordinate.X, User1.Coordinate.Y).GetDistanceSquared(new Vector2D(User2.Coordinate.X, User2.Coordinate.Y)) > 2)
                   {
                       this.Session.SendWhisper("The user is too far away, try getting closer.");
                       return;
                   }
                   User1.Chat(User1.GetClient(), "*Hugs " + text + "*", true, 0);
                   User1.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(9);
               }
           }
       }
I suggest you should put what are you going to put in the emu so know what other things we can suggest
 
May 1, 2015
467
152
I suggest you should put what are you going to put in the emu so know what other things we can suggest
you're right, lets hop back on topic.
I coded a marriage system - utilizing the relationship system and plan on coding some nice things for marriages. @Velaski helped with this.
I plan on coding some furniture interactions, such as fishing and farming with bots to sell items that you can use to do both of those tasks.
I'm open to suggestions and need some ideas, so please let me know anything you think of.
 
Last edited:

Zenuyasha

</Dev>
Dec 5, 2016
170
48
you're right, lets hop back on topic.
I coded a marriage system - utilizing the relationship system and plan on coding some nice things for marriages. @Velaski helped with this.
I plan on coding some furniture interactions, such as fishing and farming with bots to sell items that you can use to do both of those tasks.
I'm open to suggestions and need some ideas, so please let me know anything you think of.
Apartments, gangs, weapon system, a government system would be unique also
 
May 1, 2015
467
152
I finished the jobs it took me awhile to figure out the join query since i've never used one before - but it worked out good.
I also started working on gangs and have a little done, will post snippets below - here are the job snippets and screenshots:



Code:
public void StartWork(GameClient Session, int JobId, int JobRank)
        {
            string RankName = null;
            int Pay = 0;
            string MaleUni = null;
            string FemaleUni = null;
            string JobMotto = null;
            string JobLook = null;
            string JobName = null;
            int JobRoomId = 0;
            bool CanExitHeadquarters = false;

            if (Session == null)
                return;

            Room Room = Session.GetHabbo().CurrentRoom;
            if (Room == null)
                return;

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            if (Session.GetHabbo().Roleplay.IsWorking)
            {
                Session.SendWhisper("You are already working!");
                return;
            }

            if (JobId == 0 && JobRank == 0)
            {
                Session.GetHabbo().Roleplay.IsWorking = true;
                Session.GetHabbo().Roleplay.OnTheClock = DateTime.Now;
                Session.GetHabbo().Roleplay.Payment = 15;
                Session.GetHabbo().Roleplay.CanExitHeadQuarters = true;
                string OldMotto = Session.GetHabbo().Motto;
                Session.GetHabbo().Motto = "[WORKING] Welfare";
                Room.SendMessage(new UserChangeComposer(User, true));

                Session.GetHabbo().Roleplay.Chat("*Starts collecting welfare*");
                Session.GetHabbo().Roleplay.StartWorkTimer(15);
            }
            else
            {
                using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    Adapter.SetQuery("SELECT a.*,b.* FROM rp_jobs AS A JOIN rp_ranks AS b ON (a.id = b.job_id) WHERE b.job_id = @jobid AND b.rank_id = @rankid");
                    Adapter.AddParameter("jobid", JobId);
                    Adapter.AddParameter("rankid", JobRank);
                    Adapter.RunQuery();

                    DataTable Table = Adapter.getTable();

                    if (Table != null)
                    {
                        foreach (DataRow Row in Table.Rows)
                        {
                            JobId = Convert.ToInt32(Row["job_id"]);
                            RankName = Convert.ToString(Row["job_name"]);
                            Pay = Convert.ToInt32(Row["pay"]);
                            MaleUni = Convert.ToString(Row["male_uni"]);
                            FemaleUni = Convert.ToString(Row["female_uni"]);
                            JobMotto = Convert.ToString(Row["motto"]);
                            JobRoomId = Convert.ToInt32(Row["roomid"]);
                            JobName = Convert.ToString(Row["rank_name"]);
                            CanExitHeadquarters = PlusEnvironment.EnumToBool(Row["exithq"].ToString());

                            if (Session.GetHabbo().CurrentRoomId != JobRoomId)
                            {
                                Session.SendWhisper("You must be in your job headquarters to start working!");
                                return;
                            }

                            Session.GetHabbo().Roleplay.LookBeforeWork = Session.GetHabbo().Look;
                            this.UpdateClothing(Session, (Session.GetHabbo().Gender.ToLower() == "m" ? MaleUni : FemaleUni));

                            Session.GetHabbo().Look = JobLook;
                            Session.GetHabbo().Roleplay.OldMotto = Session.GetHabbo().Motto;
                            Session.GetHabbo().Motto = "[Working] " + JobName + "";
                            Session.GetHabbo().Roleplay.Payment = Pay;
                            Session.GetHabbo().Roleplay.IsWorking = true;
                            Session.GetHabbo().Roleplay.CanExitHeadQuarters = CanExitHeadquarters ? true : false;
                     

                            Session.GetHabbo().Roleplay.Chat("*Starts working as a " + JobName + "*");
                            Session.SendWhisper("Your current pay is $" + Pay + " and you will receive it in 10 minutes.");

                            Session.GetHabbo().Roleplay.StartWorkTimer(Session.GetHabbo().Roleplay.Payment);

                            Room.SendMessage(new UserChangeComposer(User, false));
                            Session.GetHabbo().CurrentRoom.SendMessage(new UserChangeComposer(User, false));
                        }
                    }
                }
            }
        }
Code:
public void StopWorking(GameClient Session)
        {
            if (Session == null)
                return;

            Room Room = Session.GetHabbo().CurrentRoom;
            if (Room == null)
                return;

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            Session.GetHabbo().Motto = Session.GetHabbo().Roleplay.OldMotto;
            Session.GetHabbo().Look = Session.GetHabbo().Roleplay.LookBeforeWork;
            Session.GetHabbo().Roleplay.IsWorking = false;
            Session.GetHabbo().Roleplay.Payment = 0;

            Room.SendMessage(new UserChangeComposer(User, false));
            Session.GetHabbo().CurrentRoom.SendMessage(new UserChangeComposer(User, false));

            Session.GetHabbo().Roleplay.StopWorkTimer(Session);

            if (Session.GetHabbo().Roleplay.JobId == 0 && Session.GetHabbo().Roleplay.JobRank == 0)
            {
                Session.GetHabbo().Roleplay.Chat("*Stops collecting welfare*");
            }
            else
            {
                Session.GetHabbo().Roleplay.Chat("*Stops Working*");
            }
        }
    }
}
I also redid the timers and moved them into the main roleplay class.
Code:
public void CreateGang(GameClient Session, string GangName)
        {
            using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                Adapter.SetQuery("SELECT * FROM rp_gangs WHERE name = @name");
                Adapter.AddParameter("name", GangName);
                Adapter.RunQuery();

                DataRow Row = Adapter.getRow();
                if (Row != null)
                {
                    Adapter.SetQuery("INSERT INTO rp_gangs (`owner_id`, `gang_name` `kills`) VALUES ('" + Session.GetHabbo().Id + "',@name,0)");
                    Adapter.AddParameter("name", GangName);
                    Adapter.RunQuery();

                    Session.SendWhisper("You have successfully created the gang " + GangName + "!");
                }
                else
                {
                    Session.SendWhisper("That gang exists already!");
                    return;
                }
            }
        }
I plan on putting the gangs in a list using linq to better manage them - and speed things up - sometime soon.
I started on a simple fishing system to catch & eat the fish for health but that will be posted when i'm finished with it.
P.S - Someone please make a decent police cadet uniform and send me the code <3_<3
 

Zenuyasha

</Dev>
Dec 5, 2016
170
48
I finished the jobs it took me awhile to figure out the join query since i've never used one before - but it worked out good.
I also started working on gangs and have a little done, will post snippets below - here are the job snippets and screenshots:



Code:
public void StartWork(GameClient Session, int JobId, int JobRank)
        {
            string RankName = null;
            int Pay = 0;
            string MaleUni = null;
            string FemaleUni = null;
            string JobMotto = null;
            string JobLook = null;
            string JobName = null;
            int JobRoomId = 0;
            bool CanExitHeadquarters = false;

            if (Session == null)
                return;

            Room Room = Session.GetHabbo().CurrentRoom;
            if (Room == null)
                return;

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            if (Session.GetHabbo().Roleplay.IsWorking)
            {
                Session.SendWhisper("You are already working!");
                return;
            }

            if (JobId == 0 && JobRank == 0)
            {
                Session.GetHabbo().Roleplay.IsWorking = true;
                Session.GetHabbo().Roleplay.OnTheClock = DateTime.Now;
                Session.GetHabbo().Roleplay.Payment = 15;
                Session.GetHabbo().Roleplay.CanExitHeadQuarters = true;
                string OldMotto = Session.GetHabbo().Motto;
                Session.GetHabbo().Motto = "[WORKING] Welfare";
                Room.SendMessage(new UserChangeComposer(User, true));

                Session.GetHabbo().Roleplay.Chat("*Starts collecting welfare*");
                Session.GetHabbo().Roleplay.StartWorkTimer(15);
            }
            else
            {
                using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    Adapter.SetQuery("SELECT a.*,b.* FROM rp_jobs AS A JOIN rp_ranks AS b ON (a.id = b.job_id) WHERE b.job_id = @jobid AND b.rank_id = @rankid");
                    Adapter.AddParameter("jobid", JobId);
                    Adapter.AddParameter("rankid", JobRank);
                    Adapter.RunQuery();

                    DataTable Table = Adapter.getTable();

                    if (Table != null)
                    {
                        foreach (DataRow Row in Table.Rows)
                        {
                            JobId = Convert.ToInt32(Row["job_id"]);
                            RankName = Convert.ToString(Row["job_name"]);
                            Pay = Convert.ToInt32(Row["pay"]);
                            MaleUni = Convert.ToString(Row["male_uni"]);
                            FemaleUni = Convert.ToString(Row["female_uni"]);
                            JobMotto = Convert.ToString(Row["motto"]);
                            JobRoomId = Convert.ToInt32(Row["roomid"]);
                            JobName = Convert.ToString(Row["rank_name"]);
                            CanExitHeadquarters = PlusEnvironment.EnumToBool(Row["exithq"].ToString());

                            if (Session.GetHabbo().CurrentRoomId != JobRoomId)
                            {
                                Session.SendWhisper("You must be in your job headquarters to start working!");
                                return;
                            }

                            Session.GetHabbo().Roleplay.LookBeforeWork = Session.GetHabbo().Look;
                            this.UpdateClothing(Session, (Session.GetHabbo().Gender.ToLower() == "m" ? MaleUni : FemaleUni));

                            Session.GetHabbo().Look = JobLook;
                            Session.GetHabbo().Roleplay.OldMotto = Session.GetHabbo().Motto;
                            Session.GetHabbo().Motto = "[Working] " + JobName + "";
                            Session.GetHabbo().Roleplay.Payment = Pay;
                            Session.GetHabbo().Roleplay.IsWorking = true;
                            Session.GetHabbo().Roleplay.CanExitHeadQuarters = CanExitHeadquarters ? true : false;
                    

                            Session.GetHabbo().Roleplay.Chat("*Starts working as a " + JobName + "*");
                            Session.SendWhisper("Your current pay is $" + Pay + " and you will receive it in 10 minutes.");

                            Session.GetHabbo().Roleplay.StartWorkTimer(Session.GetHabbo().Roleplay.Payment);

                            Room.SendMessage(new UserChangeComposer(User, false));
                            Session.GetHabbo().CurrentRoom.SendMessage(new UserChangeComposer(User, false));
                        }
                    }
                }
            }
        }
Code:
public void StopWorking(GameClient Session)
        {
            if (Session == null)
                return;

            Room Room = Session.GetHabbo().CurrentRoom;
            if (Room == null)
                return;

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            Session.GetHabbo().Motto = Session.GetHabbo().Roleplay.OldMotto;
            Session.GetHabbo().Look = Session.GetHabbo().Roleplay.LookBeforeWork;
            Session.GetHabbo().Roleplay.IsWorking = false;
            Session.GetHabbo().Roleplay.Payment = 0;

            Room.SendMessage(new UserChangeComposer(User, false));
            Session.GetHabbo().CurrentRoom.SendMessage(new UserChangeComposer(User, false));

            Session.GetHabbo().Roleplay.StopWorkTimer(Session);

            if (Session.GetHabbo().Roleplay.JobId == 0 && Session.GetHabbo().Roleplay.JobRank == 0)
            {
                Session.GetHabbo().Roleplay.Chat("*Stops collecting welfare*");
            }
            else
            {
                Session.GetHabbo().Roleplay.Chat("*Stops Working*");
            }
        }
    }
}
I also redid the timers and moved them into the main roleplay class.
Code:
public void CreateGang(GameClient Session, string GangName)
        {
            using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                Adapter.SetQuery("SELECT * FROM rp_gangs WHERE name = @name");
                Adapter.AddParameter("name", GangName);
                Adapter.RunQuery();

                DataRow Row = Adapter.getRow();
                if (Row != null)
                {
                    Adapter.SetQuery("INSERT INTO rp_gangs (`owner_id`, `gang_name` `kills`) VALUES ('" + Session.GetHabbo().Id + "',@name,0)");
                    Adapter.AddParameter("name", GangName);
                    Adapter.RunQuery();

                    Session.SendWhisper("You have successfully created the gang " + GangName + "!");
                }
                else
                {
                    Session.SendWhisper("That gang exists already!");
                    return;
                }
            }
        }
I plan on putting the gangs in a list using linq to better manage them - and speed things up - sometime soon.
I started on a simple fishing system to catch & eat the fish for health but that will be posted when i'm finished with it.
P.S - Someone please make a decent police cadet uniform and send me the code <3_<3
I can't see a thing about when a worker idles
 
Status
Not open for further replies.

Users who are viewing this thread

Top