$guild = new Guild($guild_id); $enemyGuild = new Guild($enemy_id); if (!$guild->isLoaded() || !$enemyGuild->isLoaded()) { $guild_errors[] = 'Guild with ID <b>' . $guild_id . '</b> or ID<b>' . $enemy_id . '</b> doesn\'t exist.'; } if (empty($guild_errors)) { $guild_leader_char = $guild->getOwner(); $guild_leader = FALSE; $account_players = $account_logged->getPlayers(); foreach ($account_players as $player) { if ($guild_leader_char->getId() == $player->getId()) { $guild_leader = TRUE; } } if ($guild_leader) { if ($enemyGuild->getID() != $guild->getID()) { $currentWars = array(); $wars = new DatabaseList('GuildWar'); foreach ($wars as $war) { if ($war->getStatus() == GuildWar::STATE_INVITED || $war->getStatus() == GuildWar::STATE_ON_WAR) { if ($war->getGuild1ID() == $guild->getID()) { $currentWars[$war->getGuild2ID()] = $war->getStatus(); } elseif ($war->getGuild2ID() == $guild->getID()) { $currentWars[$war->getGuild1ID()] = $war->getStatus(); } } } if (isset($currentWars[$enemyGuild->getID()])) { // in war or invited if ($currentWars[$enemyGuild->getID()] == GuildWar::STATE_INVITED) { // guild already invited you or you invited that guild