Page 1 of 1

Bounties by KyleMassacre

Posted: Fri Jul 22, 2016 6:29 pm
by cbsarge
Hi Kyle,

I hope you see this. I thought it might be fun to add a home page element to your Bounties module. I've got what I think should be a working version of it except I decided to go off the reservation and add avatars to the listing on the home page. Now after refreshing the Home page a few times it logs me out of the game.

Any thoughts on why this might be happening? I seem to remember a similar behavior when I tried adding the avatars to the player listing but, had abandoned trying to fix it then.

Any help would be greatly appreciated!

home.php

Code: Select all

<?php
TableHeader("Available Bounties");
echo Translate("Make some quick cash or put the hit out on someone!")."<br>";
echo Translate("Try to collect one of these contracts or head over to the Bounties Office and take out your own!");
echo "<center>";
$result = $db->Execute("select bounty_id,bounty_userid,bounty_adder,bounty_price,bounty_start,bounty_private,bounty_inAction from bounty_list");
{
	echo "<table class='plainTable'>";
	echo "<tr class='titleLine'>";
	echo "<td>" . Translate("#"). "</td>";
	echo "<td>" . str_replace(" ", " ", Translate("Victim")). "</td>";
	echo "<td>" . str_replace(" ", " ", Translate("Mug Shot")). "</td>";
	echo "<td>" . str_replace(" ", " ", Translate("Bounty Price")) . "</td>";
	echo "<td>" . str_replace(" ", " ", Translate("Bounty Owner")) . "</td>";
	echo "<td>" . str_replace(" ", " ", Translate("Bounty Actions")). "</td>";
	echo "</tr>";
	$row = 0;
	if($result->EOF)
		echo "<tr class='evenLine'><td colspan='100%' align='center'><strong>No bounties to display</strong></td></tr>";
	else
	{
		while (!$result->EOF)
		{
    		if ($row % 2 == 0)
        		echo "<tr class='evenLine'>";
    		else
        		echo "<tr class='oddLine'>";
        	$row ++;
        	$a = $db->Execute("select id, username from users where id = ?",$result->fields[2]);
        	$b = $db->Execute("select id, username from users where id = ?",$result->fields[1]);
			$avatarb = $db->Execute("select id from users where id = ?",$result->fields[1]);
        	if($result->fields[5] == "un-listed")
        	{
        		if($result->fields[2] == $userId)
        			$adder = $a->fields[1]. "<em>(Private)</em>";
        		else
					$adder = "<em>Private</em>";
			}
			else
				$adder = "<a href='index.php?p=view_player&id=".$a->fields[0]."'>".$a->fields[1]."</a>";
        	echo "<td>".$row.".</td>";
			echo "<td><a href='index.php?p=view_player&id=".$b->fields[0]."'>".$b->fields[1]."</td>";
			echo "<td>";
			DisplayAvatar($avatarb->fields[0]);
			echo "</td>";
			echo "<td>".FormatNumber($result->fields[3]).str_replace("","&nbsp",Translate(" !Currency"))."</td>";
			echo "<td>".$adder."</td>";
			echo "<td>";
			if  ($result->fields[2] == $userId)
				LinkButton("Cancel Bounty","index.php?p=bounties&action=cancel&id={$result->fields[0]}");
			else
				LinkButton("Claim Bounty","index.php?p=bounties&action=claim&id={$result->fields[0]}");
			echo "</td>";
			$result->MoveNext();
		}
	$result->Close();
	}
	echo "</tr>";
	echo "</table>";

}
LinkButton("Bounties Office","index.php?p=bounties");
echo "</center>";
tableFooter();
echo "<br>";