There are still creatures defending a building of your kingdom or one of your allies.<br> You have to remove them first.<br> '; $no = 1; } if ($acc["attacked"]) { $output .= 'You can\'t switch kingdoms while you are under attack.<br>'; $no = 1; } if ($no == 0) { $acc["brimstone"] -= $cost; $acc["crystal"] -= $cost; $acc["essence"] -= $cost; $acc["granite"] -= $cost; if ($inhabitants == 1) { gDeleteKingdom($acc["kingdom"]); } $inhabitants--; $sql = "UPDATE accounts SET leadertype = '0', kingdom = '{$row['id']}', brimstone = '{$acc['brimstone']}', crystal = '{$acc['crystal']}', essence = '{$acc['essence']}', granite = '{$acc['granite']}', gems_in = '0', gems_out = '0' WHERE id = '{$acc['id']}'"; $result = $db->query($sql); $sql = "UPDATE summons SET type = '0' WhERE type = '6' AND account = '{$acc['id']}'"; $result = $db->query($sql); $sql = "UPDATE summons SET type = '0' WHERE type = '6' AND target = '{$acc['id']}'"; $result = $db->query($sql); $sql = "DELETE FROM invitations WHERE account = '{$acc['id']}' AND kingdom = '{$row['id']}'"; $result = $db->query($sql); if (!$gdSpecialKingdoms[$acc["kingdom"]]) { $text = "\r\n\t\t\t\t<a href=\"index.php?page=playerinfo&action=viewinfo&aid={$acc['id']}\">{$acc['name']}</a> left our kingdom.<br>\r\n\t\t\t\t"; gNews(1, 1, "{$acc['name']} leaves kingdom", $text, $acc["kingdom"]); } $text = "\r\n\t\t\t<a href=\"index.php?page=playerinfo&action=viewinfo&aid={$acc['id']}\">{$acc['name']}</a> accepted the kingdom invitation and joined our kingdom!<br>\r\n\t\t\t";
$sql = "OPTIMIZE TABLE mails"; $result = $db->query($sql); // clean up killed kingdoms $sql = "SELECT id, name FROM kingdoms"; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { $kingdomid = $row["id"]; $newsql = "SELECT id FROM accounts WHERE kingdom = '{$kingdomid}' AND status != '2'"; $newresult = $db->query($newsql); $numrows = $db->num_rows($newresult); if ($numrows == 0) { $newsql = "SELECT id FROM kdbattles WHERE (target = '{$kingdomid}' OR kingdom = '{$kingdomid}') AND status != '2'"; $newresult = $db->query($newsql); $numrows = $db->num_rows($newresult); if ($numrows == 0) { gDeleteKingdom($kingdomid); } } } } // cleaning pubs $sql = "DELETE FROM pubs WHERE threadtime < {$time} - 2592000 AND sticky = '0'"; $result = $db->query($sql); // exclude unkillable mages $excluded = ""; foreach ($gdUnkillableMages as $mageid) { if ($excluded != "") { $excluded .= " AND "; } $excluded .= "id != {$mageid}"; }