The Multiple Inventory mod has been modified from the original version that can be found on makewebgames.com
The original attack bit was taken off the GRPG engine and modified/enhanced to work with McCodes.
attack.php
<?php
/*Designed by Tyr*/
$menuhide=1;
$atkpage=1;
require_once("globals.php");
$_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs((int) $_GET['ID']) : false;
if(!$_GET['ID']){ echo "You did not select a valid ID"; $h->endpage(); exit; }
$energy = $ir['maxenergy']/4;
$error = ($ir['hp'] <= 0) ? "You can't attack someone when you have no health!" : $error;
$error = ($ir['energy']<$energy) ? "You need to have at least 25% of your energy if you want to attack someone." : $error;
$error = ($ir['jail'] > 0) ? "You can't attack someone if you are in jail." : $error;
$error = ($ir['hospital'] > 0) ? "You can't attack someone if you are in the hospital." : $error;
$error = ($_GET['ID'] == "") ? "You didn't choose someone to attack." : $error;
$error = ($_GET['ID'] == $ir['userid']) ? "You can't attack yourself." : $error;
$armor1 = $ir['equip_boots'];
$armor2 = $ir['equip_helmet'];
$armor3 = $ir['equip_breastplate'];
$armor4 = $ir['equip_leggings'];
$armor5 = $ir['equip_gloves'];
if($armor1 > 0)
{
$yourarmorstuff = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_boots'].")");
$dat = $db->fetch_row($yourarmorstuff);
$boots = ($dat['boots'] < 1) ? 1 : $dat['boots'];
}
if($armor2 > 0)
{
$armo2 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_helmet'].")");
$dt = $db->fetch_row($armo2);
$helmet = ($dt['helmet'] < 1) ? 1 : $dt['helmet'];
}
if($armor3 > 0)
{
$armo3 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_breastplate'].")");
$dat3 = $db->fetch_row($armo3);
$breastplate = ($dat3['breastplate'] < 1) ? 1 : $dat3['breastplate'];
}
if($armor4 > 0)
{
$armo4 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_leggings'].")");
$dat4 = $db->fetch_row($armo4);
$leggings = ($dat4['leggings'] < 1) ? 1 : $dat4['leggings'];
}
if($armor5 > 0)
{
$armo5 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_gloves'].")");
$dat5 = $db->fetch_row($armo5);
$gloves = ($dat5['gloves'] >= 1) ? $dat5['gloves'] : 0 ;
}
$defense = $boots+helmet+$breastplate+$leggings+$gloves+0; // $IR*users* Defense Statistics.
$attacking_person = mysql_query("SELECT `u`.`userid`,`u`.`username`,`u`.`hp`,`u`.`maxhp`,`u`.`level`, " .
"`u`.`money`,`u`.`location`,`u`.`hospital`,`u`.`jail`,`u`.`fedjail`,`u`.`gang`,`u`.`user_level`, " .
"`u`.`equip_primary`,`u`.`equip_secondary`,`u`.`equip_boots`,`u`.`equip_helmet`,`u`.`equip_gloves`, " .
"`u`.`equip_breastplate`,`u`.`equip_leggings`,`u`.`exp`,`us`.`strength`,`us`.`agility`,`us`.`guard` " .
"FROM `users` `u` " .
"LEFT JOIN `userstats` `us` " .
"ON `u`.`userid`=`us`.`userid` " .
"WHERE (`u`.`userid`=".$_GET['ID'].")", $c)
OR die(mysql_error());
$attack_person = mysql_fetch_array($attacking_person);
$armo1 = $attack_person['equip_boots'];
$armo2 = $attack_person['equip_helmet'];
$armo3 = $attack_person['equip_breastplate'];
$armo4 = $attack_person['equip_leggings'];
$armo5 = $attack_person['equip_gloves'];
if($armo1 > 0)
{
$ayourarmorstuff = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_boots'].")");
$adat = $db->fetch_row($ayourarmorstuff);
$aboots = ($adat['boots'] < 1) ? 1 : $adat['boots'];
}
if($armo2 > 0)
{
$armor2 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_helmet'].")");
$adt = $db->fetch_row($armor2);
$ahelmet = ($adt['helmet'] < 1) ? 1 : $adt['helmet'];
}
if($armo3 > 0)
{
$armor3 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_breastplate'].")");
$adat3 = $db->fetch_row($armor3);
$abreastplate = ($adat3['breastplate'] < 1) ? 1 : $adat3['breastplate'];
}
if($armo4 > 0)
{
$armor4 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_leggings'].")");
$adat4 = $db->fetch_row($armor4);
$aleggings = ($adat4['leggings'] < 1) ? 1 : $adat4['leggings'];
}
if($armo5 > 0)
{
$armor5 = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_gloves'].")");
$adat5 = $db->fetch_row($armor5);
$agloves = ($adat5['gloves'] >= 1) ? $adat5['gloves'] : 0 ;
}
$adefense = $boots+helmet+$breastplate+$leggings+$gloves+0;
$primarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$attack_person['equip_primary']."");
$ouch = $db->fetch_row($primarydamage);
$secondarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$attack_person['equip_secondary']."");
$ouchy = $db->fetch_row($secondarydamage);
if($attack_person['equip_primary'] > 0 && $attack_person['equip_secondary'] > 0)
{
$killer = ($ouch['weapon']+$ouchy['weapon']+$attack_person['strength'])-($ir['guard']+$defense);
$wepname = "".$ouch['itmname']." and their ".$ouchy['itmname']."";
}
elseif($attack_person['equip_primary'] > 0 && $attack_person['equip_secondary'] = 0)
{
$killer = ($ouch['weapon']+$attack_person['strength'])-($ir['guard']+$defense);
$wepname = "".$ouch['itmname']."";
}
elseif($attack_person['equip_primary'] = 0 && $attack_person['equip_secondary'] > 0)
{
$killer = ($ouchy['weapon']+$attack_person['strength']) - ($ir['guard']+$defense);
$wepname = "".$ouch['itmname']."";
}
else
{
$killer = $attack_person['strength']-($ir['guard']+$defense);
$wepname = Fists;
}
$aprimarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$ir['equip_primary']."");
$winn = $db->fetch_row($aprimarydamage);
$asecondarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$ir['equip_secondary']."");
$win = $db->fetch_row($asecondary);
if($ir['equip_primary'] > 0 AND $ir['equip_primary'] > 0)
{
$killers = ($winn['weapon']+$win['weapon']+$ir['strength'])-($attack_person['guard']+$adefense);
$aweap = "".$winn['itmname']." and their ".$win['itmname']."";
}
elseif($ir['equip_primary'] > 0 && $ir['equip_secondary'] == 0)
{
$killers = ($winn['weapon']+$ir['strength'])-($attack_person['guard']+$adefense);
$aweap = "".$winn['itmname']."";
}
elseif($ir['equip_primary'] == 0 && $ir['equip_secondary'] > 0)
{
$killers = ($win['weapon']+$ir['strength']) - ($attack_person['guard']+$adefense);
$aweap = "".$win['itmname']."";
}
else
{
$killers = $ir['strength'] - ($attack_person['guard']+$defense);
$aweap = Fists;
}
if(!mysql_num_rows($attacking_person)) { echo "Invalid User Selected to attack."; $h->endpage(); exit; }
$error = ($attack_person['location'] != $ir['location']) ? "You must be in the same city as the person you are attacking. Duh." : $error;
$error = ($attack_person['username'] == "") ? "That person doesn't exist." : $error;
$error = ($attack_person['hospital'] > 0) ? "You can't attack someone that is in the hospital." : $error;
$error = ($attack_person['jail'] > 0) ? "You can't attack someone that is in jail." : $error;
$error = ($ir['level'] > 5 && $attack_person['level'] < 6) ? "You can't attack someone that is level 5 or below because you are higher than level 5." : $error;
$error = ($ir['gang'] == $attack_person['gang'] AND $ir['gang'] != 0) ? "You cant attack someone in the same clan as yourself!" : $error;
$error = ($attack_person['hp'] <= 0) ? "This person has no health at the moment." : $error;
$error = ($attack_person['fedjail'] > 1) ? "This person is in fed and cannot be attacked." : $error;
$error = ($attack_person['user_level'] == 2) ? "Admins Cannot be attacked." : $error;
if (isset($error)){
echo "".htmlentities(stripslashes($error))."";
$h->endpage();
exit;
}
$yourhp = $ir['hp']; // $IR Health
$theirhp = $attack_person['hp']; // Defenders Health $attack_person
echo "<center>Fight House</center>
<center><font color=white>You are in a fight with ".$attack_person['username'].".</center>
";
$wait = ($ir['agility'] > $attack_person['agility']) ? 1 : 0;
while($yourhp > 0 && $theirhp > 0)
{
$damage = $killer;
$damage = ($damage < 1) ? 1 : $damage;
if($wait == 0)
{
$yourhp = $yourhp - $damage;
echo "<font color=white><center> " . $attack_person['username'] . " hit you for " . $damage . " damage using their " . $wepname . ". <br></center>"; // WEAPON STUFF HERE LATER.
}
else { $wait = 0; }
if($yourhp > 0)
{
$damage = $killers;
$damage = ($damage < 1) ? 1 : $damage;
$theirhp = $theirhp - $damage;
echo "<font color=white><center> You hit " . $attack_person['username'] . " for " . $damage . " damage using your ". $aweap . ". </center><br>";
}
if($theirhp <= 0){ // ATTACKER WINS AND UPDATES
$winner = $ir['userid'];
$theirhp = 0;
$moneywon = floor($attack_person['money'] /10);
$expwon = 150 - (25 * ($ir['level'] - $attack_person['level']));
$expwon = ($expwon < 0) ? 0 : $expwon;
$newexp = $expwon + $ir['exp'];
$newmoney = $ir['money'] + $moneywon;
$result = mysql_query("UPDATE `users` SET `exp` = ".$newexp.", money = ".$newmoney." WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error());
$newmoney = $attack_person['money'] - $moneywon;
$result = mysql_query("UPDATE `users` SET `money` = ".$newmoney.", `hospital` = 30 WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error());
event_add($attack_person['userid'], "You were hospitalized by ".$ir['username']." for 20 minutes.", $c);
echo "<font color=white><center>You hospitalized " . $attack_person['username'] . ". You gain $expwon exp and stole $".$moneywon." from " . $attack_person['username'] . ".</center>";
}
if($yourhp <= 0)
{ // DEFENDER WINS AND UPDATES
$winner = $attack_person['userid'];
$yourhp = 0;
$moneywon = floor($ir['money'] /10);
$expwon = 100 - (25 * ($attack_person['level'] - $ir['level']));
$expwon = ($expwon < 0) ? 0 : $expwon;
$newexp = $expwon + $attack_person['exp'];
$newmoney = $attack_person['money'] + $moneywon;
$result = mysql_query("UPDATE `users` SET `exp` = ".$newexp.", `money` = ".$newmoney." WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error());
$newmoney = $ir['money'] - $moneywon;
$result = mysql_query("UPDATE `users` SET `money` = '".$newmoney."',`hospital` = '20' WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error());
event_add($ir['userid'], "You were hospitalized by ".$attack_person['username']." for 20 minutes.", $c);
echo "<center><font color=white>".$attack_person['username']." Hospitalized you and stole $".$moneywon." from you.</center>";
}
}
//UPDATE USERS
$newenergy = $ir['energy'] - floor($ir['energy'] * .10);
$result = mysql_query("UPDATE `users` SET `hp` = ".$theirhp." WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error());
$result = mysql_query("UPDATE `users` SET `hp` = ".$yourhp.", `energy` = '".$newenergy."' WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error());
echo "</td></tr>";
?>
inventory.php
<?php
require_once("globals.php");
$q=$db->query("SELECT * FROM `items`
WHERE `itmid` IN({$ir['equip_primary']},{$ir['equip_secondary']},{$ir['equip_armor']},{$ir['equip_helmet']},{$ir['equip_boots']},{$ir['equip_leggings']},{$ir['equip_gloves']},{$ir['equip_breastplate']})");
echo "<h3>Equipped Items</h3><hr />";
while($r=$db->fetch_row($q))
{
$equip[$r['itmid']]=$r;
}
echo "<table width='75%' cellspacing='1' class='table'>
<tr>
<th>Helmet</th>
<td>";
if($equip[$ir['equip_helmet']]['itmid'])
{
echo $equip[$ir['equip_helmet']]['itmname']."</td><td><a href='unequip.php?type=equip_helmet'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo '</tr>
<tr>
<th>Breast Plate</th>
<td>';
if($equip[$ir['equip_breastplate']]['itmid'])
{
echo $equip[$ir['equip_breastplate']]['itmname']."</td>
<td><a href='unequip.php?type=equip_breastplate'>Unequip Item</a></td>";
}
else
{
print 'None equipped.</td><td> </td>';
}
print '</tr>
</tr>
<tr>
<th>Primary Weapon</th>
<td>';
if($equip[$ir['equip_primary']]['itmid'])
{
echo $equip[$ir['equip_primary']]['itmname']."</td>
<td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo '</tr>
<tr>
<th>Secondary Weapon</th>
<td>';
if($equip[$ir['equip_secondary']]['itmid'])
{
echo $equip[$ir['equip_secondary']]['itmname']."</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo '</tr>
<tr>
<th>Leggings</th>
<td>';
if($equip[$ir['equip_leggings']]['itmid'])
{
echo $equip[$ir['equip_leggings']]['itmname']."</td>
<td><a href='unequip.php?type=equip_braclet'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo '</tr>
<tr>
<th>Gloves</th>
<td>';
if($equip[$ir['equip_gloves']]['itmid'])
{
echo $equip[$ir['equip_gloves']]['itmname']."</td>
<td><a href='unequip.php?type=equip_ring'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo '</tr>
<tr>
<th>Boots</th>
<td>';
if($equip[$ir['equip_boots']]['itmid'])
{
echo $equip[$ir['equip_boots']]['itmname']."</td><td><a href='unequip.php?type=equip_boots'>Unequip Item</a></td>";
}
else
{
echo 'None equipped.</td><td> </td>';
}
echo "</tr>
</table><hr />
<h3>Inventory</h3><hr />";
$inv=$db->query("SELECT iv.*,i.*,it.*
FROM `inventory` iv
LEFT JOIN `items` i
ON iv.`inv_itemid`=i.`itmid`
LEFT JOIN `itemtypes` it
ON i.`itmtype`=it.`itmtypeid`
WHERE iv.`inv_userid`={$userid}
ORDER BY i.`itmtype` ASC, i.`itmname` ASC");
if ($db->num_rows($inv) == 0)
{
echo "<b>You have no items\!</b>";
}
else
{
echo "<b>Your items are listed below.</b><br />
<table width=100% class=\"table\" border=\"0\" cellspacing=\"1\">
<tr>
<td class=\"h\">Item</td>
<td class=\"h\">Sell Value</td>
<td class=\"h\">Total Sell Value</td>
<td class=\"h\">Links</td>
</tr>";
$lt="";
while($i=$db->fetch_row($inv))
{
if($lt!=$i['itmtypename'])
{
$lt=$i['itmtypename'];
echo "\n<tr><td colspan=4><b>{$lt}</b></td></tr>";
}
if($i['weapon'])
{
$i['itmname']="<font color='red'>*</font>".$i['itmname'];
}
if($i['armor'])
{
$i['itmname']="<font color='green'>*</font>".$i['itmname'];
}
if($i['helmet'])
{
$i['itmname']="<font color='blue'>*</font>".$i['itmname'];
}
if($i['boots'])
{
$i['itmname']="<font color='pink'>*</font>".$i['itmname'];
}
if($i['breastplate'])
{
$i['itmname']="<font color='brown'>*</font>".$i['itmname'];
}
if($i['leggings'])
{
$i['itmname']="<font color='yellow'>*</font>".$i['itmname'];
}
if($i['gloves'])
{
$i['itmname']="<font color='lime'>*</font>".$i['itmname'];
}
echo "<tr><td>".$i['itmname']."";
if ($i['inv_qty'] > 1)
{
echo "x".$i['inv_qty']."";
}
echo "</td><td>$".$i['itmsellprice']."</td><td>";
echo "$".($i['itmsellprice']."*".$i['inv_qty'])."";
echo "</td><td>[<a href='iteminfo.php?ID=".$i['itmid']."'>Info</a>]";
echo ' [<a href="itemsend.php?ID='.$i['inv_id'].'">Send</a>]
[<a href="itemsell.php?ID='.$i['inv_id'].'">Sell</a>]
[<a href="imadd.php?ID='.$i['inv_id'].'">Add To Market</a>]
[<a href="itemuse.php?ID='.$i['inv_id'].'">Use</a>]';
if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on'])
{
echo ' [<a href="itemuse.php?ID='.$i['inv_id'].'">Use</a>]';
}
if($i['weapon'])
{
echo ' [<a href="equip_weapon.php?ID='.$i['inv_id'].'">Equip as Weapon</a>]';
}
if($i['armor'])
{
echo ' [<a href="equip_armor.php?ID='.$i['inv_id'].'">Equip as Armor</a>]';
}
if($i['helmet'])
{
echo ' [<a href="equip_helmet.php?ID='.$i['inv_id'].'">Equip as Helmet</a>]';
}
if($i['boots'])
{
echo ' [<a href="equip_boots.php?ID='.$i['inv_id'].'">Equip as Boots</a>]';
}
if($i['breastplate'])
{
echo ' [<a href="equip_breastplate.php?ID='.$i['inv_id'].'">Equip as BreastPlate</a>]';
}
if($i['leggings'])
{
echo ' [<a href="equip_leggings.php?ID='.$i['inv_id'].'">Equip as Leggings</a>]';
}
if($i['gloves'])
{
echo ' [<a href="equip_ring.php?ID='.$i['inv_id'].'">Equip as Gloves</a>]';
}
echo '</td></tr>';
}
echo '</table>';
echo '<small><b>NB:</b>
Items with a small red </small><font color="red">*</font><small> next to their name can be used as weapons in combat.<br />
Items with a small green </small><font color="green">*</font><small> next to their name can be used as armor in combat.<br />
Items with a small blue </small><font color="blue">*</font><small> next to their name can be used as a helmet in combat.<br />
Items with a small pink </small><font color="pink">*</font><small> next to their name can be used as boots in combat.<br />
Items with a small brown </small><font color="brown">*</font><small> next to their name can be used as leggings in combat.<br />
Items with a small lime </small><font color="lime">*</font><small> next to their name can be used as a breastplate in combat.<br />
Items with a small yellow </small><font color="yellow">*</font><small> next to their name can be used as gloves in combat.<br />';
}
$h->endpage();
?>
staff_items.php
<?php
include "sglobals.php";
//This contains item stuffs
switch($_GET['action'])
{
case 'newitem': new_item_form(); break;
case 'newitemsub': new_item_submit(); break;
case 'giveitem': give_item_form(); break;
case 'giveitemsub': give_item_submit(); break;
case 'killitem': kill_item_form(); break;
case 'killitemsub': kill_item_submit(); break;
case 'edititem': edit_item_begin(); break;
case 'edititemform': edit_item_form(); break;
case 'edititemsub': edit_item_sub(); break;
case 'newitemtype': newitemtype(); break;
default: print "Error: This script requires an action."; break;
}
function new_item_form()
{
global $db,$ir,$c;
if($ir['user_level'] > 2)
{
die("403");
}
print "<h3>Adding an item to the game</h3><form action='staff_items.php?action=newitemsub' method='post'>
Item Name: <input type='text' name='itmname' value='' /><br />
Item Desc.: <input type='text' name='itmdesc' value='' /><br />
Item Type: ".itemtype_dropdown($c,'itmtype')."<br />
Item Buyable: <input type='checkbox' name='itmbuyable' checked='checked' /><br />
Item Price: <input type='text' name='itmbuyprice' /><br />
Item Sell Value: <input type='text' name='itmsellprice' /><br /><br />
<hr />
<b>Usage Form</b><hr />
<b><u>Effect 1</u></b><br />
On? <input type='radio' name='effect1on' value='1' /> Yes <input type='radio' name='effect1on' value='0' checked='checked' /> No<br />
Stat: <select name='effect1stat' type='dropdown'>
<option value='energy'>Energy</option>
<option value='will'>Will</option>
<option value='brave'>Brave</option>
<option value='hp'>Health</option>
<option value='strength'>Strength</option>
<option value='agility'>Agility</option>
<option value='guard'>Guard</option>
<option value='labour'>Labour</option>
<option value='IQ'>IQ</option>
<option value='hospital'>Hospital Time</option>
<option value='jail'>Jail Time</option>
<option value='money'>Money</option>
<option value='crystals'>Crystals</option>
<option value='cdays'>Education Days Left</option>
<option value='bankmoney'>Bank money</option>
<option value='cybermoney'>Cyber money</option>
<option value='crimexp'>Crime XP</option>
</select> Direction: <select name='effect1dir' type='dropdown'>
<option value='pos'>Increase</option>
<option value='neg'>Decrease</option>
</select><br />
Amount: <input type='text' name='effect1amount' value='0' /> <select name='effect1type' type='dropdown'>
<option value='figure'>Value</option>
<option value='percent'>Percent</option>
</select><hr />
<b><u>Effect 2</u></b><br />
On? <input type='radio' name='effect2on' value='1' /> Yes <input type='radio' name='effect2on' value='0' checked='checked' /> No<br />
Stat: <select name='effect2stat' type='dropdown'>
<option value='energy'>Energy</option>
<option value='will'>Will</option>
<option value='brave'>Brave</option>
<option value='hp'>Health</option>
<option value='strength'>Strength</option>
<option value='agility'>Agility</option>
<option value='guard'>Guard</option>
<option value='labour'>Labour</option>
<option value='IQ'>IQ</option>
<option value='hospital'>Hospital Time</option>
<option value='jail'>Jail Time</option>
<option value='money'>Money</option>
<option value='crystals'>Crystals</option>
<option value='cdays'>Education Days Left</option>
<option value='bankmoney'>Bank money</option>
<option value='cybermoney'>Cyber money</option>
<option value='crimexp'>Crime XP</option>
</select> Direction: <select name='effect2dir' type='dropdown'>
<option value='pos'>Increase</option>
<option value='neg'>Decrease</option>
</select><br />
Amount: <input type='text' name='effect2amount' value='0' /> <select name='effect2type' type='dropdown'>
<option value='figure'>Value</option>
<option value='percent'>Percent</option>
</select><hr />
<b><u>Effect 3</u></b><br />
On? <input type='radio' name='effect3on' value='1' /> Yes <input type='radio' name='effect3on' value='0' checked='checked' /> No<br />
Stat: <select name='effect3stat' type='dropdown'>
<option value='energy'>Energy</option>
<option value='will'>Will</option>
<option value='brave'>Brave</option>
<option value='hp'>Health</option>
<option value='strength'>Strength</option>
<option value='agility'>Agility</option>
<option value='guard'>Guard</option>
<option value='labour'>Labour</option>
<option value='IQ'>IQ</option>
<option value='hospital'>Hospital Time</option>
<option value='jail'>Jail Time</option>
<option value='money'>Money</option>
<option value='crystals'>Crystals</option>
<option value='cdays'>Education Days Left</option>
<option value='bankmoney'>Bank money</option>
<option value='cybermoney'>Cyber money</option>
<option value='crimexp'>Crime XP</option>
</select> Direction: <select name='effect3dir' type='dropdown'>
<option value='pos'>Increase</option>
<option value='neg'>Decrease</option>
</select><br />
Amount: <input type='text' name='effect3amount' value='0' /> <select name='effect3type' type='dropdown'>
<option value='figure'>Value</option>
<option value='percent'>Percent</option>
</select><hr />
<b>Combat Usage</b><br />
Helmet Defense: <input type='text' name='helmet' value='0' /><br />
Weapon Power: <input type='text' name='weapon' value='0' /><br />
Boots Defense: <input type='text' name='boots' value='0' /><br />
BreastPlate Defense: <input type='text' name='amulet' value='0' /><br />
Leggings Defense: <input type='text' name='braclet' value='0' /><br />
Gloves Defense: <input type='text' name='ring' value='0' /><br />
<input type='submit' value='Add Item To Game' /></form>";
}
function new_item_submit()
{
global $db,$ir,$c,$h;
if($ir['user_level'] > 2)
{
die("403");
}
if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice']))
{
print "You missed one or more of the fields. Please go back and try again.<br />
<a href='admin.php?action=newitem'>> Back</a>";
$h->endpage();
exit;
}
$itmname=$db->escape($_POST['itmname']);
$itmdesc=$db->escape($_POST['itmdesc']);
$weapon=abs((int) $_POST['weapon']);
$helmet=abs((int) $_POST['helmet']);
$boots=abs((int) $_POST['boots']);
$amulet=abs((int) $_POST['amulet']);
$braclet=abs((int) $_POST['braclet']);
$ring=abs((int) $_POST['ring']);
$special=abs((int) $_POST['special']);
if($_POST['itmbuyable'] == 'on') { $itmbuy=1; } else { $itmbuy=0; }
$efx1=$db->escape(serialize(array("stat" => $_POST['effect1stat'], "dir" => $_POST['effect1dir'], "inc_type" => $_POST['effect1type'], "inc_amount" => abs((int) $_POST['effect1amount']))));
$efx2=$db->escape(serialize(array("stat" => $_POST['effect2stat'], "dir" => $_POST['effect2dir'], "inc_type" => $_POST['effect2type'], "inc_amount" => abs((int) $_POST['effect2amount']))));
$efx3=$db->escape(serialize(array("stat" => $_POST['effect3stat'], "dir" => $_POST['effect3dir'], "inc_type" => $_POST['effect3type'], "inc_amount" => abs((int) $_POST['effect3amount']))));
$m=$db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $boots, $helmet, $amulet, $braclet, $ring)");
print "The {$_POST['itmname']} Item was added to the game.";
stafflog_add("Created item {$_POST['itmname']}");
}
function give_item_form()
{
global $db,$ir,$c;
if($ir['user_level'] > 3)
{
die("403");
}
print "<h3>Giving Item To User</h3>
<form action='staff_items.php?action=giveitemsub' method='post'>
User: ".user_dropdown($c,'user')."<br />
Item: ".item_dropdown($c,'item')."<br />
Quantity: <input type='text' name='qty' value='1' /><br />
<input type='submit' value='Give Item' /></form>";
}
function give_item_submit()
{
global $db,$ir,$c;
if($ir['user_level'] > 3)
{
die("403");
}
$db->query("INSERT INTO inventory VALUES('',{$_POST['item']},{$_POST['user']},{$_POST['qty']},0,0)",$c) or die(mysql_error());
print "You gave {$_POST['qty']} of item ID {$_POST['item']} to user ID {$_POST['user']}";
stafflog_add("Gave {$_POST['qty']} of item ID {$_POST['item']} to user ID {$_POST['user']}");
}
function kill_item_form()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
print "<h3>Deleting Item</h3>
The item will be permanently removed from the game.<br />
<form action='staff_items.php?action=killitemsub' method='post'>
Item: ".item_dropdown($c,'item')."<br />
<input type='submit' value='Kill Item' /></form>";
}
function kill_item_submit()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
$d=$db->query("SELECT * FROM items WHERE itmid={$_POST['item']}");
$itemi=$db->fetch_row($d);
$db->query("DELETE FROM items WHERE itmid={$_POST['item']}");
$db->query("DELETE FROM shopitems WHERE sitemITEMID={$_POST['item']}");
$db->query("DELETE FROM inventory WHERE inv_itemid={$_POST['item']}");
$db->query("DELETE FROM itemmarket WHERE imITEM={$_POST['item']}");
print "The {$itemi['itmname']} Item was removed from the game.";
stafflog_add("Deleted item {$itemi['itmname']}");
}
function edit_item_begin()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
print "<h3>Editing Item</h3>
You can edit any aspect of this item.<br />
<form action='staff_items.php?action=edititemform' method='post'>
Item: ".item_dropdown($c,'item')."<br />
<input type='submit' value='Edit Item' /></form>";
}
function edit_item_form()
{
global $db,$ir,$c,$h;
if($ir['user_level'] > 2)
{
die("403");
}
$d=$db->query("SELECT * FROM items WHERE itmid={$_POST['item']}");
$itemi=$db->fetch_row($d);
print "<h3>Editing Item</h3>
<form action='staff_items.php?action=edititemsub' method='post'>
<input type='hidden' name='itmid' value='{$_POST['item']}' />
Item Name: <input type='text' name='itmname' value='{$itemi['itmname']}' /><br />
Item Desc.: <input type='text' name='itmdesc' value='{$itemi['itmdesc']}' /><br />
Item Type: ".itemtype_dropdown($c,'itmtype',$itemi['itmtype'])."<br />
Item Buyable: <input type='checkbox' name='itmbuyable'";
if ($itemi['itmbuyable']) { print " checked='checked'"; }
print " /><br />Item Price: <input type='text' name='itmbuyprice' value='{$itemi['itmbuyprice']}' /><br />
Item Sell Value: <input type='text' name='itmsellprice' value='{$itemi['itmsellprice']}' /><hr /><b>Usage Form</b><hr />";
$stats=array(
"energy" => "Energy",
"will" => "Will",
"brave" => "Brave",
"hp" => "Health",
"strength" => "Strength",
"agility" => "Agility",
"guard" => "Guard",
"labour" => "Labour",
"IQ" => "IQ",
"hospital" => "Hospital Time",
"jail" => "Jail Time",
"money" => "Money",
"crystals" => "Crystals",
"cdays" => "Education Days Left",
"bankmoney" => "Bank money",
"cybermoney" => "Cyber money",
"crimexp" => "Crime XP");
for($i=1;$i<=3;$i++)
{
if($itemi["effect".$i])
{
$efx=unserialize($itemi["effect".$i]);
}
else
{
$efx=array("inc_amount" => 0);
}
$switch1=($itemi['effect'.$i.'_on'] > 0) ? " checked='checked'" : "";
$switch2=($itemi['effect'.$i.'_on'] > 0) ? "" : " checked='checked'";
print "<b><u>Effect {$i}</u></b><br />
On? <input type='radio' name='effect{$i}on' value='1'$switch1 /> Yes <input type='radio' name='effect{$i}on' value='0'$switch2 /> No<br />
Stat: <select name='effect{$i}stat' type='dropdown'>";
foreach($stats as $k => $v)
{
if($k==$efx['stat'])
{
print "<option value='{$k}' selected='selected'>{$v}</option>\n";
}
else
{
print "<option value='$k'>{$v}</option>\n";
}
}
if($efx['dir']=="neg")
{
$str="<option value='pos'>Increase</option><option value='neg' selected='selected'>Decrease</option>";
}
else
{
$str="<option value='pos' selected='selected'>Increase</option><option value='neg'>Decrease</option>";
}
if($efx['inc_type']=="percent")
{
$str2="<option value='figure'>Value</option><option value='percent' selected='selected'>Percent</option>";
}
else
{
$str2="<option value='figure' selected='selected'>Value</option><option value='percent'>Percent</option>";
}
print "</select> Direction: <select name='effect{$i}dir' type='dropdown'>{$str}
</select><br />
Amount: <input type='text' name='effect{$i}amount' value='{$efx['inc_amount']}' /> <select name='effect{$i}type' type='dropdown'>{$str2}</select><hr />";
}
print "<b>Combat Usage</b><br />
Weapon Power: <input type='text' name='weapon' value='{$itemi['weapon']}' /><br />
Helmet Defense: <input type='text' name='helmet' value='{$itemi['helmet']}' /><br />
Boots Defense: <input type='text' name='boots' value='{$itemi['boots']}' /><br />
BreastePlate Defense: <input type='text' name='amulet' value='{$itemi['breastplate']}' /><br />
Leggings Defense: <input type='text' name='braclet' value='{$itemi['leggings']}' /><br />
Gloves Defense: <input type='text' name='ring' value='{$itemi['gloves']}' /><br />
<input type='submit' value='Edit Item' /></form>";
}
function edit_item_sub()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice']))
{
print "You missed one or more of the fields. Please go back and try again.<br />
<a href='staff_items.php?action=edititem'>> Back</a>";
$h->endpage();
exit;
}
$itmname=$_POST['itmname'];
$itmdesc=$_POST['itmdesc'];
$weapon=abs((int) $_POST['weapon']);
$armor=abs((int) $_POST['armor']);
$helmet=abs((int) $_POST['helmet']);
$boots=abs((int) $_POST['boots']);
$amulet=abs((int) $_POST['amulet']);
$braclet=abs((int) $_POST['braclet']);
$ring=abs((int) $_POST['ring']);
$special=abs((int) $_POST['special']);
if($_POST['itmbuyable'] == 'on') { $itmbuy=1; } else { $itmbuy=0; }
$db->query("DELETE FROM items WHERE itmid={$_POST['itmid']}",$c);
$efx1=$db->escape(serialize(array("stat" => $_POST['effect1stat'], "dir" => $_POST['effect1dir'], "inc_type" => $_POST['effect1type'], "inc_amount" => abs((int) $_POST['effect1amount']))));
$efx2=$db->escape(serialize(array("stat" => $_POST['effect2stat'], "dir" => $_POST['effect2dir'], "inc_type" => $_POST['effect2type'], "inc_amount" => abs((int) $_POST['effect2amount']))));
$efx3=$db->escape(serialize(array("stat" => $_POST['effect3stat'], "dir" => $_POST['effect3dir'], "inc_type" => $_POST['effect3type'], "inc_amount" => abs((int) $_POST['effect3amount']))));
$m=$db->query("INSERT INTO items VALUES('{$_POST['itmid']}',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $boots, $helmet, $amulet, $braclet, $ring)");
print "The {$_POST['itmname']} Item was edited successfully.";
stafflog_add("Edited item {$_POST['itmname']}");
}
function newitemtype()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 2)
{
die("403");
}
if($_POST['name'])
{
$db->query("INSERT INTO itemtypes VALUES(NULL, '{$_POST['name']}')");
print "Item Type {$_POST['name']} added.";
stafflog_add("Added item type {$_POST['name']}");
}
else
{
print "<h3>Add Item Type</h3><hr />
<form action='staff_items.php?action=newitemtype' method='post'>
Name: <input type='text' name='name' /><br />
<input type='submit' value='Add Item Type' /></form>";
}
}
$h->endpage();
?>