This is the dump mod I made but as it doesn't seem to be selling as planned, I'm giving it out for free... Well now that I think about it is quite a small mod. :pinch:
Those who bought this mod will not receive a refund but will get 10% of my next mod £10 or under.
Here it is. :D
(Forget about the crap at the bottom. :P)
This mod allows your users to dump there old crap items for other users to find, It takes 5 energy off the searcher.
Run this query in your data base. :thumbup:
[mysql]
CREATE TABLE IF NOT EXISTS `dump` (
`dumpID` int(11) NOT NULL AUTO_INCREMENT,
`itmID` int(11) NOT NULL,
`dumperID` int(11) NOT NULL,
PRIMARY KEY (`dumpID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
[/mysql]
Make a new file called dump.php
<?php
include_once("globals.php");
echo '<h3>Dump</h3><hr width="75%" />';
switch($_GET['step']) {
case "dump": dump(); break;
case "dump2": dump2(); break;
case "search": search(); break;
default: index();
}
function index() {
global $db, $ir, $c, $h, $userid;
$_SESSION['rfc'] = (int) rand(100,999);
echo '
Welcome to the dump, people all over the city come here to dump there crap.
> [url="dump.php?step=search&rfc='.$_SESSION['rfc'].'"]Search the dump![/url]
';
}
function dump2() {
global $db, $ir, $c, $h, $userid;
if($_POST) {
$Itemid = abs((int) $_GET['id']);
$Query = mysql_query("SELECT * FROM `inventory` WHERE `inv_userid` = ".$userid."");
$Data = mysql_fetch_array($Query);
item_remove($userid, $Itemid, $_POST['amount']);
for($i=1; $i <= $_POST['amount']; $i++) {
mysql_query("INSERT INTO `dump` (dumpID, itmID, dumperID) VALUES (NULL, ".$Itemid.", ".$userid.")");
}
echo '
You have dumped '.$_POST['amount'].' '.getitmname($Itemid).'(s)!
';
}
}
function dump() {
global $db, $ir, $c, $h, $userid;
$Query = mysql_query("SELECT * FROM `inventory` WHERE `inv_userid` = ".$userid."");
echo '
Please pick which items you would like to trash.
<table width=75%>
<th width="70%">Name</th><th width="15%">Amount</th><th width="15%">Trash</th>';
while($Data = mysql_fetch_array($Query)) {
$bgcolor = ($bgcolor == "#dfdfdf") ? "#fff" : "#dfdfdf";
echo '<form method="POST" action=dump.php?step=dump2&id='.$Data['inv_itemid'].'><tr bgcolor="'.$bgcolor.'"><td>[b]'.getitmname($Data['inv_itemid']).'[/b] x'.$Data['inv_qty'].'</td><td align="center"><input type=text name="amount" size="4" maxlength="4" value="'.$Data['inv_qty'].'"></td><td align="center"><input type="submit" value="Dump"></td></tr></form>';
}
echo '<table>
';
}
function search() {
global $db, $ir, $c, $h, $userid;
$_GET['rfc'] = abs((int) $_GET['rfc']);
if(($_SESSION['rfc'] !== $_GET['rfc']) || $_GET['rfc'] < 100) {
echo '
You cannot refresh this page.
';
} else {
$_SESSION['rfc'] = (int) rand(100,999);
$Num = mysql_query("SELECT * FROM `dump`");
if($ir['energy'] < 5) {
echo '
You do not have enough energy to search the dump any longer.
';
} elseif(mysql_num_rows($Num) < 1 ) {
echo '
You searched the dump for hours but couldn\'t find anything.
> [url="dump.php?step=search&rfc='.$_SESSION['rfc'].'"]Search again![/url]
';
mysql_query("UPDATE `users` SET `energy` = `energy` -5 WHERE `userid` = ".$userid."");
} else {
$Query = mysql_query("SELECT * FROM `dump` ORDER BY RAND() LIMIT 0,1;") or die(mysql_error());
while($Data = mysql_fetch_array($Query)) {
$getname = mysql_query("SELECT `username` FROM `users` WHERE `userid` = ".$Data['dumperID']."", $c);
if(mysql_num_rows($getname)) {
$A = mysql_fetch_array($getname);
$Name = '[url="viewuser.php?u='.$Data['dumperID'].'"]'.$A['username'].'[/url]';
} else {
$Name = "Unknown";
}
echo '
You searched the dump and find a '.getitmname($Data['itmID']).' that was dumped by '.$Name.'!';
item_add($userid, $Data['itmID'], 1);
mysql_query("UPDATE `users` SET `energy` = `energy` -5 WHERE `userid` = ".$userid."");
mysql_query("DELETE FROM `dump` WHERE `dumpID`= ".$Data['dumpID']."");
}
echo'
> [url="dump.php?step=search&rfc='.$_SESSION['rfc'].'"]Search again![/url]
';
}
}
}
echo '<hr width="75%" />
<table width="75%">
<tr><td width="50%" align="center">
> [url="explore.php"]Back[/url]
</td><td width="50%" align="center">
> [url="dump.php?step=dump"]Dump Items[/url]
</td></tr></table><hr width="75%" />';
$h->endpage();
function getitmname($itmid) {
$getitem = mysql_query("SELECT `itmname` FROM `items` WHERE `itmid` = ".$itmid."");
if(mysql_num_rows($getitem)) {
$itemData = mysql_fetch_array($getitem);
$item = $itemData['itmname'];
return $item;
}
}
?>
You're welcome. :love:
Criticism welcome. 8o