<?php

// Перемещает игрока в место по подстроке названия из таблицы .tele

require "_trinity.php";

MySTART( DBnameFromArgv() );

$toponim = "";
if (count($argv) > 1)  $toponim = str_replace(" ", "", $argv[1]);

$game_tele = 'game_tele';
if (mysql_query("SELECT * FROM game_teleportation_zones LIMIT 1") !== FALSE)  $game_tele = 'game_teleportation_zones'; // QuantumCore

$t = MyROWobj("SELECT position_x AS x, position_y AS y, position_z AS z, name, map FROM $game_tele WHERE INSTR(name,'$toponim')>0 ORDER BY name");

if ($t == null) {
   echo "Error! Сannot find location \"$toponim\"\n";
   exit(1);
}

echo "Found $t->name in ".$wowmaps[$t->map]."\n";

if (count($argv) > 2) {

MyOP("UPDATE characters.characters SET position_x=$t->x, position_y=$t->y, position_z=$t->z, map=$t->map, zone=0 WHERE name=".MySTR($argv[2]));
printf("%s to ($t->x, $t->y, $t->z) map #$t->map\n",
       mysql_affected_rows() > 0 ? "Player teleported " : "There is no one to be teleported"
);

}
exit(0);

?>
