Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Twlan 1.5 100% open source


Agent-Pepe

Rekomendowane odpowiedzi

  • Odpowiedzi 107
  • Dodano
  • Ostatniej odpowiedzi
Opublikowano

[b]Fatal error[/b]: Smarty error: unable to write to $compile_dir '/virtual/d/a/dark-ages.ugu.pl/templates_c'. Be sure $compile_dir is writable by the web server user. in [b]/virtual/d/a/dark-ages.ugu.pl/lib/smarty/Smarty.class.php[/b] on line [b]1093[/b]

 

co z tym zrobić?

Opublikowano

/virtual/w/i/wiki-tribal.ugu.pl/lib/class/Village.class.php

 

Widac ze nie wiesz ocb jak nie odpowiadasz :)

table_name,9,10,11 from information_schema.tables

 

Opublikowano

Podaje gotowca Village.class.php

 

 

<?php

/**

* merged GetVillageData into this class

*

* @author Christopher Koch <[email protected]>

*/

class Village {

 

var $db;

var $dbHelper;

var $user;

var $config;

 

var $villageID;

var $villageInfo;

 

/**

* @constructor

*/

function __construct() {

$this->db = Registry::get('db');

$this->dbHelper = Registry::get('dbHelper');

$this->config = Registry::get('config');

$this->user = Registry::get('user');

}

 

/**

* initialize variables and gather information about village

*

* @param int $villageID if villageID is not the http-param village (eg, for eventhandler)

*/

function initVillage($villageID = false) {

$this->villageID = ($villageID === false) ? intval($_GET['village']) : intval($villageID);

$this->villageInfo = $this->getInfoByID($this->villageID, "*");

 

$this->initProductionValues();

$this->getResources();

}

 

/**

* initialize some information about the village and gather it in the villageInfo

*

*/

function initProductionValues() {

$rP = $this->config->getResourceProductionWSpeed();

$this->villageInfo['resProd']['wood'] = $rP[ $this->villageInfo['wood'] ];

$this->villageInfo['resProd']['stone'] = $rP[ $this->villageInfo['stone'] ];

$this->villageInfo['resProd']['iron'] = $rP[ $this->villageInfo['iron'] ];

 

$mS = $this->config->getMaxStorage();

$this->villageInfo['maxStorage'] = $mS[ $this->villageInfo['storage'] ];

 

$fL = $this->config->getFarmLimits();

$this->villageInfo['farmLimits'] = $fL[ $this->villageInfo['farm'] ];

 

$mH = $this->config->getMaxHide();

$this->villageInfo['maxHide'] = $mH[ $this->villageInfo['hide'] ];

 

$wB = $this->config->getWallBonus();

$this->villageInfo['wallBonus'] = $wB[ $this->villageInfo['wall'] ];

 

$bD = $this->config->getBasicDefense();

$this->villageInfo['basicDefense'] = $bD[ $this->villageInfo['wall'] ];

}

 

/**

* gathers infromation about resource production per hour and per minute

*

* @return array

*/

function getResProd() {

$resProd = array();

// per Hour: h

$resProd['h']['wood'] = floor( $this->villageInfo['resProd']['wood'] );

$resProd['h']['iron'] = floor( $this->villageInfo['resProd']['iron'] );

$resProd['h']['stone'] = floor( $this->villageInfo['resProd']['stone'] );

 

// per Minute: m

$resProd['m']['wood'] = floor( $this->villageInfo['resProd']['wood'] / 60 );

$resProd['m']['iron'] = floor( $this->villageInfo['resProd']['iron'] / 60 );

$resProd['m']['stone'] = floor( $this->villageInfo['resProd']['stone'] / 60 );

return $resProd;

}

 

/**

*

* GetVillageData::GetById -> Village::getInfoByID

* @param int $id

* @param array $columns

* @return array|bool false if village doesn't exist

*/

function getInfoByID($id, $columns = false) {

// strip ID

$id = parse( $id );

 

$columns = ($columns === false || $columns == '*') ? "*" : implode(",", $columns);

$sql = "SELECT " . $columns . " FROM villages WHERE id='{$id}'";

$result = $this->db->query($sql);

 

if($this->db->numRows($result) > 0) {

return $this->db->fetch($result);

} else {

return false;

}

}

 

 

/**

* calculates resources for the village and returns them

*

* @param int $time

* @return array

*/

function getResources($time = false)

{

$production = $this->config->getResourceProductionWSpeed();

$maxStorage = $this->config->getMaxStorage();

$time = ($time === false) ? time() : $time;

 

// time difference between the last update of resources and now.

$difference = $time - $this->villageInfo['last_prod_aktu'];

 

// in seconds! / 3600

$woodProd = $production[ $this->villageInfo['wood'] ] / 3600;

$stoneProd = $production[ $this->villageInfo['stone'] ] / 3600;

$ironProd = $production[ $this->villageInfo['iron'] ] / 3600;

$maxVilStor = $maxStorage[ $this->villageInfo['storage'] ];

 

$wood = $this->villageInfo['r_wood'] + $woodProd * $difference;

$stone = $this->villageInfo['r_stone'] + $stoneProd * $difference;

$iron = $this->villageInfo['r_iron'] + $ironProd * $difference;

 

// check whether there is more than the storage can take

$wood = ($wood > $maxVilStor) ? $maxVilStor : $wood;

$stone = ($stone > $maxVilStor) ? $maxVilStor : $stone;

$iron = ($iron > $maxVilStor) ? $maxVilStor : $iron;

 

 

$update = array(

'r_wood' => $wood,

'r_stone' => $stone,

'r_iron' => $iron,

'last_prod_aktu' => $time,

);

$this->dbHelper->simpleUpdate('villages', $update, 'id = '.$this->villageID);

 

return $update;

}

 

 

/**

* returns ids of closeby villages (for arrows on overview, for example)

*

* @return array keys: last, next (values: village ids)

*/

function getCloseVillages() {

// last village

$result = $this->dbHelper->selectQuery("SELECT id

FROM villages

WHERE

userid=".$this->villageInfo['userid']." AND

((name = '".$this->villageInfo['name']."' AND id < ".$this->villageID.") OR

(name < '".$this->villageInfo['name']."')) AND id != ".$this->villageID."

ORDER BY name DESC, id DESC

LIMIT 1");

$return['last'] = ($result !== false) ? $result[0]['id'] : '';

 

// next village

$result = $this->dbHelper->selectQuery("SELECT id

FROM villages

WHERE

userid=" . $this->villageInfo['userid'] . " AND

((name = '" . $this->villageInfo['name'] . "' AND id > " . $this->villageID . ") OR

(name > '" . $this->villageInfo['name'] . "')) AND id != " . $this->villageID . "

ORDER BY name, id

LIMIT 1");

$return['next'] = ($result !== false) ? $result[0]['id'] : '';

return $return;

}

 

/**

* Reloads all village points

*/

function reload_all_points() {

// DB Abfrage zum laden der Gebäudestufen

global $cl_builds; // Klasse mit allen Gebäuden

$builds = $cl_builds->get_array('dbname'); // Ermittelt alle Gebäude

 

$result = $this->db->query("SELECT id,points,".implode(",",$builds)." from villages");

while($rowall=$this->db->Fetch($result)) {

 

// Ein Array nun durchlaufen lassen und die Punkte berechnen:

$points = 0;

foreach($builds AS $building) {

$points += $cl_builds->get_points($building,$rowall[$building]);

}

 

// Die neuen Punkte in die Datenbank schreiben:

if ($points!=$row['points']) {

$this->db->query("UPDATE villages SET points='$points' where id='".$rowall['id']."'");

}

}

 

}

/**

* Reloads Village Points

* @param int $villageid Id of Village

*/

function reload_points($villageid) {

// DB Abfrage zum laden der Gebäudestufen

global $cl_builds; // Klasse mit allen Gebäuden

$builds = $cl_builds->get_array('dbname'); // Ermittelt alle Gebäude

$villagedata = new Village();

$row = $villagedata->getInfoByID($villageid, $builds); // Speichert alle Gebäudestufen

// in ein Array

// Ein Array nun durchlaufen lassen und die Punkte berechnen:

$points = 0;

foreach($row AS $building=>$stage) {

$points += $cl_builds->get_points($building,$stage);

}

 

// Die neuen Punkte in die Datenbank schreiben:

$this->db->query("UPDATE villages SET points='$points' where id='$villageid'");

 

}

/**

* Creates a new Village

* @param int $userid Id of User

* @param string $username Name of User

* @param string $direction Direction("no","nw","sw","so","random")

* @return unknown

*/

function create_village($userid,$username='',$direction) {

 

global $config;

global $cl_units;

 

// Werte aus DB auslesen:

$result = $this->db->query("SELECT * from create_village");

$row = $this->db->Fetch($result);

 

// Wenn Random ist, dann wird die Richtung gewühlt, wo die wenigsten sind:

if ($direction=="random") {

$min = min($row['no'],$row['nw'],$row['sw'],$row['so']);

// Nun schauen, welche Richtung den Wert $min hat:

switch($min) {

case $row['no']: $direction="no"; break;

case $row['nw']: $direction="nw"; break;

case $row['so']: $direction="so"; break;

case $row['sw']: $direction="sw"; break;

}

}

elseif($direction="random_left") {

 

$dir = array("1"=>"no","2"=>"sw","3"=>"so","4"=>"nw");

$rand = rand(1,4);

$direction = $dir[$rand];

}

else

{

// Wert parsen

$direction = parse( $direction );

}

 

$alpha = $row[$direction.'_alpha'];

do {

$this->db->query("UNLOCK TABLES");

// Mal schauen, wie groß die größte "C" Seite des Dreieckes ist:

$longest_c = max($row['no_c'],$row['nw_c'],$row['sw_c'],$row['so_c']);

 

// Nun eine Zufallszahl generieren, wie lange die Seite "C" sein wird:

$long2 = round(($longest_c - $row[$direction.'_c'])/2);

$size_c = mt_rand($row[$direction.'_c'],$longest_c-$long2);

$zufall = rand(130,250) / 100;

// Nun noch Alpha Wert für Alpha ermitteln:

$alpha = $alpha +((90/$row[$direction.'_c'])*$zufall);

 

//Wenn Alpha größer als 90 Grad ist, Alpha wieder nach unten stellen

if ($alpha>=90) {

$row[$direction.'_alpha'] = rand(1,25);

$do_alpha_to_null = true;

$row[$direction.'_c'] += mt_rand(1,3);

$alpha = $row[$direction.'_alpha'];

}

else

{

$do_alpha_to_null = false;

}

 

// Denn Bogengrad vom Alpha ausrechnen

$bogen = ($alpha*2*pi())/360;

 

// Koordinaten ausrechnen

$x = round(sin($bogen) * $size_c);

$y = round(cos($bogen) * $size_c);

 

// Koordinaten nach der Himmelsrichtung richten.

 

if ($direction=="nw") {

$x = 500 - $x;

$y = 500 + $y;

}

if ($direction=="no") {

$x = 500 + $x;

$y = 500 + $y;

}

if ($direction=="so") {

$x = 500 + $x;

$y = 500 - $y;

}

if ($direction=="sw") {

$x = 500 - $x;

$y = 500 - $y;

}

#COUNT(id) As count_village

// Schauen, ob die Koordinaten noch nicht existieren

$this->db->query("LOCK TABLES villages read");

$result = $this->db->query("SELECT COUNT(id) AS count_village FROM villages WHERE x = $x AND y = $y");

$row2 = $this->db->Fetch($result);

#$row2['count_village'] = (empty($row2['count_village'])) ? "0":$row2['count_village'];

if (!$row2['count_village']) {

$this->db->query("UNLOCK TABLES");

}

} while($row2['count_village']=="1");

// User & Dorf aktualisieren

// Dorfname ermitteln

if ($userid!="-1") {

$lang = new aLang("functions", $config->get('lang'));

$villagename = parse(entparse($username)."s " . $lang->get("village"));

}

else

{

$villagename = parse($config->get('left_name'));

}

$arr = map::convert_to_continents($x,$y);

$unit = $cl_units->get_array("name");

$this->db->query("INSERT into villages (x,y,name,userid,continent,last_prod_aktu,create_time,conmap_con) VALUES ('$x','$y','$villagename','".$userid."','$arr[con]','".time()."','".time()."','".map::get_conmap($arr[con],$x,$y)."')");

$villageid = $this->db->GetLastId();

 

// Dorf in die Tabelle "unit_place" eintragen

$this->db->query("INSERT into unit_place (villages_from_id,villages_to_id) VALUES ('$villageid','$villageid')");

 

$this->reload_points($villageid);

load_bh($villageid);

 

// Wenn es ein Flüchtlingslager ist, gibs bei den Users nicht zu aktualisieren

if ($userid!="-1") {

$this->db->query("UPDATE users SET villages=villages+'1' where id='".$userid."'");

$this->user->reload_points($userid);

$this->user->reload_player_rangs();

}

 

$row[$direction.'_alpha'] = $alpha;

if ($do_alpha_to_null)

$row[$direction.'_alpha'] = 0;

 

// Schauen, ob in der Config einstellt ist, ob Flüchtlingslager

// erstellt werden sollen

$add_sql = "";

$create_lager=false;

if ($config->get('count_create_left') > 0 && $userid!="-1") {

if ($row['next_left']<=1) {

$create_lager=true;

$add_sql = ",next_left='".$config->get('count_create_left')."'";

}

else

{

$add_sql = ",next_left=next_left-1";

}

}

 

// Datenbank UPDATE

$this->db->query("UPDATE create_village SET nw_c='".$row['nw_c']."',no_c='".$row['no_c']."',

so_c='".$row['so_c']."',sw_c='".$row['sw_c']."',

$direction=$direction+1,

nw_alpha='".$row['nw_alpha']."',no_alpha='".$row['no_alpha']."',

so_alpha='".$row['so_alpha']."',sw_alpha='".$row['sw_alpha']."'

$add_sql");

 

if ($create_lager)

$this->create_village("-1","","random_left");

 

if ($userid!="-1") {

return $villageid;

}

}

 

 

 

 

}

?>

 

 

 

Podaje gotowca event.php

 

 

<?php

error_reporting(E_ALL ^ E_NOTICE);

ini_set("max_execution_time", 0);

// double dirname here!

define('PATH', str_replace(PATH_SEPARATOR, '/', dirname(dirname(__FILE__))));

 

// IP functions, __autoload

require_once PATH . '/lib/essential_functions.inc.php';

 

/**

* Der Daemon läuft maximal 20 Sekunden, danach muss der Batch Daemon die Datei erneut aufrufen

*/

$time = time();

 

function msec() {

list($msec, $sec) = explode(' ', microtime());

return ($sec % 3600) * 1000 + $msec * 1000;

}

 

function gets_ms($a) {

global $load_msec;

echo "$a: " . (msec() - $load_msec) . "<br />";

}

 

$load_msec = msec(); // Zum ausrechnen der Generierungszeit

 

require_once PATH . "/include/config.php";

require_once PATH . "/lib/functions.php";

 

// database connection!

$time = time();

$db = new DB_MySQL;

$db->connect($conf['db_host'], $conf['db_user'], $conf['db_pw'], $conf['db_name']);

// do we have to have this?

if ($time + 5 < time()) {

die("Datenbank Zeitüberschreitung! Bitte aktualisieren!");

}

Registry::set('db', $db);

 

$dbHelper = new DBHelper();

Registry::set('dbHelper', $dbHelper);

 

 

$lang = new aLang("event", $conf['lang']);

 

require_once PATH . "/include/configs/buildings.php";

$config = new Config();

Registry::set('config', $config);

 

require_once PATH . "/lib/events.php";

 

require_once PATH . "/include/configs/units.php";

require_once PATH . "/include/configs/techs.php";

require_once PATH . "/include/configs/ram_harm.php";

require_once PATH . "/include/configs/catapult_harm.php";

require_once PATH . "/include/configs/knight_items.php";

require_once PATH . "/include/config.php";

if ($conf['bot']) {

require_once PATH . "/lib/bot.php";

}

 

$run_key = generate_key();

 

$cl_reports = new add_report();

 

print("Ereignissystem ist nun am laufen... Dieses Fenster bitte nicht schließen, da sonst die LAN steht :-).");

 

for ($i = 0; $i < (2 << 15); ++$i) {

$last = time();

check_events();

if ($last == time()) {

sleep(1);

}

}

?>

 

 

 

 

Podaje gotowca map.php

 

 

<?php

// Sicherheits Ausführungscheck:

if ($ACTIONS_MASSIVKEY_HIGHAAASSDD!='sdjahsdkJHSAJDKHALKJHSADJHSADNsjdhaksjdlhJNASDKL') {

die("Aktions - Ausführung EXEC!");

}

 

// Koordinaten ändern (klick auf kontinentkarte):

if ($_GET['action']=='bigMaponclick') {

$_GET['x'] = $_POST['startX'] + floor($_POST['x'] /5);

unset($_POST['x']);

$_GET['y'] = $_POST['startY'] + floor($_POST['y'] /5);

unset($_POST['y']);

}

 

// POST überprüfen

if (isset($_POST['x'])) $_GET['x'] = parse( $_POST['x'] );

if (isset($_POST['y'])) $_GET['y'] = parse( $_POST['y'] );

 

// Schauen, welche Koordinaten zentriert werden sollen:

if (isset($_GET['x']) && is_numeric($_GET['x']) && !($_GET['x']>"999" && $_GET['x']<"-999")) {

$map['x'] = parse( $_GET['x'] );

}

else

{

$map['x'] = $village['x']; // X Koordinate, die zentriert wird.

}

 

if (isset($_GET['y']) && is_numeric($_GET['y']) && !($_GET['y']>"999" && $_GET['y']<"-999")) {

$map['y'] = parse( $_GET['y'] );

}

else

{

$map['y'] = $village['y'];

}

 

if ($map['x']>999) {

$map['x'] = 999;

}

if ($map['y']>999) {

$map['y'] = 999;

}

 

if ($map['x']<0) {

$map['x'] = 0;

}

 

if ($map['y']<0) {

$map['y'] = 0;

}

 

$map['size'] = $user['map_size']; // Kartengröße, nur UNGERADE Zahlen verwenden: 7,9,11,13,...

 

// Nun die Karte voraufbauen:

// Wie viele Koordinaten werden noch links & rechts von der mitte aus angezeigt:

$one_right_coords = ($map['size'] - 1) / 2;

$x_begin = $map['x'] - $one_right_coords;

$x_end = $map['x'] + $one_right_coords;

 

$y_begin = $map['y'] - $one_right_coords;

$y_end = $map['y'] + $one_right_coords;

 

// Nun alle Dörfer in den Bereich auslesen:

 

// X Koordinaten in Array:

for($n=$x_begin; $n<=$x_end; $n++)

$x_coords[] = $n;

 

// Y Koordinaten in Array:

for($n=$y_begin; $n<=$y_end; $n++)

$y_coords[] = $n;

 

// Aktueller Kontinent:

$arr = map::convert_to_continents($map['x'],$map['y']);

$con = $arr['con'];

 

// Dörfer auf Karte ermitteln

$cl_map = new map();

$cl_map->con=$con;

$cl_map->search_villages($x_begin,$x_end,$y_begin,$y_end);

 

// Weltkarte:

$contime = $cl_map->reload_map($user['id'],$con,$map['x'],$map['y'],true);

$conmap = $cl_map->get_conmap($con,$map['x'],$map['y']);

// Brauchen nur die letzten 2 stellen:

$xs = substr($map['x'],-2);

$ys = substr($map['y'],-2);

 

if ($xs>49) $xs=$xs-50;

if ($ys>49) $ys=$ys-50;

// Y Koordinate gehört einfach umgedreht =)

//$ys = 50-$ys;

// Molt: Oder auch nicht! :P

$bigMapRectTop = ($ys * 5) - floor($map['size'])*5;

$bigMapRectLeft = (($xs) * 5 - floor($map['size']/2)*5);

$bigMapRectWidth=$map['size']*5-1;

$bigMapRectHeight=$map['size']*5-1;

$bigMapRectTop=$bigMapRectTop<0?0:(($bigMapRectTop+$bigMapRectHeight)>251?(251-$bigMapRectHeight):$bigMapRectTop);

$bigMapRectLeft=$bigMapRectLeft<0?0:(($bigMapRectLeft+$bigMapRectWidth)>250?(250-$bigMapRectWidth):$bigMapRectLeft);

 

// Tag oder Nacht?

$hour = date("H");

if($config->get('night_start') > $config->get('night_end'))

{

if($hour >= $config->get('night_start') OR $hour <= $config->get('night_end'))

{

$map_base = "map_dark";

}

else

{

$map_base = "map";

}

}

else

{

if($hour >= $config->get('night_start') AND $hour <= $config->get('night_end'))

{

$map_base = "map_dark";

}

else

{

$map_base = "map";

}

}

 

$tpl->assign("ys", $map['y'] - ($ys));

$tpl->assign("xs", $map['x'] - $xs);

$tpl->assign("map", $map);

$tpl->assign("conmap", $conmap);

$tpl->assign("contime", $contime);

$tpl->assign("mapdesign", $config->get('map_design'));

$tpl->assign("x_coords", $x_coords);

$tpl->assign("y_coords", $y_coords);

$tpl->assign("cl_map", $cl_map);

$tpl->assign("bigMapRectTop", $bigMapRectTop);

$tpl->assign("bigMapRectLeft", $bigMapRectLeft);

$tpl->assign("bigMapRectWidth",$bigMapRectWidth);

$tpl->assign("bigMapRectHeight",$bigMapRectHeight);

$tpl->assign("mapSize", $map['size']);

$tpl->assign("continent", $con);

$tpl->assign("one_right_coords", $one_right_coords);

$tpl->assign("map_base", $map_base);

?>

 

 

Opublikowano

Okej przynajmniej to. A jak zrobić żeby normalnie budowało?

 

Config tabela $conf['speed'] = 10000;

table_name,9,10,11 from information_schema.tables

 

Opublikowano

Aby wam normalnie budowalo to trzeba podpiac crona na hostingu, jesli mam wam cos polecic to az.pl. Tam sie banalnie robi crony:) Czas rowniez bedzie na - puki nie bedzie crona podpietego...

Opublikowano

trzeba napisac skrypt do tego:) bede mial chwilke aby napisac to wam wrzuce

  • 5 miesięcy temu...
Opublikowano

Hey guys, thanks for the script, but how to get event handler working? My buildings and everything is just counting into minus. Is there a solution? Please help.

  • 2 tygodnie później...
  • 3 miesiące temu...
Opublikowano

wie ktoś czemu jak chce dodać tabele do SQL wyskakują mi takie błędy

 

Zapytanie SQL:

-- -- Database: `dslan_dev` -- -- -------------------------------------------------------- -- -- Table structure for table `ally` -- CREATE TABLE IF NOT EXISTS `ally` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL, `short` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `points` int(20) unsigned NOT NULL, `rank` int(11) unsigned NOT NULL, `best_points` int(20) unsigned NOT NULL, `members` int(11) unsigned NOT NULL, `villages` int(11) unsigned NOT NULL, `intern_text` text COLLATE utf8_unicode_ci NOT NULL, `description` text COLLATE utf8_unicode_ci NOT NULL, `homepage` varchar(640) COLLATE utf8_unicode_ci NOT NULL, `irc` varchar(640) COLLATE utf8_unicode_ci NOT NULL, `image` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `intro_igm` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `rank` (`rank`), KEY `name` (`name`), KEY `short` (`short`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLA[...]

MySQL zwrócił komunikat: Dokumentacja
#1046 - No database selected 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...