Suggestions

j0ker

$client = socket_accept($sock);
Dec 29, 2010
79
22
So I'm just dabbling into PlusEMU, im trying to make a simple mp5 command with a time delay between each room.sendmessage, any suggestions? heres the code im using:

Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Rooms;
using Plus.HabboHotel.Pathfinding;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class mp5Command : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_mp5"; }
        }

        public string Parameters
        {
            get { return "%name%"; }
        }

        public string Description
        {
            get { return "Shoot a user"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Choose a user");
                return;
            }

            if (!Room.PushEnabled && !Session.GetHabbo().GetPermissions().HasRight("room_override_custom_config"))
            {
                Session.SendWhisper("Room owner disabled shooting.");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("User doesnt exist!");
                return;
            }

            RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);
            if (TargetUser == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online or in this room.");
                return;
            }

            if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)
            {
                Session.SendWhisper("You cant shoot yourself!");
                return;
            }

            if (TargetUser.TeleportEnabled)
            {
                Session.SendWhisper("Oops, this person disabled violence!");
                return;
            }

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


        
                ThisUser.ApplyEffect(499);

            Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* Pulls out MP5 *", 1, ThisUser.LastBubble));
                Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* takes aim at " + Params[1] + " *", 1, ThisUser.LastBubble));
            TargetUser.ApplyEffect(93);
                Room.SendMessage(new ChatComposer(TargetUser.VirtualId, "* has died from a fatal gunshot wound *", 1, ThisUser.LastBubble));
                ThisUser.ApplyEffect(0);
                TargetUser.ApplyEffect(0);
            }

        }
    }
 

JynX

Posting Freak
Feb 6, 2016
710
438
All you would need to do would be where it runs it execute a task
Code:
Task.Run(async delegate
{
    Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* Pulls out MP5 *", 1, ThisUser.LastBubble));
    await Task.Delay(5000);
    Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* takes aim at " + Params[1] + " *", 1, ThisUser.LastBubble));
});
Note the 5000 is the amount in ms so:
5000 = 5s
1000 = 1s
10000 = 10s
 

j0ker

$client = socket_accept($sock);
Dec 29, 2010
79
22
All you would need to do would be where it runs it execute a task
Code:
Task.Run(async delegate
{
    Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* Pulls out MP5 *", 1, ThisUser.LastBubble));
    await Task.Delay(5000);
    Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "* takes aim at " + Params[1] + " *", 1, ThisUser.LastBubble));
});
Note the 5000 is the amount in ms so:
5000 = 5s
1000 = 1s
10000 = 10s

Perfect, just had to add "using System.Threading.Tasks;" and then I was able to run tasks, Thanks man helped a lot :) taught me something new :)
 

Users who are viewing this thread

Top