#timeban [name][days]
Allows you to ban a characters account for a specified number of days. The characters account will be banned for the number of days right down to the minute of when he/she was banned. Also this will return a -1 which tells the world server that the account is suspended and not banned.
I'v not tested this patch but it does compile just fine.
I am the Lead GM of the Vallon / Tallon Zek server and this was a much needed command and I thought I would share it with the EQ community.
SQL Code
Code:
ALTER TABLE `account` ADD `timebanned` DATETIME NOT NULL
Patch for latest version of PEQ
Code:
Index: common/database.cpp
===================================================================
--- common/database.cpp (revision 1187)
+++ common/database.cpp (working copy)
@@ -307,12 +307,19 @@
MYSQL_RES *result;
MYSQL_ROW row;
- if (RunQuery(query, MakeAnyLenString(&query, "SELECT status FROM account WHERE id='%i'", account_id), errbuf, &result)) {
+ if (RunQuery(query, MakeAnyLenString(&query, "SELECT `status`, UNIX_TIMESTAMP(`timebanned`) as `timebanned`, UNIX_TIMESTAMP() as `current` FROM `account` WHERE `id` = %i", account_id), errbuf, &result)) {
safe_delete_array(query);
if (mysql_num_rows(result) == 1)
{
row = mysql_fetch_row(result);
sint16 status = atoi(row[0]);
+ sint32 timebanned = atoi(row[1]);
+ sint32 current = atoi(row[2]);
+
+ // Check Time Banned
+ if(timebanned > current) {
+ return -1;
+ }
mysql_free_result(result);
return status;
Index: zone/command.cpp
===================================================================
--- zone/command.cpp (revision 1187)
+++ zone/command.cpp (working copy)
@@ -384,6 +384,7 @@
command_add("nologs","[status|normal|error|debug|quest|all] - Unsubscribe to a log type",250,command_nologs) ||
command_add("datarate","[rate] - Query/set datarate",100,command_datarate) ||
command_add("ban","[name] - Ban by character name",150,command_ban) ||
+ command_add("timeban","[name][days] - Ban by character name and for specificed number of days",150,command_timeban) ||
command_add("ipban","[IP address] - Ban IP by character name",200,command_ipban) ||
command_add("oocmute","[1/0] - Mutes OOC chat",200,command_oocmute) ||
command_add("revoke","[charname] [1/0] - Makes charname unable to talk on OOC",200,command_revoke) ||
@@ -6287,6 +6288,55 @@
}
}
+void command_timeban(Client *c, const Seperator *sep)
+{
+ char errbuf[MYSQL_ERRMSG_SIZE];
+ char *query = 0;
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+
+ if(sep->arg[1][0] == 0) {
+ c->Message(0, "Usage: #ban [charname][days]");
+ } else {
+ database.RunQuery(query, MakeAnyLenString(&query, "SELECT `account_id` FROM `character_` WHERE `name` = '%s'", sep->arg[1]), errbuf, &result);
+ if(query) {
+ safe_delete_array(query);
+ }
+ if(mysql_num_rows(result)) {
+ row = mysql_fetch_row(result);
+ database.RunQuery(query, MakeAnyLenString(&query, "UPDATE `account` SET `timebanned` = DATE_ADD(NOW(), INTERVAL %i DAY) WHERE `id` = %i", sep->arg[1], atoi(row[0])), errbuf, 0);
+ c->Message(13,"Account number %i with the character %s has been temporary banned for %i days.", atoi(row[0]), sep->arg[1], sep->arg[2]);
+
+ ServerPacket* pack = new ServerPacket(ServerOP_FlagUpdate, 6);
+ *((int32*) pack->pBuffer) = atoi(row[0]);
+ *((sint16*) &pack->pBuffer[4]) = -2;
+ worldserver.SendPacket(pack);
+ safe_delete(pack);
+
+ Client *client = NULL;
+ client = entity_list.GetClientByName(sep->arg[1]);
+ if(client) {
+ client->Kick();
+ } else {
+ ServerPacket* pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
+ ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
+ strcpy(skp->adminname, c->GetName());
+ strcpy(skp->name, sep->arg[1]);
+ skp->adminrank = c->Admin();
+ worldserver.SendPacket(pack);
+ safe_delete(pack);
+ }
+
+ mysql_free_result(result);
+ } else {
+ c->Message(13,"Character does not exist.");
+ }
+ if(query) {
+ safe_delete_array(query);
+ }
+ }
+}
+
void command_ipban(Client *c, const Seperator *sep)
{
if(sep->arg[1] == 0)
Index: zone/command.h
===================================================================
--- zone/command.h (revision 1187)
+++ zone/command.h (working copy)
@@ -245,6 +245,7 @@
void command_setaapts(Client *c, const Seperator *sep);
void command_stun(Client *c, const Seperator *sep);
void command_ban(Client *c, const Seperator *sep);
+void command_timeban(Client *c, const Seperator *sep);
void command_ipban(Client *c, const Seperator *sep);
void command_oocmute(Client *c, const Seperator *sep);
void command_revoke(Client *c, const Seperator *sep);