Небольшой php скрипт для создания собственных телепортов на сервере
скачивай и засовываем куда надо,после открываем его(в любом текстовом редакторе) и редактируем под себя
PHP код:
// We get the DB login infos
define('DB_HOST', 'localhost'); //имя хоста или ip адрес
define('DB_USER', 'your_db_user'); // юзер
define('DB_PASSWORD', 'your_db_password'); //пароль
define('DB_NAME', 'mangos'); //основная база
// We get the DB login infos
define ( 'DB_HOST' , 'localhost' ); // Имя хоста или ip адрес
define ( 'DB_USER' , 'your_db_user' ); // Пользователь
define ( 'DB_PASSWORD' , 'your_db_password' ); // Пароль
define ( 'DB_NAME' , 'mangos' ); // Основная база
//this function is used to check the id entry which have to be unique
function checkId ( $id ){
// we check if the id already exist
$sql = "SELECT id FROM spell_target_position WHERE id='$id'" ;
$req = mysql_query ( $sql ) or die( 'SQL error !' . $sql . '<br>' . mysql_error ());
// we count the number of results
$res = mysql_num_rows ( $req );
return $res ;
}
$db = mysql_connect ( DB_HOST , DB_USER , DB_PASSWORD ); // connection to the base
mysql_select_db ( DB_NAME , $db ); // selection of the base
if( $Button == 'Send' ){
// we check if the field are empty
if(empty( $id ) OR empty( $target_map ) OR empty( $target_position_x ) OR empty( $target_position_y ) OR empty( $target_position_z ) OR empty( $target_orientation ) OR empty( $entry ) OR empty( $displayId ) )
{
echo '<font color="red">Warning you have to fill all the fields!</font>' ;
}
// No field is empty, we can write them in the table
//but
//here is our id checker!
elseif( checkId ( $id ))
{
echo '<font color="red">Sorry this id already exist, try another spell</font>' ;
}
else // the id does not exist, we insert the informations in the table
{
$sql1 = "INSERT INTO spell_target_position(id, target_map, target_position_x, target_position_y, target_position_z, target_orientation) VALUES('$id','$target_map','$target_position_x','$target_position_y','$target_position_z','$target_orientation')" ;
mysql_query ( $sql1 ) or die( 'Erreur SQL !' . $sql1 . '<br>' . mysql_error ());
echo '<font color="orange">Your portal have been added</font><br />' ;
echo '<font color="orange">Restart your server (.server restart 10)</font><br />' ;
echo '<font color="orange">Type .gobject add ' . $entry . ' where you want to put your portal</font>' ;
}
}
// the searching part, because some times the spell id you choosed will not work for somes reasons...
if( $Button == 'Search' ){
$sqlsearch = "SELECT `id`
FROM `spell_target_position`
WHERE `id` LIKE '%" . mysql_escape_string ( $search ). "%'" ;
$sqlResult = mysql_query ( $sqlsearch );
// if an id was found, we show the edit form
while(list( $id )= mysql_fetch_array ( $sqlResult )){
echo $id ;
echo '<form method="post" action="">' ;
echo '<table>' ;
echo '<tr>' ;
echo '<td><label for="newid">Teleport spell ID</label> :</td> <td><input type="text" name="newid" id="newid" /></td>' ;
echo '</table>' ;
echo '<input type="submit" value="Edit" name="Button" />' ;
echo '<input type="hidden" value=' . $id . ' name="id" />' ;
echo '</form>' ;
}
}
if( $Button == 'Edit' ){
//here is our id checker again!
if( checkId ( $id ))
{
echo '<font color="red">Sorry this id already exist, try another spell</font>' ;
}
else // the id does not exist, we insert the informations in the table
{
$sqlupdate = "UPDATE spell_target_position SET id='$newid' WHERE id='$id'" ;
$sqlquery = mysql_query ( $sqlupdate );
Как пользоваться?
Заходим на страницу
В поле
Teleport spell ID,как я понимаю 17609
Map ID :
Position X :
Position Y :
Position Z :
Orientation : это все позиции места,куда будет телепорт(в игре можно узнать по .gps)
Entry : номер ентри(ВНИМАНИЕ: должен быть уникальным!)
Name (will be displayed on mouse over) : имя,которое будет отображаться игроку при наведении на портал(ВНИМАНИЕ: только на английском языке!
Ну и всё...жмем send
Если все норм,то перезагружаем серв и входим в игру
Вводим .gobject add entry в нужном нам месте и вуаля!
[Ссылки могут видеть только зарегистрированные пользователи. ]
Последний раз редактировалось Винсент; 13.04.2010 в 19:51.