using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.HabboHotel.GameClients;
namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
class OnlineCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_online"; }
}
public string Parameters
{
get { return "%test%"; }
}
public string Description
{
get { return "Online command"; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
int OnlineUsers = PlusEnvironment.GetGame().GetClientManager().Count;
Session.SendWhisper("There are " + OnlineUsers + " online, Coolio!");
}
}
}
this.Register("online", new OnlineCommand());
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Plus.Database.Interfaces;
using System.Data;
namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun
{
class WhosOnlineCommand : IChatCommand
{
public string PermissionRequired
{
get { return "command_whosonline"; }
}
public string Parameters
{
get { return ""; }
}
public string Description
{
get { return "Displays the online users"; }
}
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
string Output = "Current Users Online";
Output += "-----------------------\r";
using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
{
Adapter.SetQuery("SELECT FROM users WHERE online = '1'");
Adapter.RunQuery();
DataTable Table = Adapter.getTable();
if (Table != null)
{
foreach (DataRow Row in Table.Rows)
{
Output += Row["username"].ToString() + "\r";
}
}
Session.SendNotification(Output);
}
}
}
}
This appears to be what I'm looking for.I'm pretty sure he wants to be able to view the users online.
Here's the command:
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Plus.Database.Interfaces; using System.Data; namespace Plus.HabboHotel.Rooms.Chat.Commands.User.Fun { class WhosOnlineCommand : IChatCommand { public string PermissionRequired { get { return "command_whosonline"; } } public string Parameters { get { return ""; } } public string Description { get { return "Displays the online users"; } } public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { string Output = "Current Users Online"; Output += "-----------------------\r"; using (IQueryAdapter Adapter = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { Adapter.SetQuery("SELECT FROM users WHERE online = '1'"); Adapter.RunQuery(); DataTable Table = Adapter.getTable(); if (Table != null) { foreach (DataRow Row in Table.Rows) { Output += Row["username"].ToString() + "\r"; } } Session.SendNotification(Output); } } } }
this.Register("whosonline", new WhosOnlineCommand());
Adapter.SetQuery("SELECT username FROM users WHERE online = '1'");
Glad you helped him out - however pulling from the database is not the best way to do this.I messed up the query in the command, lol.
silly mistake. It should be the following:
Code:Adapter.SetQuery("SELECT username FROM users WHERE online = '1'");
public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{
String usersOnline = "Users Online Now [" + PlusEnvironment.GetGame().GetClientManager().GetClients.Count + "]\n================================\n";
foreach (GameClient Client in PlusEnvironment.GetGame().GetClientManager().GetClients)
{
usersOnline += Client.GetHabbo().Username + ", ";
}
Session.SendNotification(usersOnline);
}
My :whosonline command won't take, it just prints the text, any idea?Glad you helped him out - however pulling from the database is not the best way to do this.
This code:
Code:public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { String usersOnline = "Users Online Now [" + PlusEnvironment.GetGame().GetClientManager().GetClients.Count + "]\n================================\n"; foreach (GameClient Client in PlusEnvironment.GetGame().GetClientManager().GetClients) { usersOnline += Client.GetHabbo().Username + ", "; } Session.SendNotification(usersOnline); }
This is how I do mine. (This is not actually tested - but should work).
All of the online sessions are stored in the client manager. No reason to import all the database classes/functions and add extra pull when you can use a Collection already storing this information.
You have to put the permission into the database / add the command to the commandhandler classMy :whosonline command won't take, it just prints the text, any idea?
I don't like the way you coded the command, honestly.Glad you helped him out - however pulling from the database is not the best way to do this.
This code:
Code:public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params) { String usersOnline = "Users Online Now [" + PlusEnvironment.GetGame().GetClientManager().GetClients.Count + "]\n================================\n"; foreach (GameClient Client in PlusEnvironment.GetGame().GetClientManager().GetClients) { usersOnline += Client.GetHabbo().Username + ", "; } Session.SendNotification(usersOnline); }
This is how I do mine. (This is not actually tested - but should work).
All of the online sessions are stored in the client manager. No reason to import all the database classes/functions and add extra pull when you can use a Collection already storing this information.
Hi Jerry,I don't like the way you coded the command, honestly.
This is how I done it:You must be registered for see links
In my code, it shows a list of all online VISIBLE users to everyone and it shows all online VISIBLE and INVISIBLE users to staff members. For the visible/invisible part, it uses a user setting hide_online from the users table. However, my code is cleaner, just saying.
Wondering if you could help me implement this?Hi Jerry,
I'm having trouble implementing it. Can you help me on a more granular basis after I add the file name you've submitted with the same name as the class?