|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
01-28-2010, 06:27 PM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
COMMITTED: #timeban [name][days]
#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);
|
|
|
|
01-28-2010, 07:09 PM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
That looks really nice! I really like how it should allow you to keep the actual account status set to whatever it was previously set at, so when the timeban is over, they return to their previous account status.
|
01-28-2010, 07:38 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
Suspend would probably be a better name than timeban for this operation; you return -1 without freeing the result also.
I had thought we needed such a thing though so cheers.
|
01-28-2010, 10:37 PM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
ugh...yea forgot about where I done the return without freeing the result.
in the database.cpp move
mysql_free_result(result);
above the
// Check Time Banned
if(timebanned > current) {
return -1;
}
and that will fix that small memory leak.
|
|
|
|
01-29-2010, 12:38 AM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
Please use this patch instead....I never got a chance to test the prior patch as I did it in 5 minutes.
Here is a working patch and tested.
Code:
Index: common/database.cpp
===================================================================
--- common/database.cpp (revision 1192)
+++ common/database.cpp (working copy)
@@ -307,14 +307,21 @@
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]);
mysql_free_result(result);
+
+ // Check Time Banned
+ if(timebanned > current) {
+ return -1;
+ }
+
return status;
}
else
Index: zone/command.cpp
===================================================================
--- zone/command.cpp (revision 1192)
+++ 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", atoi(sep->arg[2]), 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 1192)
+++ 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);
Last edited by Derision; 01-29-2010 at 01:18 PM..
Reason: Pinned for submission
|
|
|
|
01-29-2010, 03:51 PM
|
Developer
|
|
Join Date: Feb 2004
Location: UK
Posts: 1,540
|
|
I've just been testing this, and it works
Is there any reason for sending the ServerOP_FlagUpdate, since we are kicking the character anyway ? I commented that bit out and it seems to work just the same.
|
01-29-2010, 05:34 PM
|
Sarnak
|
|
Join Date: Feb 2008
Posts: 87
|
|
Most likely not but I basically used the same code as #ban so I didn't even bother looking at the rest of the code.
I know this code will help the GM over the problem childs on the servers who cause drama. I know that the VZTZ server is the only PVP server and this feature will help free up time for my GM's.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 08:14 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|