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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-02-2009, 04:00 AM
Shin Noir's Avatar
Shin Noir
Legendary Member
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
Default #transferchar [charname] [acctid]

Saw Rogean post this, took a couple minutes to try to write it. I did not test this at all, which I should, but I'm not at home busy on a laptop.. Let me know if anything is wrong (atoi function i am not familiar with).
Code:
Index: common/database.cpp
===================================================================
--- common/database.cpp	(revision 1004)
+++ common/database.cpp	(working copy)
@@ -1613,6 +1613,24 @@
 	return true;
 }
 
+
+bool Database::TransferCharacterToAccount(int32 charid, int32 acctid) {
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	int32	affected_rows = 0;
+
+	if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE `character_` SET `account_id` = '%i' WHERE `id` = '%i';", acctid,charid), errbuf, 0,&affected_rows)) {
+		cerr << "Error in TransferCharacterToACcount(charid, acctid) query '" << query << "' " << errbuf << endl;
+		return false;
+	}
+	safe_delete_array(query);
+
+	if (affected_rows == 0)
+		return false;
+
+	return true;
+}
+
 int8 Database::CopyCharacter(const char* oldname, const char* newname, int32 acctid) {
 	char errbuf[MYSQL_ERRMSG_SIZE];
 	char *query = 0;
Index: common/database.h
===================================================================
--- common/database.h	(revision 1004)
+++ common/database.h	(working copy)
@@ -116,6 +116,7 @@
 	bool	MoveCharacterToZone(const char* charname, const char* zonename);
 	bool	MoveCharacterToZone(const char* charname, const char* zonename,int32 zoneid);
 	bool	MoveCharacterToZone(int32 iCharID, const char* iZonename);
+	bool	TransferCharacterToAccount(int32 charid, int32 acctid);
 	bool	UpdateName(const char* oldname, const char* newname);
 	bool	SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
 	bool	SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone);
Index: zone/command.cpp
===================================================================
--- zone/command.cpp	(revision 1004)
+++ zone/command.cpp	(working copy)
@@ -189,6 +189,7 @@
 		command_add("tgczone",NULL,0,command_peqzone) ||
 		command_add("showbuffs","- List buffs active on your target or you if no target",50,command_showbuffs) ||
 		command_add("movechar","[charname] [zonename] - Move charname to zonename",50,command_movechar) ||
+		command_add("transferchar","[charname] [accountid] - Move charname to accountid",200,command_transferchar) ||
 		command_add("viewpetition","[petition number] - View a petition",20,command_viewpetition) ||
 		command_add("petitioninfo","[petition number] - Get info about a petition",20,command_petitioninfo) ||
 		command_add("delpetition","[petition number] - Delete a petition",20,command_delpetition) ||
@@ -1602,6 +1603,25 @@
 	}
 }
 
+void command_transferchar(Client *c, const Seperator *sep)
+{ //Shin: Transfer a character from one login to another.
+	if(sep->arg[1][0] == 0 || sep->arg[2][0] == 0)
+		c->Message(0, "Usage: #transferchar [charactername] [accountid] ");
+	else
+	{
+		int32 charid = database.GetCharacterID(sep->arg[2]);
+		if (charid)
+		{
+			if (!database.TransferCharacterToAccount(charid, atoi(sep->arg[1])))
+				c->Message(0, "Character failed to move!");
+			else
+				c->Message(0, "Character has been moved.");
+		}
+		else
+			c->Message(0, "Character name not found.");
+	}
+}
+
 void command_viewpetition(Client *c, const Seperator *sep)
 {
 	if (sep->arg[1][0] == 0)
Index: zone/command.h
===================================================================
--- zone/command.h	(revision 1004)
+++ zone/command.h	(working copy)
@@ -96,6 +96,7 @@
 void command_peqzone(Client *c, const Seperator *sep);
 void command_showbuffs(Client *c, const Seperator *sep);
 void command_movechar(Client *c, const Seperator *sep);
+void command_transferchar(Client *c, const Seperator *sep);
 void command_viewpetition(Client *c, const Seperator *sep);
 void command_petitioninfo(Client *c, const Seperator *sep);
 void command_delpetition(Client *c, const Seperator *sep);
__________________

~Shin Noir
DungeonEQ.com
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 06:38 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