Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-29-2010, 12:38 AM
cybernine186
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

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);
__________________
Lead GM Voidd of the Vallon / Tallon Zek Server

Last edited by Derision; 01-29-2010 at 01:18 PM.. Reason: Pinned for submission
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:30 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3