function setup_target($name) { global $pvptimeout, $session; //Legacy support if (is_numeric($name)) { $where = "acctid={$name}"; } else { $where = "login='******'"; } $sql = "SELECT name AS creaturename, level AS creaturelevel, weapon AS creatureweapon, gold AS creaturegold, experience AS creatureexp, maxhitpoints AS creaturehealth, attack AS creatureattack, defense AS creaturedefense, loggedin, location, laston, alive, acctid, pvpflag, boughtroomtoday, race FROM " . db_prefix("accounts") . " WHERE {$where}"; $result = db_query($sql); if (db_num_rows($result) > 0) { $row = db_fetch_assoc($result); if (abs($session['user']['level'] - $row['creaturelevel']) > 2) { output("`\$Error:`4 That user is out of your level range!"); return false; } elseif ($row['pvpflag'] > $pvptimeout) { output("`\$Oops:`4 That user is currently engaged by someone else, you'll have to wait your turn!"); return false; } elseif (strtotime($row['laston']) > strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " sec") && $row['loggedin']) { output("`\$Error:`4 That user is now online, and cannot be attacked until they log off again."); return false; } elseif ((int) $row['alive'] != 1) { output("`\$Error:`4 That user is not alive."); return false; } elseif ($session['user']['playerfights'] > 0) { $sql = "UPDATE " . db_prefix("accounts") . " SET pvpflag='" . date("Y-m-d H:i:s") . "' WHERE acctid={$row['acctid']}"; db_query($sql); $row['creatureexp'] = round($row['creatureexp'], 0); $row['playerstarthp'] = $session['user']['hitpoints']; $row['fightstartdate'] = strtotime("now"); $row = modulehook("pvpadjust", $row); pvpwarning(true); return $row; } else { output("`4Judging by how tired you are, you think you had best not engage in battle against other players right now."); return false; } } else { output("`\$Error:`4 That user was not found! It's likely that their account expired just now."); return false; } return false; }
case 3: output("`&You feel vigorous!"); $session['user'][turns]++; } $session[bufflist][101] = array("name" => "`#Buzz", "rounds" => 10, "wearoff" => "Your buzz fades.", "atkmod" => 1.25, "roundmsg" => "You've got a nice buzz going.", "activate" => "offense"); } else { output("You don't have enough money. How can you have any ale if you don't have any money!?!"); } } } else { if ($_GET['act'] == "listupstairs") { addnav("Refresh the list", "inn.php?op=bartender&act=listupstairs"); output("Cedrik lays out a set of keys on the counter top, and tells you which key opens whose room. The choice is yours, you may sneak in and attack any one of them."); $pvptime = getsetting("pvptimeout", 600); $pvptimeout = date("Y-m-d H:i:s", strtotime("-{$pvptime} seconds")); pvpwarning(); $days = getsetting("pvpimmunity", 5); $exp = getsetting("pvpminexp", 1500); $sql = "SELECT name,alive,location,sex,level,laston,loggedin,login,pvpflag FROM accounts WHERE \n\t\t\t\t(locked=0) AND \n\t\t\t\t(level >= " . ($session['user']['level'] - 1) . " AND level <= " . ($session['user']['level'] + 2) . ") AND \n\t\t\t\t(alive=1 AND location=1) AND \n\t\t\t\t(age > {$days} OR dragonkills > 0 OR pk > 0 OR experience > {$exp}) AND\n\t\t\t\t(laston < '" . date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " sec")) . "' OR loggedin=0) AND\n\t\t\t\t(acctid <> " . $session['user'][acctid] . ")\n\t\t\t\tORDER BY level DESC"; $result = db_query($sql) or die(db_error(LINK)); output("<table border='0' cellpadding='3' cellspacing='0'><tr><td>Name</td><td>Level</td><td>Ops</td></tr>", true); for ($i = 0; $i < db_num_rows($result); $i++) { $row = db_fetch_assoc($result); $biolink = "bio.php?char=" . rawurlencode($row[login]) . "&ret=" . urlencode($_SERVER['REQUEST_URI']); addnav("", $biolink); if ($row[pvpflag] > $pvptimeout) { output("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'><td>{$row['name']}</td><td>{$row['level']}</td><td>[ <a href='{$biolink}'>Bio</a> | `i(Attacked too recently)`i ]</td></tr>", true); } else { output("<tr class='" . ($i % 2 ? "trlight" : "trdark") . "'><td>{$row['name']}</td><td>{$row['level']}</td><td>[ <a href='{$biolink}'>Bio</a> | <a href='pvp.php?act=attack&bg=1&name=" . rawurlencode($row[login]) . "'>Attack</a> ]</td></tr>", true); addnav("", "pvp.php?act=attack&bg=1&name=" . rawurlencode($row[login])); }
output("`\$Error:`4 That user is not in a location that you can attack them."); }else{ if((int)$row[alive]!=1){ output("`\$Error:`4 That user is not alive."); }else{ if ($session[user][playerfights]>0){ $sql = "UPDATE accounts SET pvpflag=now() WHERE acctid=$row[acctid]"; db_query($sql); $battle=true; $row[pvp]=1; $row[creatureexp] = round($row[creatureexp],0); $row[playerstarthp] = $session[user][hitpoints]; $session[user][badguy]=createstring($row); $session[user][playerfights]--; $session['user']['buffbackup']=""; pvpwarning(true); }else{ output("`4Judging by how tired you are, you think you had best not engage in another player battle today."); } } } } } }else{ output("`\$Error:`4 That user was not found! How'd you get here anyhow?"); } if ($battle){ }else{ addnav("Return to the village","village.php"); }