| xBlackPlagu3x |
09/29/2011 18:15 |
[Release]Unstick Character (PHP)
Add this HTML code in a website
Code:
<form method="post" action="unstick.php">
<table>
<tr>
<td height="43">
Username: </td><td width="30px"></td><td><center><input type="text" name="username" value="" /></center></td>
</tr>
</table>
<input type="submit" name="submit" value="Unstick!" />
</form>
Create a file called "unstick.php"
Code:
<?php
// MySQL Connection
// Enter your MySQL information here
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("*YourDatabase", $con);
// The lines below checks to see if the character even exists
$obj1=mysql_query("SELECT COUNT(*ColumnForNameOfCharacter*) FROM *CharacterTable* WHERE Name='$_POST[username]'");
$row = mysql_fetch_assoc($obj1);
if(mysql_num_rows($obj1) > 0)
{
// The line below, set accounts to whatever table holds the info of where your character is in the world. Also change MapID, MapX and MapY to whatever is in your table.
mysql_query("UPDATE *ChangeToCharactersTable* SET MapID = '1002', X = '250', Y = '250' WHERE *ChangeToColumnForNameOfCharacter* = '" . $_POST['username'] . "'");
}
else
{
die("Character doesn't even exist.");
}
mysql_close($con);
header("location:*Change to whatever page you want to go to after the script is run. Ex: http://127.0.0.1*");
?>
What this does is that the user visits the html page right? They then enter in their in-game name. If it exists, good for them, it teleports them to a location in TC. If it doesn't, it'll tell 'em so. If you want to edit things around that's cool, but this is just a basic layout. What you MIGHT wanna do, is add some security in there because if you just add what I gave you, anyone could enter ANY accound name and have them "unstuck".
|