• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

ModernAac - doubts..

milbradt

New Member
Joined
Dec 25, 2011
Messages
177
Solutions
1
Reaction score
4
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$a = $ots->createObject('Guild');
$alogo = $a->getCustomField('id');
if(!file_exists('../../public/guild_logos/' . $alogo)) {
$alogo = $alogo;
{ else
$alogo = 'default.gif';
}


It's correct?
 
Last edited:
The tags are not correct. You open, then you open another one but only close one (check after the if statment).
Depending on what the function should return, alogo is wrong.
Either way alogo is wrong since it does not return .gif (if you are asking for the name itself).
Query is wrong I guess, check if you have something like player->getGuild()->getId() insted, then check if there is a file named that.

We need more to go on if you want a better awnser.
 
The tags are not correct. You open, then you open another one but only close one (check after the if statment).
Depending on what the function should return, alogo is wrong.
Either way alogo is wrong since it does not return .gif (if you are asking for the name itself).
Query is wrong I guess, check if you have something like player->getGuild()->getId() insted, then check if there is a file named that.

We need more to go on if you want a better awnser.

Yes.. exist.
This also working, however not returning >ELSE<. =\

ex, parts code:
Code:
<?PHP
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();
echo "

$counting = 0;
foreach($SQL->query('SELECT * FROM `guild_wars` WHERE `status` IN (1,4) OR ((`end` >= (UNIX_TIMESTAMP() - 604800) OR `end` = 0) AND `status` IN (0,5));') as $war)
{
  $counting++;
  $a = $ots->createObject('Guild');
  $a->load($war['guild_id']);
  if(!$a->isLoaded())
  continue;

  $e = $ots->createObject('Guild');
  $e->load($war['enemy_id']);
  if(!$e->isLoaded())
  continue;
  $alsdsdogo = $a->getCustomField('id');
  $alogo = $a->getCustomField('id');
  if(!file_exists('../../public/guild_logos/' . $alogo))
  $alogo = $alogo;
   else
     $alogo = 'default.gif';

  $elogo = $e->getCustomField('id');
  if(empty($elogo) || !file_exists('../../public/guild_logos/' . $elogo))
  $elogo = $elogo;

  echo "<tr style=\"background: " . (is_int($counting / 2) ? '#1874CD' : '#1E90FF') . ";color:black;\">
<td align=\"center\"><center><a href=\"".WEBSITE."/index.php/guilds/view/".$a->getId()."\"><img src=\"".$config['website']."/public/guild_logos/".$alogo."\" width=\"64\" height=\"64\" border=\"0\"/><br /><font class=\"details_wars\">".$a->getName()."</center></font></a></td>
<td align=\"center\">";

Code complet:
Code:
<?PHP
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();
echo "

$counting = 0;
foreach($SQL->query('SELECT * FROM `guild_wars` WHERE `status` IN (1,4) OR ((`end` >= (UNIX_TIMESTAMP() - 604800) OR `end` = 0) AND `status` IN (0,5));') as $war)
{
  $counting++;
  $a = $ots->createObject('Guild');
  $a->load($war['guild_id']);
  if(!$a->isLoaded())
  continue;

  $e = $ots->createObject('Guild');
  $e->load($war['enemy_id']);
  if(!$e->isLoaded())
  continue;
  $alsdsdogo = $a->getCustomField('id');
  $alogo = $a->getCustomField('id');
  if(!file_exists('../../public/guild_logos/' . $alogo))
  $alogo = $alogo;
   else
     $alogo = 'default.gif';

  $elogo = $e->getCustomField('id');
  if(empty($elogo) || !file_exists('../../public/guild_logos/' . $elogo))
  $elogo = $elogo;

  echo "<tr style=\"background: " . (is_int($counting / 2) ? '#1874CD' : '#1E90FF') . ";color:black;\">
<td align=\"center\"><center><a href=\"".WEBSITE."/index.php/guilds/view/".$a->getId()."\"><img src=\"".$config['website']."/public/guild_logos/".$alogo."\" width=\"64\" height=\"64\" border=\"0\"/><br /><font class=\"details_wars\">".$a->getName()."</center></font></a></td>
<td align=\"center\">";


$date_begin = $war['begin'] - (5 * 60 * 60);
$date_end = $war['end'] - (5 * 60 * 60);

switch($war['status'])
{
case 0:
{
echo "<center><b>Pending acceptation</b><br />Invited on " . date("M d Y, H:i:s", $date_begin) . " for " . ($date_end > 0 ? (($date_end - $date_begin) / 86400) : "unspecified") . " days. The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.")."<br />Will expire in three days.</center>";
break;
}

case 3:
{
echo "<center><s>Canceled invitation</s><br />Sent invite on " . date("M d Y, H:i:s", $date_begin) . ", canceled on " . date("M d Y, H:i:s", $date_end) . ".</center>";
break;
}

case 2:
{
echo "<center>Rejected invitation<br />Invited on " . date("M d Y, H:i:s", $date_begin) . ", rejected on " . date("M d Y, H:i:s", $date_end) . ".</center>";
break;
}

case 1:
{
echo "<center><br /><font size=\"5\"><span style=\"color: red;\">" . $war['guild_kills'] . " </span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . " </span></font><br /><br /><span style=\"color: darkred; font-weight: bold;\">On a brutal war</span><br />Began on " . date("M d Y, H:i:s", $date_begin) . ($date_end > 0 ? ", will end up at " . date("M d Y, H:i:s", $date_end) : "") . ".<br />The frag limit is set to " . $war['frags'] . " frags, " . ($war['payment'] > 0 ? "with payment of " . $war['payment'] . " bronze coins." : "without any payment.</center>");
break;
}

case 4:
{
echo "<center><font size=\"5\"><span style=\"color: red;\">" . $war['guild_kills'] . " </span> : <span style=\"color: lime;\">" . $war['enemy_kills'] . " </span></font><br /><br /><span style=\"color: darkred;\">Pending end</span><br />Began on " . date("M d Y, H:i:s", $war['begin']) . ", signed armstice on " . date("M d Y, H:i:s", $war['end']) . ".<br />Will expire after reaching " . $war['frags'] . " frags. ".($war['payment'] > 0 ? "The payment is set to " . $war['payment'] . " bronze coins." : "There's no payment set.</center>");
break;
}

case 5:
{
echo "<center><i>Ended</i><br />Began on " . date("M d Y, H:i:s", $date_begin) . ", ended on " . date("M d Y, H:i:s", $date_end) . ". Frag statistics: <span style=\"color: red;\">" . $war['guild_kills'] . " </span> to <span style=\"color: lime;\">" . $war['enemy_kills'] . " </span>.</center>";
break;
}

default:
{
echo "<center>Unknown, please contact with gamemaster.</center>";
break;
}
}

echo "<br /><br /><a onclick=\"show_hide('war-details:" . $war['id'] . "'); return false;\" style=\"cursor: pointer;\"><font class=\"details_wars\"><center>&raquo; Details &laquo;</center></font></a></td>
<td align=\"center\"><center><a href=\"".WEBSITE."/index.php/guilds/view/".$e->getId()."\"><img src=\"".$config['website']."/public/guild_logos/".$elogo."\" width=\"64\" height=\"64\" border=\"0\"/><br /><font class=\"details_wars\">".$e->getName()."</center> </font></a></td>
</tr>
<tr id=\"war-details:" . $war['id'] . "\" style=\"display: none; background: " . (is_int($counting / 2) ? '#D4C0A1' : '#F1E0C6') . ";color:black;\">
<td colspan=\"3\">";
if(in_array($war['status'], array(1,4,5))) {$deaths = $SQL->query('SELECT `pd`.`id`, `pd`.`date`, `gk`.`guild_id` AS `enemy`, `p`.`name`, `pd`.`level`
FROM `guild_kills` gk
LEFT JOIN `player_deaths` pd ON `gk`.`death_id` = `pd`.`id`
LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id`
WHERE `gk`.`war_id` = ' . $war['id'] . ' AND `p`.`deleted` = 0
ORDER BY `pd`.`date` DESC')->fetchAll();
if(!empty($deaths)) {
foreach($deaths as $death) {$killers = $SQL->query('SELECT `p`.`name` AS `player_name`, `p`.`deleted` AS `player_exists`, `k`.`war` AS `is_war`
FROM `killers` k
LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id`
LEFT JOIN `players` p ON `p`.`id` = `pk`.`player_id`
WHERE `k`.`death_id` = ' . $death['id'] . '
ORDER BY `k`.`final_hit` DESC, `k`.`id` ASC')->fetchAll();
$i = 0;$count = count($killers);
$others = false;$deathdate = $death['date'] - (5 * 60 * 60);
echo date("j M Y, H:i", $deathdate) . " <span style=\"font-weight: bold; color: " . ($death['enemy'] == $war['guild_id'] ? "red" : "green") . ";\"><font size=3>+</font></span>
<a href=\"".WEBSITE."/index.php/character/view/".$death['name']. "\"><b><font class=\"details_wars\">".$death['name']."</font></b></a> ";
foreach($killers as $killer) {$i++;
if($killer['is_war'] != 0) {
if($i == 1)
echo "killed at level <b>".$death['level']."</b> by ";
else if($i == $count && $others == false)
echo " and by ";
else
echo ", ";

if($killer['player_exists'] == 0)
echo "<a href=\"".WEBSITE."/index.php/character/view/".$killer['player_name']."\">";

echo '<font class="details_wars">'.$killer['player_name'].'</font>';
if($killer['player_exists'] == 0)
echo "</a>";
}
else$others = true;

if($i == $count) {
if($others == true)
echo " and few others";

echo ".<br />";
}
}
}
}
else
echo "<center>There were no frags on this war so far.</center>";
}
else
echo "<center>This war did not began yet.</center>";

echo "</td>
</tr>";
}

if($counting == 0) {
echo "<tr style=\"background: #D4C0A1;\">
<td colspan=\"3\" style=\"color:black;\"><center>No active wars.</center></td>
</tr>";
}
echo "</table>";?></div></div>
 
Last edited:
Code:
<?php
    require("config.php");
    $ots = POT::getInstance();
    $ots->connect(POT::DB_MYSQL, connection());
    $SQL = $ots->getDBHandle();

    $count = 0;
   
    $queryPost = $SQL->query('SELECT * FROM `guild_wars` WHERE `status` IN (1,4) OR ((`end` >= (UNIX_TIMESTAMP() - 604800) OR `end` = 0) AND `status` IN (0,5));');
    foreach($queryPost as $query) {
        $count++;
        $guild = $ots->createObject('Guild');
        $guild->load($query['guild_id']);
        if(!$guild->isLoaded()) {
            continue;
        }

        $enemyGuild = $ots->createObject('Guild');
        $enemyGuild->load($query['enemy_id']);
        if(!$enemyGuild->isLoaded()) {
            continue;
        }

        $logo = $guild->getCustomField('id');
        if(file_exists('../../public/guild_logos/' . $logo . '.gif')) {
            $logo = $logo;
        } else {
            $logo = 'default.gif';
        }

        echo "<tr style=\"background: " . (is_int($count / 2) ? '#1874CD' : '#1E90FF') . ";color:black;\">
        <td align=\"center\"><center><a href=\"".WEBSITE."/index.php/guilds/view/".$guild->getId()."\"><img src=\"".$config['website']."/public/guild_logos/".$logo."\" width=\"64\" height=\"64\" border=\"0\"/><br /><font class=\"details_wars\">".$guild->getName()."</center></font></a></td>
        <td align=\"center\">";
    }
?>

That script is plain weird, the enemy logo was fetched aswell as the enemy guild but not used.
The code should work now I guess, the path to default.gif might be wrong.
 
not work. =\

Guilds that have the GIF image load.
The guild are default does not load the image.

$logo = $logo; = working
$logo = 'default.gif'; = don't work ;\
 
As I said the location is most likely wrong, where is it located then?
Right not it expects the image to be in www/default.gif.
 
located:
var/www/tibia/public/guild_logos/default.gif

if I use..

if(file_exists('../../public/guild_logos/' . $logo . '.gif'))
$logo = 'default.gif';

work.. =S
 
Last edited:
Back
Top