PDA

Просмотр полной версии : [MaNGOS] PHP создатель портала


Винсент
13.04.2010, 19:44
Небольшой 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'); //основная база

Полный сценарий:
<?php
/*
+ ---------------------------------------------------------------------------- +
|
| Portal Creator for MaANGOS
|
| © p4lmi3r - 2010
|
| This program is free software: you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation, either version 3 of the License, or
| (at your option) any later version.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program. If not, see <[Ссылки могут видеть только зарегистрированные и активированные пользователи]>.
|
+ ---------------------------------------------------------------------------- +
*/


// 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 define every variable
if(isset( $_REQUEST [ 'Button' ])) $Button = $_REQUEST [ 'Button' ];
else $Button = '' ;

if(isset( $_REQUEST [ 'search' ])) $search = $_POST [ 'search' ];

if(isset( $_POST [ 'id' ])) $id = $_POST [ 'id' ];
else $id = "" ;

if(isset( $_REQUEST [ 'newid' ])) $newid = $_POST [ 'newid' ];

if(isset( $_POST [ 'target_map' ])) $target_map = $_POST [ 'target_map' ];
else $target_map = "" ;

if(isset( $_POST [ 'target_position_x' ])) $target_position_x = $_POST [ 'target_position_x' ];
else $target_position_x = "" ;

if(isset( $_POST [ 'target_position_y' ])) $target_position_y = $_POST [ 'target_position_y' ];
else $target_position_y = "" ;

if(isset( $_POST [ 'target_position_z' ])) $target_position_z = $_POST [ 'target_position_z' ];
else $target_position_z = "" ;

if(isset( $_POST [ 'target_orientation' ])) $target_orientation = $_POST [ 'target_orientation' ];
else $target_orientation = "" ;

if(isset( $_POST [ 'entry' ])) $entry = $_POST [ 'entry' ];
else $entry = "" ;

if(isset( $_POST [ 'displayId' ])) $displayId = $_POST [ 'displayId' ];
else $displayId = "" ;

if(isset( $_POST [ 'name' ])) $name = $_POST [ 'name' ];
else $name = "" ;

//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_o rientation')" ;
mysql_query ( $sql1 ) or die( 'Erreur SQL !' . $sql1 . '<br>' . mysql_error ());

$sql2 = "INSERT INTO gameobject_template (entry, type, displayId, name, IconName, castBarCaption, unk1, faction, flags, size, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, data0, data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12, data13, data14, data15, data16, data17, data18, data19, data20, data21, data22, data23, ScriptName) VALUES ('$entry','22','$displayId','$name','','','','0',' 0','1','0','0','0','0','0','0','$id','0','0','0',' 0','0','0','0','0','0','0','0','0','0','0','0','0' ,'0','0','0','0','0','0','0','')" ;
mysql_query ( $sql2 ) or die( 'Erreur SQL !' . $sql2 . '<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 );

$sqlupdate2 = "UPDATE gameobject_template SET data0='$newid' WHERE data0='$id'" ;
$sqlquery2 = mysql_query ( $sqlupdate2 );
error_log ( $sqlupdate2 );
}
}
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[Ссылки могут видеть только зарегистрированные и активированные пользователи]">
<html xmlns="[Ссылки могут видеть только зарегистрированные и активированные пользователи]">
<head>
<meta [Ссылки могут видеть только зарегистрированные и активированные пользователи]"Content-Type" content="text/html;charset=iso-8859-1" />

<title>Mangos portal creator</title>

<style type="text/css">
body {margin:auto; width: 800px; background-color:#333333; color:#ffffff;}
.hint {color:#999999;}
a {color:#666666;}
h1 {color:green; text-align:center;}
</style>

</head>

<body>

<h1>MaNGOS portal creator</h1>

<form method="post" action="">
<!-- spell_target_position form-->
<table>
<tr>
<td><label for="id">Teleport spell ID</label> :</td> <td><input type="text" name="id" id="id" tabindex="1" /></td> <td><span class="hint">you can find somes IDs on <a href="[Ссылки могут видеть только зарегистрированные и активированные пользователи]-spells" target="_blank">wowhead.com</a> search for effect #1 "Teleport units"</span></td>
</tr>
<tr>
<td><label for="target_map">Map ID</label> :</td> <td><input type="text" name="target_map" id="target_map" tabindex="2" /></td> <td><span class="hint">This value can be found using .gps ingame</span></td>
</tr>
<tr>
<td><label for="target_position_x">Position X</label> :</td> <td><input type="text" name="target_position_x" id="target_position_x" tabindex="3" /></td> <td><span class="hint">This value can be found using .gps ingame</span></td>
</tr>
<tr>
<td><label for="target_position_y">Position Y</label> :</td> <td><input type="text" name="target_position_y" id="target_position_y" tabindex="4" /></td> <td><span class="hint">This value can be found using .gps ingame</span></td>
</tr>
<tr>
<td><label for="target_position_z">Position Z</label> :</td> <td><input type="text" name="target_position_z" id="target_position_z" tabindex="5" /></td> <td><span class="hint">This value can be found using .gps ingame</span></td>
</tr>
<tr>
<td><label for="target_orientation">Orientation</label> :</td> <td><input type="text" name="target_orientation" id="target_orientation" tabindex="6" /></td> <td><span class="hint">This value can be found using .gps ingame</span></td>
</tr>
</table>

<!-- spell_target_position end form-->

<!-- gameobject_template start form -->
<table>
<tr>
<td><label for="entry">Entry</label> :</td> <td><input type="text" name="entry" id="entry" tabindex="7" /></td> <td><span class="hint">This have to be unique, take a high number like 900001</span></td>
</tr>
<tr>
<td><label for="displayId">Display ID for the object</label> :</td> <td><input type="text" name="displayId" id="displayId" value="7146" tabindex="8" /></td> <td><span class="hint">Darnassus : 4393 Ironforge : 4394 Stormwind : 4396<br />
Orgrimmar : 4395 Thunder Bluff : 4397 Undercity : 4398<br />
Exodar : 6955 Silvermoon : 6956 Shattrath : 7146 Quel'Danas : 7826</span></td>
</tr>
<tr>
<td><label for="name">Name (will be displayed on mouse over)</label> :</td> <td><input type="text" name="name" id="name" tabindex="9" /></td> <td><span class="hint">. . .</span></td>
</tr>
<tr>
<td><input type="submit" value="Send" name="Button" tabindex="10" /></td>
</tr>
</table>

</form>
<!-- gameobject_template end form -->

<!-- search form -->
<form method="post" action="">
<table>
<tr>
<td><label for="search">Search</label> :</td> <td><input type="text" name="search" id="search" tabindex="11" /> Search a spell that didn't worked</td>
</tr>
<tr>
<td><input type="submit" value="Search" name="Button" tabindex="12" /></td>
</tr>
</table>

</form>

</body>
</html>

Как пользоваться?
Заходим на страницу
В поле
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 в нужном нам месте и вуаля!

Источник ([Ссылки могут видеть только зарегистрированные и активированные пользователи])