@ -108,27 +108,21 @@ echo "<b> $kampf_a1[name] vs. $kampf_a2[name]";
}
#######################Clan Kampf
if($ab == "Clan Kampf") {
if($ab == "Clanfight") {
echo "<SCRIPTlanguage='JavaScript'>";
?>
function showfight(){
var Info = window.open("./clan_kampf.php?char_id=<?phpecho$char_id;?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
var Info = window.open("./event_abholen.php?<?phpecho$abholstring;?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
}
<?php
echo "</SCRIPT>";
$kampf_a = mysql_fetch_array(mysql_query("SELECT c1.name AS c1name, c2.name, k.id, k.dauer FROM clan_kampf k LEFT JOIN chars c1 ON(k.char1=c1.id) LEFT JOIN chars c2 ON(k.char2=c2.id) WHERE k.db_satz='$char_id' LIMIT 1"));
$zeit_in_sek = $kampf_a[dauer] - time();
$zeit_in_sek = getEventStatusBlocked($char_id);
?>
<palign=center><b>Clan Kampf</b><br> <br>
<?php
echo "<b> $kampf_a[c1name] vs. $kampf_a[name] </b><br> <br>";
// okay does this user already has a char in the fight??
$qry = mysql_query('SELECT count(*) as anzahl FROM clan_challenge_participants ccp inner join chars c on ccp.char_id = c.id WHERE besitzer = ' .$user['id']);
$qry = mysql_query('SELECT count(*) as anzahl FROM clan_challenge_participants ccp inner join chars c on ccp.char_id = c.id WHERE besitzer = ' .$user['id'] . ' AND clan_challenge_id = ' . $clan_challenge_id);
@ -141,8 +141,8 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
function getEventStatus($charid) {
$sql = 'SELECT event_type FROM event_chars ec inner join events e on ec.event_id = e.event_id where block_end > now() and char_id = ' . $charid;
$sql = 'SELECT event_type FROM event_chars ec inner join events e on ec.event_id = e.event_id where (block_end > now() or abgeholt = 1) and char_id = ' . $charid;
// echo $sql . '<br>';
$qry = mysql_query($sql);
$row = mysql_fetch_assoc($qry);
switch ($row['event_type']) {
@ -161,6 +161,27 @@ function getEventStatus($charid) {
case EVENT_CLAN_FIGHT:
return 'Clanfight';
}
return NULL;
}
function getEventStatusBlocked($charid) {
$sql = 'SELECT Timestampdiff(Second,now(),MAX(block_end)) FROM event_chars WHERE char_id = ' . $charid;
// echo $sql . '<br>';
$row = mysql_fetch_row(mysql_query($sql));
return $row[0];
}
function getEventIdsToFetch($charid) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end <now()andabgeholt =1ANDchar_id ='.$charid;
$qry = mysql_query($sql);
$result = array();
while ($row = mysql_fetch_row($qry)) {
$result[] = $row[0];
}
return $result;
}
function abholenChar(array $user, $event_id, $char_id) {