|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10-02-2009, 04:00 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
#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);
|
|
|
|
10-02-2009, 10:49 AM
|
|
Demi-God
|
|
Join Date: May 2007
Location: b
Posts: 1,447
|
|
Shin,
I love you.
Probably one of the more useful things you have written!
|
10-02-2009, 11:37 AM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Quote:
Originally Posted by Secrets
Shin,
I love you.
Probably one of the more useful things you have written!
|
Meh. Teleport Bind is insanely useful, slacker.
This is a lazy man's tool. Rogean showed how easy this is to do. I just turned it into a command cuz he said he was thinking about doing it. :P
|
10-02-2009, 12:30 PM
|
Fire Beetle
|
|
Join Date: Sep 2009
Posts: 16
|
|
Shin, you may want to think about how to handle if the character being transferred is in use. Maybe a forced disconnect?
|
10-02-2009, 12:41 PM
|
|
Legendary Member
|
|
Join Date: Apr 2002
Location: Seattle, WA
Posts: 506
|
|
Also verifying the account ID exists would be nice. I probably should do that, but.. Meh. I don't even know if this code works still. Need to sit down and test it, then i'll go through and optimize with stupid-proofing it. I could also probably write a switch conversion so it will accept account login names or account id's, since with that info doing a character transfer can be very easy.
But then again Pend, if a character is moved to another account, what does that do in potential bugs? It isn't like there is much for ties between characters and accounts, if the character is logged in and the account that owns it is swapped, the only time account will be fetched again is when the character logs off or does a save etc and when it does it'll just save to the new account name... I should test that, log out and see what characters come up if I transfer a char between accounts. XD
|
|
|
|
10-02-2009, 03:29 PM
|
|
Discordant
|
|
Join Date: Mar 2009
Location: Ottawa
Posts: 495
|
|
What happens in the following situation?
1) Player uses #transferchar to transfer Char A from Account A to Account B
2) Player logs in Char A from Account B while the original char is still in game
|
10-02-2009, 04:15 PM
|
|
Administrator
|
|
Join Date: Jul 2003
Location: Massachusetts
Posts: 708
|
|
Would kick them off.. the same thing that happens when you log into your own account twice.
__________________
EQEmulator Developer / Administrator
|
11-22-2009, 08:01 PM
|
Fire Beetle
|
|
Join Date: Jun 2008
Location: California
Posts: 1
|
|
i dont get how to do this
|
01-24-2010, 08:13 PM
|
Fire Beetle
|
|
Join Date: Nov 2008
Location: .
Posts: 21
|
|
I know this thread is little old but just wondering if this is the easiest way to xfer toons to new accounts. also does this move gear/factions/flags etc or any ideas on a easy way to do this?
|
01-24-2010, 09:10 PM
|
|
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Quote:
Originally Posted by tricyclethief2
I know this thread is little old but just wondering if this is the easiest way to xfer toons to new accounts. also does this move gear/factions/flags etc or any ideas on a easy way to do this?
|
I just use a PHP script, but the code above would be good for those who are in-game more. Everything gets transferred over since you are only changing the account id, nothing else.
|
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 07:35 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|