Allow event alerts

Results 1 to 3 of 3
  1. #1
    Member MattSantos is offline
    MemberRank
    May 2016 Join Date
    94Posts

    Support Allow event alerts

    Hello dear people, I wanted a help to know how I can do that users that do not allow event alerts ( allowevents ) do not receive event alerts, and those who receive permit .
    This is my code :
    using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
    using Plus.HabboHotel.Rooms;
    using Plus.HabboHotel.GameClients;
    using Plus.Communication.Packets.Outgoing.Rooms.Engine;
    using System.Linq;
    using Plus.Communication.Packets.Outgoing.Inventory.Purse;


    namespace Plus.HabboHotel.Rooms.Chat.Commands.Events
    {
    internal class EventAlertCommand : IChatCommand
    {
    public string PermissionRequired
    {
    get
    {
    return "command_event_alert";
    }
    }
    public string Parameters
    {
    get
    {
    return "%message%";
    }
    }
    public string Description
    {
    get
    {
    return "Enviar um alerta de evento";
    }
    }
    public void Execute(GameClient Session, Room Room, string[] Params)
    {
    if (Session != null)
    {
    if (Room != null)
    {
    if (Params.Length == 1)
    {
    Session.SendWhisper("Por favor, digite uma mensagem para enviar.");
    return;
    }
    foreach (GameClient client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
    {


    if (client.GetHabbo().AllowEvents == false)
    Session.SendWhisper("Parece que está havendo um novo evento em nosso hotel. Para reativar as mensagens de eventos digite ;eventosoff");
    }
    foreach (GameClient client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
    {
    string Message = CommandManager.MergeParams(Params, 1);
    if (client.GetHabbo().AllowEvents == true)


    PlusEnvironment.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("Está acontecendo um evento!",
    "Está acontecendo um novo jogo realizado pela equipe Staff! <br><br>Este, tem o intuito de proporcionar um entretenimento a mais para os usuários!<br><br>Evento: <b>" + Message +
    "</b><br>Por: <b>" + Session.GetHabbo().Username +
    "</b> <br><br>Caso deseje participar, clique no botão abaixo!",
    "sp_staffevent", "Participar do Evento", "event:navigator/goto/" + Session.GetHabbo().CurrentRoomId));
    }
    }
    }
    }
    }
    }
    Pastebin: fff - Pastebin.com


  2. #2
    Account Upgraded | Title Enabled! streamhotel is offline
    MemberRank
    Apr 2012 Join Date
    EarthLocation
    511Posts

    Re: Allow event alerts

    @MattSantos

    Why do you do an second foreach? Do you actually know what you're doing? First of all, your code looks like shit.

    - - - Updated - - -

    Why do you do an second foreach? Do you actually know what you're doing? Look at the code below that I create for u to understand how you need to deal with this issue.

    Code:
    foreach (GameClient client in PlusEnvironment.GetGame().
    GetClientManager().GetClients.ToList())
    {
    
     if (client.GetHabbo().AllowEvents == true)
    
     { 
    
     client.SendMessage(new MOTDNotificationComposer(new RoomNotificationComposer
     ("Message from an Event Manager",
     "There's a new game playing organised by staff! <br><br>Join it to win 
     cool prizes and for FUN!<br>  <br>Which event? <b>" + Message +
     "</b><br>Organized by: <b>" + Session.GetHabbo().Username +
     "</b> <br><br>Where are u waiting for? GO!",
     "sp_staffevent", "Join it", "event:navigator/goto/" 
     + Session.GetHabbo().CurrentRoomId));
    
     } 
    
    else
    
     {
    
     client.SendWhisper("You didn't enabled the option for receiving event alerts, 
     please re-enable with :eventsoff");
     
     }
    
    }
    What you actually did wrong is foreaching items that you don't use later. And foreaching an second time is useless and just slow down it's process.
    Last edited by streamhotel; 07-09-16 at 08:53 AM.

  3. #3
    Member MattSantos is offline
    MemberRank
    May 2016 Join Date
    94Posts

    Re: Allow event alerts

    Thanks boy



Advertisement