[Question] Undelete a Character

08/24/2009 20:05 Crystal1990#1
Dear ePvPers community,

i have a little question, does anyone knows an SQL - script to "undelete" a deletet character.

My problem:

If an player on my server was hacked and his character is deleted after this, i want to recover the character and all Items.

I tryed to write an script with PHP but after this i became an ridiculous error message...

Code:
Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark before the character string '?'. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 79

Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near '?'. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 79

Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 79

Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark before the character string ''. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near ''. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark before the character string ''. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 173

Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near ''. (severity 15) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 173

Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 173

Warning: mssql_query() [function.mssql-query]: message: Disallowed implicit conversion from data type varchar to data type varbinary, table 'character.dbo.user_slot', column 'info'. Use the CONVERT function to run this query. (severity 16) in C:\Inetpub\vhosts\xp-dekaron.de\httpdocs\include\includes\recoverchar.php on line 173
I am not so crazy to post my whole script but for the PHP-scripters i will post the important CODEs

Line 78 + 79
Code:
$setbagquery	= "INSERT INTO user_bag ([character_no], [line_no], [byHeader], [wIndex], [upt_time], [reg_bindate], [exp_bindate]) VALUES ('".$recchar["character_no"]."', '".$bag["line_no"]."', '".$bag["byHeader"]."', '".$bag["wIndex"]."', '".$bag["upt_time"]."', '".$bag["reg_bindate"]."', '".$bag["exp_bindate"]."')";
$setbag		= mssql_query($setbagquery);
Line 96 + 97
Code:
$setsuitquery	= "INSERT INTO user_suit ([character_no], [line_no], [byHeader], [wIndex], [upt_time], [reg_bindate], [exp_bindate]) VALUES ('".$recchar["character_no"]."', '".$suit["line_no"]."', '".$suit["byHeader"]."', '".$suit["wIndex"]."', '".$suit["upt_time"]."', '".$suit["reg_bindate"]."', '".$suit["exp_bindate"]."')";
$setsuit	= mssql_query($setsuitquery);
Line 172 + 173
Code:
$setslotquery	= "INSERT INTO user_slot ([character_no], [line_no], [info], [ipt_time], [upt_time]) VALUES ('".$recchar["character_no"]."', '".$slot["line_no"]."', '".$slot["info"]."', '".$slot["ipt_time"]."', '".$slot["upt_time"]."')";
$setslot	= mssql_query($setslotquery);
A short info to read the CODEs:

all this CODEs are scripted like this:

Code:
			if (mssql_num_rows ($searchbagausf) > 0) {
		
				while ($bag = mssql_fetch_array($searchbagausf)) {

					$setbagquery	= "INSERT INTO user_bag ([character_no], [line_no], [byHeader], [wIndex], [upt_time], [reg_bindate], [exp_bindate]) VALUES ('".$recchar["character_no"]."', '".$bag["line_no"]."', '".$bag["byHeader"]."', '".$bag["wIndex"]."', '".$bag["upt_time"]."', '".$bag["reg_bindate"]."', '".$bag["exp_bindate"]."')";
					$setbag		= mssql_query($setbagquery);
				}

				$delbagquery	= "DELETE FROM user_bag_secede WHERE [character_no] = '".$recchar["character_no"]."' ";
				$delbag		= mssql_query($delbagquery);

			}
The variable "$recchar" is an array with the query from the user_character_secede.


I hope someone can help me with this problem,

thanks in advanced

Yours Crystal
08/24/2009 20:44 Bakloma#2
i think if its deleted, its deleted :o
08/24/2009 21:05 Crystal1990#3
@Bakloma:

No, you are wrong,

deleted characters are saved in the *name*_secede tables like character_secede.

And my question is not: is it possible.

My question is how.


BTW, my script is working in one point:

The deleted character is 'undeleted' after this script.

i only have a problem with the data-types in the database and i need them to "undelete" the skills and items to.

This way i can say it posslible to "undelete" characters
08/24/2009 21:23 ~Kakkarot~#4
i dont get this how do you undelete if its deleted in database, once you delete ingame you can create another char with same name so that means that char does not exsist in database, so im just asking ...you can seriously undelete the deleted char lol....?
08/24/2009 22:02 Crystal1990#5
You can use a little trick for this:

1. the script have to check if the charname is available.

if yes, the script will be use the 'original' name,
if not, the script will ask you to rename the character

then the script will test the new name,

if the name is free, it will use the name, other way, it will ask you again.


2. There is also the posibility that a character name is twice or more in the user_character_secede.

In this case, ths script ask which of these characters should be recovered.

thats the way ;)
08/24/2009 22:11 ~Kakkarot~#6
Quote:
Originally Posted by Crystal1990 View Post
You can use a little trick for this:

1. the script have to check if the charname is available.

if yes, the script will be use the 'original' name,
if not, the script will ask you to rename the character

then the script will test the new name,

if the name is free, it will use the name, other way, it will ask you again.


2. There is also the posibility that a character name is twice or more in the user_character_secede.

In this case, ths script ask which of these characters should be recovered.

thats the way ;)
very nice then, it will most likey be very helpfull :)