Ok so I had a bit of time to spare and saw this
[mccode lite] Mod Idea
In the requests section.
Granted the request was for McLite and was done by Zeddicus but I wanted to make one for V2. So here it is (: Enjoy!
Any problems let me know.
sendbomb.php
<?php
/*
This mod created Free for the Members of Mwg
All rights have been reserved
Property of Tyr
Please Keep this tag
*/
require_once("globals.php");
$_GET['ID'] = isset($_GET['ID']) && is_numeric($_GET['ID']) ? abs((int) $_GET['ID']) : false;
$_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : false;
switch($_GET['action']) {
case "index":index();break;
case 'diffuse': diffuse(); break;
case 'bomb': bomb(); break;
case 'bomby': bomby(); break;
default:index();break;
}
function index () {
global $ir,$h;
echo "<table width='70%' class='table'><tr><th>Wire 1</th><th>Wire 2</th><th>Wire 3</th><th>Wire 4</th></tr>
<tr><td>[url='sendbomb.php?action=diffuse&ID=1']<font color=blue>Blue Wire</font>[/url]</td>
<td>[url='sendbomb.php?action=diffuse&ID=2']<font color=green>Green Wire</font>[/url]</td>
<td><a href='sendbomb.php?action=diffuse&ID=3'><font color=red>Red Wire</font></td>
<td><a href='sendbomb.php?action=diffuse&ID=4'><font color=black>Black Wire</font></td>
</tr><table>";
}
function bomb() {
global $ir,$h,$db;
if(isset($_POST['bomb']))
{
echo "You successfully Planted the bomb on ".$bomb['username']."
[url='index.php'][b]Home[/b][/url]";
item_add($_GET['ID'], 3, 1);
$kapow = sprintf("UPDATE `users` SET `bombattempts`=`bombattempts`-1 WHERE `userid`=%u", $ir['userid']);
$db->query($kapow);
}
else {
if(!$_GET['ID'])
{
echo "Invalid user ID selected.
[url='index.php']Back[/url]";
$h->endpage();
exit;
}
$query1 = sprintf("SELECT
m.`userid`,m.`user_level`,m.`username`,m.`gang`,m.`hospital`,m.`jail`,g.`gangID`
FROM `users` m
LEFT JOIN `gangs` g
ON m.`gang`=g.`gangID`
WHERE (`userid`=%u)", $_GET['ID']);
$query2 = $db->query($query1);
if(!$db->num_rows($query2))
{
echo "The ID you have chosen does not exist";
$h->endpage();
exit;
}
$bomb = $db->fetch_row($query2);
if($bomb['hospital'] > 0 || $bomb['jail'] > 0)
{
echo "You can not select to bomb a user who is in the hospital.
[url='index.php'][b]Home[/b][/url]";
$h->endpage();
exit;
}
if($bomb['userid'] == $ir['userid'])
{
echo "Now why in the world would you attempt to blow up yourself? Working for Al-Quaida are we?";
$h->endpage();
exit;
}
elseif($bomb['user_level'] > 1)
{
echo "You are not permitted to bomb staff members!";
$h->endpage();
exit;
}
elseif($bomb['gang'] == $ir['gang'])
{
echo "You cannot bomb a member of your own clan!";
$h->endpage();
exit;
}
elseif($ir['bombattempts'] == 0)
{
echo "You do not have the capabilities to bomb another user."; //The amount of bombs a user can send.
$h->endpage();
exit;
}
else
{
echo "<center>[b]<h2>Bomb User</h2>[/b]</center>
<center>
<form act='sendbomb.php?act=bomb' method='post'>
<input type='hidden' name='bomb' value='bomb' />
You Are about to Bomb ".stripslashes($bomb['username']).", Are You Sure You Want To Continue??
<input type='submit' value='Yes!' />";
}
}
}
function diffuse() {
global $db,$ir,$h;
$boom = sprintf("SELECT inv.`inv_itemid`,inv.`inv_userid`,i.`itmid`,m.`userid` FROM `inventory` inv LEFT JOIN `items` i ON inv.`inv_itemid`=i.`itmid` LEFT JOIN `users` m ON m.`userid`=inv.`inv_userid` WHERE (m.`userid`=%u)", $ir['userid']);
$bomb = $db->query($boom);
if(!$db->num_rows($bomb))
{
echo "You do not have a bomb attached to you currently. Why try and blow yourself up?
[url='index.php'][b]Home[/b][/url]";
$h->endpage();
exit;
}
if (!in_array($_GET['ID'], array(1, 2, 3, 4)))
{
echo "You did not select a Valid Wire! Go back and try again!
[url='sendbomb.php'][b]Back[/b][/url]";
$h->endpage();
exit;
}
$rand = rand(1,4);
if($_GET['ID'] === 1 AND $rand != 1)
{
echo "While attempting to diffuse the bomb, you decide to snip the <font color=blue>blue</font> wire. Fatal mistake, it sends you howling to the hospital lucky to escape with your life!
<a href='hospital.php'>[b]Hospital[/b]";
$bombquery = sprintf("UPDATE `users` SET `hospital`=20,`hospreason`='Failed Diffusion',`new_events`=`new_events`+1,`timer`=0 WHERE `userid`=%u", $ir['userid']);
$insert = sprintf("INSERT INTO `events` VALUES('',%u,unix_timestamp(),0,'While attempting to diffuse the bomb it detonates you are very lucky to be alive!')", $ir['userid']);
$delete = sprintf("DELETE FROM `inventory` WHERE `inv_itemid`=3 AND `inv_userid`=%u", $ir['userid']);
$db->query($bombquery);
$db->query($insert);
$db->query($delete);
$h->endpage();
exit;
}
elseif($_GET['ID'] === 2 AND $rand != 2)
{
echo "While attempting to diffuse the bomb, you decide to snip the <font color=green>green</font> wire. Fatal mistake, it sends you howling to the hospital lucky to escape with your life!
<a href='hospital.php'>[b]Hospital[/b]";
$bombquery = sprintf("UPDATE `users` SET `hospital`=20,`hospreason`='Failed Diffusion',`new_events`=`new_events`+1,`timer`=0 WHERE `userid`=%u", $ir['userid']);
$insert = sprintf("INSERT INTO `events` VALUES('',%u,unix_timestamp(),0,'While attempting to diffuse the bomb it detonates you are very lucky to be alive!')", $ir['userid']);
$delete = sprintf("DELETE FROM `inventory` WHERE `inv_itemid`=3 AND `inv_userid`=%u", $ir['userid']);
$db->query($bombquery);
$db->query($insert);
$db->query($delete);
$h->endpage();
exit;
}
elseif($_GET['ID'] === 3 AND $rand !=3)
{
echo "While attempting to diffuse the bomb, you decide to snip the <font color=red>red</font> wire. Fatal mistake, it sends you howling to the hospital lucky to escape with your life!
<a href='hospital.php'>[b]Hospital[/b]";
$bombquery = sprintf("UPDATE `users` SET `hospital`=20,`hospreason`='Failed Diffusion',`new_events`=`new_events`+1,`timer`=0 WHERE `userid`=%u", $ir['userid']);
$insert = sprintf("INSERT INTO `events` VALUES('',%u,unix_timestamp(),0,'While attempting to diffuse the bomb it detonates you are very lucky to be alive!')", $ir['userid']);
$delete = sprintf("DELETE FROM `inventory` WHERE `inv_itemid`=3 AND `inv_userid`=%u", $ir['userid']);
$db->query($bombquery);
$db->query($insert);
$db->query($delete);
$h->endpage();
exit;
}
elseif($_GET['ID'] === 4 AND $rand !=4)
{
echo "While attempting to diffuse the bomb, you decide to snip the <font color=black>black</font> wire. Fatal mistake, it sends you howling to the hospital lucky to escape with your life!
<a href='hospital.php'>[b]Hospital[/b]";
$bombquery = sprintf("UPDATE `users` SET `hospital`=20,`hospreason`='Failed Diffusion',`new_events`=`new_events`+1,`timer`=0 WHERE `userid`=%u", $ir['userid']);
$insert = sprintf("INSERT INTO `events` VALUES('',%u,unix_timestamp(),0,'While attempting to diffuse the bomb it detonates you are very lucky to be alive!')", $ir['userid']);
$delete = sprintf("DELETE FROM `inventory` WHERE `inv_itemid`=3 AND `inv_userid`=%u", $ir['userid']);
$db->query($bombquery);
$db->query($insert);
$db->query($delete);
$h->endpage();
exit;
}
else
{
$statgain = mt_rand(1,100);
$whichstat = mt_rand(1,5);
if($whichstat==1)
{
$stat = strength;
}
elseif($whichstat==2)
{
$stat = agility;
}
elseif($whichstat==3)
{
$stat = guard;
}
elseif($whichstat==4)
{
$stat = labour;
}
else
{
$stat = IQ;
}
echo "Successful Diffusion! You gained ".$statgain." in your ".$stat.".
[url='index.php'][b]Home[/b][/url]";
$update = sprintf("UPDATE `users` SET `timer`=0 WHERE `userid`=%u", $exp, $ir['userid']);
$delete = sprintf("DELETE FROM `inventory` WHERE `inv_itemid`=3 AND `inv_userid`=%u", $ir['userid']);
$statage = sprintf("UPDATE `userstats` SET %s=%u WHERE `userid`=%d", $stat, $statgain, $ir['userid']);
$db->query($update);
$db->query($delete);
$db->query($statage);
$h->endpage();
exit;
}
}
?>
SQLS
ALTER TABLE `users` ADD `timer` NOT NULL Default 0;
ALTER TABLE `users` ADD `bombattempts` NOT NULL Default 0;
Viewuser Link
[url='sendbomb.php?action=bomb&ID=".$r[']Bomb User[/url]
Now open up
imadd.php and find
$r=$db->fetch_row($q);
Right beneath this add the following
if($r['inv_itemid'] == 3)
{
echo "You cannot put a bomb on the market!";
$h->endpage();
exit;
}
Close/Save
Now open up itemsend.php and find
$r=$db->fetch_row($q);
below this add
if($r['inv_itemid'] == 3)
{
echo "You cannot give a ticking time bomb away!";
$h->endpage();
exit;
}
close and save
Now open up itemsell.php find
$r=$db->fetch_row($q);
beneath add
if($r['inv_itemid'] == 3)
{
echo "You cannot sell a ticking time bomb!!";
$h->endpage();
exit;
}
Close and Save
If you have any other files where users can send items in their inventory away just add the same type restrictions to those files as well.
The Bombs are determined off the 2nd column added in users table "bombattempts"
There are multiple differant ways users can obtain this, the choice is all up to you.
It can be a donator only option
Perhaps a Random Streets Find
Daily Reward, etc etc.
I'd suggest limiting the amount of bombs people gain, keeping it small :-)
Any problems post here and I'll fix.
**EDIT** Guess it would help to let everyone know what this mod does a *.*
Basically a user can opt to plant a bomb on another user. If the other user has a bomb planted on them, they can go to a bomb diffusion center and attempt to cut 1 of 4 wires. The wires are always random so there is no cheating. If the user fails they are hospitalized for 20 minutes. If they succeed they get a random 1 through 100 stat gain in a Random userstat.
If they do not try and diffuse it, in 10 minutes the timer goes off and they are hospitilized. cron next