Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Feature Requests

Development::Feature Requests Post suggestions/feature requests here.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2005, 03:55 AM
Magoth78
Discordant
 
Join Date: Jun 2003
Posts: 345
Default [PHP] Movechar

Hello there,

After some time, I finally coded a simple PHP movechar script.
Once you have entered your charname and accountname, it will verify if the row matches and will send you to the safe point of the zone where your character is in.
Actually, you can't zone in an other zone than the actual one cause I've coded it so people don't use movechar as a cheat (on my server at least).

Here's the code: This is my 2nd php script so be cool if you see a lot of newbish code errors...

Code:
 <?php

$host = 'your_host.com';
$dbuser = 'user';
$dbpass = 'password';
$db = 'dbname';

$link = mysql_connect($host, $dbuser, $dbpass)
   OR die(mysql_error());

if (!mysql_select_db($db, $link))
	{
    	echo 'Unable to connect to the database.';
	echo mysql_errno($link) . ": " . mysql_error($link). "\n";
    	exit;
	}


$charname = $_POST['charname'];
$accountname = $_POST['accountname'];


$query = mysql_query("SELECT zonename FROM empire.character_ WHERE name='$charname';");
	if (!$query) {
   	die('Could not query:' . mysql_error());
	}
	$find_zonename = mysql_result($query, 0);
	echo "Found zone is..... :<b> $find_zonename </b> \r\n <br>";

$query2 = mysql_query("SELECT zoneid FROM character_ WHERE zonename='$find_zonename' LIMIT 1;");
	if (!$query2) {
   	die('Could not query:' . mysql_error());
	}
	$find_zoneid = mysql_result($query2, 0);
	

$query3 = mysql_query("SELECT name FROM account WHERE charname='$charname';");
	if (!$query3) {
   	die('Could not query:' . mysql_error());
	}
	$find_accountname = mysql_result($query3, 0);
	

$query4 = mysql_query("SELECT safe_x FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query4) {
   	die('Could not query:' . mysql_error());
	}
	$find_safex = mysql_result($query4, 0);
	
$query5 = mysql_query("SELECT safe_y FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query5) {
   	die('Could not query:' . mysql_error());
	}
	$find_safey = mysql_result($query5, 0);
	

$query6 = mysql_query("SELECT safe_z FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query6) {
   	die('Could not query:' . mysql_error());
	}
	$find_safez = mysql_result($query6, 0);
	

		if($accountname != $find_accountname)
		{
		echo ("Account name matched with this char ...  <b> Failed! </b> \r\n <br> <b> Verify your Character's name and your's Account's name!"); 
		mysql_close($link);
		exit;
		}
		

		if($accountname = $find_accountname)
		{
			echo ("Account name matched with this char ...  <b> Ok! </b> \r\n <br>");
			$charmove = mysql_query("UPDATE character_ SET zonename='$find_zonename', zoneid='$find_zoneid', x='$find_safex', y='$find_safey', z='$find_safez'  WHERE name='$charname';");
			if (!$charmove) {
   			die('Could not query:' . mysql_error());
			}
			echo ("Character moved to his actual zone safe point. \r\n");
			mysql_close($link);
		}

?>
And a simple html form:
Code:
<HTML>
<BODY>
<FORM METHOD="post" ACTION="char.php">
Character Name : <INPUT TYPE="text" SIZE="30" NAME="charname"><BR>
Account Name : <INPUT TYPE="text" SIZE="20" NAME="accountname"><BR>
<INPUT TYPE="submit" VALUE="Envoyer" NAME="valider">
</FORM>
</BODY>
</HTML>
Installed on empire and working fine.

Mag
__________________
User's projects:
-- Original EMPIRE I/II and Factions! servers
-- Web GM Portal
-- EQoffline/bots
Reply With Quote
  #2  
Old 08-24-2005, 04:02 AM
mrea
Discordant
 
Join Date: Sep 2004
Location: Camp Hill,PA
Posts: 370
Default

I haven't tested it, so I probably shouldn't say this yet :-P, but excellent job. I will definitely use this.
__________________


Reply With Quote
  #3  
Old 08-25-2005, 12:20 AM
Magoth78
Discordant
 
Join Date: Jun 2003
Posts: 345
Default

Just a little fix on my code.

Instead of checking the AccountName for the Character, it will check the AccountID .
As noticed, in the Account table, you only have 1 character per account created, this is the first character. And you don't have the others created chars in the account table, it's why I fixed that by checking the character AccountID.

Code:
<?php

$host = 'your_host';
$dbuser = 'user';
$dbpass = 'password';
$db = 'dbname';

$link = mysql_connect($host, $dbuser, $dbpass)
   OR die(mysql_error());

if (!mysql_select_db($db, $link))
	{
    	echo 'Unable to connect to the database.';
	echo mysql_errno($link) . ": " . mysql_error($link). "\n";
    	exit;
	}

// Query
$charname = $_POST['charname'];
$accountname = $_POST['accountname'];


$query = mysql_query("SELECT zonename FROM empire.character_ WHERE name='$charname';");
	if (!$query) {
   	die('Could not query:' . mysql_error());
	}
	$find_zonename = mysql_result($query, 0);
	echo "Found zone is..... :<b> $find_zonename </b> \r\n <br>";

$query2 = mysql_query("SELECT zoneid FROM character_ WHERE zonename='$find_zonename' LIMIT 1;");
	if (!$query2) {
   	die('Could not query:' . mysql_error());
	}
	$find_zoneid = mysql_result($query2, 0);
	

$query3 = mysql_query("SELECT account_id FROM character_ WHERE name='$charname';");
	if (!$query3) {
   	die('Could not query:' . mysql_error());
	}
	$find_accountid = mysql_result($query3, 0);
	

$query3a = mysql_query("SELECT id FROM account WHERE name='$accountname';");
	if (!$query3a) {
   	die('Could not query:' . mysql_error());
	}
	$verifyaccount_id = mysql_result($query3a, 0);
	

$query4 = mysql_query("SELECT safe_x FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query4) {
   	die('Could not query:' . mysql_error());
	}
	$find_safex = mysql_result($query4, 0);
	

$query5 = mysql_query("SELECT safe_y FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query5) {
   	die('Could not query:' . mysql_error());
	}
	$find_safey = mysql_result($query5, 0);
	

$query6 = mysql_query("SELECT safe_z FROM zone WHERE zoneidnumber='$find_zoneid';");
	if (!$query6) {
   	die('Could not query:' . mysql_error());
	}
	$find_safez = mysql_result($query6, 0);
	//echo $find_accountname;

		if($find_accountid != $verifyaccount_id)
		{
		echo ("Account name matched with this char ...  <b> Failed! </b> \r\n <br> <b> Verify your Character's name and your's Account's name!"); 
		mysql_close($link);
		exit;
		}
		

		if($find_accountid = $verifyaccount_id)
		{
			echo ("Account name matched with this char ...  <b> Ok! </b> \r\n <br>");
			$charmove = mysql_query("UPDATE character_ SET zonename='$find_zonename', zoneid='$find_zoneid', x='$find_safex', y='$find_safey', z='$find_safez'  WHERE name='$charname';");
			if (!$charmove) {
   			die('Could not query:' . mysql_error());
			}
			echo ("Character moved to his actual zone safe point. \r\n");
			mysql_close($link);
		}

?>
Enjoy,

Mag
__________________
User's projects:
-- Original EMPIRE I/II and Factions! servers
-- Web GM Portal
-- EQoffline/bots
Reply With Quote
Reply


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:35 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3