0) ? (float) SPEED : 1.0; $startAt = $planTime + (int) round($delay * 86400 / $speed); if (time() < $startAt) { return false; } // ATENTIE: NATARS_UID e constanta de CLASA (Artifacts::NATARS_UID), nu // una globala. defined('NATARS_UID') intoarce mereu false, deci o // verificare cu defined() ar folosi tacut o valoare gresita si Natarii // n-ar mai fi gasiti niciodata. $natarUid = class_exists('Artifacts') ? (int) Artifacts::NATARS_UID : 3; // capitala Natarilor: satul lor care are slotul de Minune $res = mysqli_query($database->dblink, "SELECT v.wref, f.f99 AS level FROM " . TB_PREFIX . "vdata v JOIN " . TB_PREFIX . "fdata f ON f.vref = v.wref WHERE v.owner = " . $natarUid . " AND v.capital = 1 AND f.f99t = 40 LIMIT 1"); $row = $res ? mysqli_fetch_assoc($res) : null; if (!$row) { return false; } $wref = (int) $row['wref']; $level = (int) $row['level']; if ($level >= 100) { return false; // gata, nu mai are ce urca } // Un nivel deja in lucru? Coada de constructii tine randul in bdata. $busy = mysqli_query($database->dblink, "SELECT COUNT(*) AS total FROM " . TB_PREFIX . "bdata WHERE wid = " . $wref); $busyRow = $busy ? mysqli_fetch_assoc($busy) : null; if ($busyRow && (int) $busyRow['total'] > 0) { return false; // asteptam sa se termine nivelul curent } $next = $level + 1; if (!isset($bid40[$next]['time'])) { return false; } // Timpul REAL din datele de joc, scalat cu viteza serverului - la fel ca // pentru orice alta constructie. Natarii nu sar peste el. $buildTime = (int) max(1, round($bid40[$next]['time'] / $speed)); // Folosim metoda jocului, nu SQL propriu: ea actualizeaza si tipul // cladirii in fdata si respecta formatul cozii. $ok = $database->addBuilding($wref, 99, 40, 0, time() + $buildTime, 0, $next); if (!$ok) { error_log('[TravianZ] Natars WW: constructia nu a pornit: ' . mysqli_error($database->dblink)); return false; } return true; } }