-
Posts
2,142 -
Joined
-
Last visited
-
Days Won
148
Content Type
Profiles
Forums
Events
Everything posted by Magictallguy
-
cardealer.php <?php include(__DIR__ . '/globals.php'); echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; switch($_GET['action']) { case 'buy': buyCar(); break; default: carIndex(); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function carIndex() { global $db, $ir; echo "<h3>Cars: Car Dealership</h3>"; $selectGarage = $db->query(sprintf("SELECT `pgID` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { echo "<a href='garage.php'>Buy your own driveway</a>"; } ?><table class='table' width='100%' cellspacing='1'> <tr> <th width='25%'>Car/Description</th> <th width='20%'>Cost</th> <th width='50%'>Stats</th> <th width='5%'>Links</th> </tr><? $select = $db->query("SELECT * FROM `cars` ORDER BY `cCost` ASC, `cName` ASC"); if(!$db->num_rows($select)) { echo "<tr><td colspan='3' class='center'>There are no available cars</td></tr>"; } else { while($row = $db->fetch_row($select)) { ?><tr> <td><strong><? echo format($row['cName']); ?></strong><? echo nl2br(format($row['cDesc'])); ?></td> <td>$<? echo format($row['cCost']); ?></td> <td><table class='table' width='100%' cellspacing='1'> <tr> <th width='10%'>Speed</th> <td width='40%'><? echo format($row['cSpeed']); ?></td> <th width='10%'>Handling</th> <td width='40%'><? echo format($row['cHandling']); ?></td> </tr> <tr> <th width='10%'>Acceleration</th> <td width='40%'><? echo format($row['cAccel']); ?></td> <th width='10%'>Braking</th> <td width='40%'><? echo format($row['cBrake']); ?></td> </tr> </table></td> <td><? echo ($ir['money'] >= $row['cCost']) ? "<a href='cardealer.php?action=buy&ID=".$row['cID']."'>Buy</a>" : "<span style='color:#444;'><em>Buy</em></span>"; ?></td> </tr><? } } echo "</table>"; } function buyCar() { global $db, $ir; echo "<h3>Cars: Car Dealership: Buying a car</h3>"; if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $_GET['ID'])); if(!$db->num_rows($selectCar)) { error("That car doesn't exist"); } $row = $db->fetch_row($selectCar); $selectGarage = $db->query(sprintf("SELECT `pgCapacity`, `pgType` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { error("You don't have anywhere to park your car. You must buy a driveway before you can buy a car"); } $garage = $db->fetch_row($selectGarage); $selectPlayerCars = $db->query(sprintf("SELECT COUNT(`pcID`) FROM `playerCars` WHERE (`pcUser` = %u)", $ir['userid'])); $getGarageName = $db->query(sprintf("SELECT `gTypeName` FROM `garageTypes` WHERE (`gTypeID` = %u)", $garage['pgType'])); $garageName = $db->fetch_single($getGarageName); if($db->fetch_single($selectPlayerCars) >= $garage['pgCapacity']) { error("Your ".format($garageName)." is full. You must upgrade it before you can fit any more cars"); } if($ir['money'] < $row['cCost']) { error("You don't have enough money to buy the ".format($row['cName'])); } $db->query(sprintf("INSERT INTO `playerCars` VALUES ('', %u, %u, %u, %u, %u, %u)", $ir['userid'], $_GET['ID'], $row['cSpeed'], $row['cHandling'], $row['cAccel'], $row['cBrake'])); success("You've bought the ".format($row['cName'])); } $h->endpage(); ?> I'm slowing down due to family getting in the way lol
-
Next lot of SQL's - don't worry people, I'll release this all on one topic ;) CREATE TABLE `playerCars` ( `pcID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `pcUser` INT( 11 ) NOT NULL DEFAULT 0, `pcCarID` INT( 11 ) NOT NULL DEFAULT 0, `pcSpeed` INT( 11 ) NOT NULL DEFAULT 0, `pcHandling` INT( 11 ) NOT NULL DEFAULT 0, `pcAccel` INT( 11 ) NOT NULL DEFAULT 0, `pcBrake` INT( 11 ) NOT NULL DEFAULT 0 ); CREATE TABLE `playerGarages` ( `pgID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `pgUser` INT( 11 ) NOT NULL DEFAULT 0, `pgType`INT( 11 ) NOT NULL DEFAULT 1, `pgCapacity` INT( 11 ) NOT NULL DEFAULT 1 ); CREATE TABLE `garages` ( `gTypeID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `gTypeName` VARCHAR( 255 ) NOT NULL DEFAULT 0, `gTypeCost` INT( 11 ) NOT NULL DEFAULT 3000 ); INSERT INTO `garages` VALUES ('', 'Driveway', 3000);
-
I'd also make it so they'd have to buy it, but the client gets what the client wants ;)
-
Oh, Razor! Do you want players to automatically have a garage, or do you want them to buy it? I can do that.. Could be fun ^.^
-
Thank you kindly :) staff_cars.php - Code has been fully tested <?php include(__DIR__ . '/globals.php'); if($ir['user_level'] != 2) { error("You can't access this"); } echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'add': addCar(); break; case 'edit': editCar(); break; case 'del': deleteCar(); break; default: error("I don't know what to do.."); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function addCar() { global $db; echo "<h3>Cars: Create Car</h3>"; if(isset($_POST['submit'])) { $texts = array( 'carName' => 'name', 'carDesc' => 'description' ); $nums = array( 'carSpeed' => 'speed', 'carHandling' => 'handling', 'carAccel' => 'acceleration', 'carBrake' => 'braking', 'carCost' => 'cost' ); foreach($_POST[$texts] as $what => $value) { $_POST[$texts] = isset($_POST[$texts]) && is_string($_POST[$texts]) ? trim($_POST[$texts]) : null; if(empty($_POST[$texts])) { error("You didn't enter a valid ".$value); } } foreach($_POST[$nums] as $what => $value) { $_POST[$nums] = isset($_POST[$nums]) && ctype_digit($_POST[$texts]) ? abs(@intval($_POST[$texts])) : null; if(empty($_POST[$nums])) { error("You didn't enter a valid ".$nums." value"); } } $select = $db->query(sprintf("SELECT `cID` FROM `cars` WHERE (`cName` = '%s')", $db->escape($_POST['carName']))); if($db->num_rows($select)) { error("A car with that name already exists"); } $db->query(sprintf("INSERT INTO `cars` VALUES ('', '%s', '%s', %u, %u, %u, %u, %u)", $db->escape($_POST['carName']), $db->escape($_POST['carDesc']), $_POST['carSpeed'], $_POST['carHandling'], $_POST['carAccel'], $_POST['carBrake'], $_POST['carCost'])); stafflog_add("Created a new car: ".$_POST['carName']); success("The “".format($_POST['carName'])."” has been created"); } ?><form action='staff_cars.php?action=add' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Name</th> <td width='55%'><input type='text' name='carName' /></td> </tr> <tr> <th>Description</th> <td><textarea name='carDesc' rows='10' cols='70'></textarea></td> </tr> <tr> <th>Speed</th> <td><input type='number' name='carSpeed' /></td> </tr> <tr> <th>Handling</th> <td><input type='number' name='carHandling' /></td> </tr> <tr> <th>Acceleration</th> <td><input type='number' name='carAccel' /></td> </tr> <tr> <th>Braking</th> <td><input type='number' name='carBrake' /></td> </tr> <tr> <th>Cost</th> <td><input type='number' name='carCost' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Create' /></td> </tr> </table> </form><? } function editCar() { global $db; echo "<h3>Cars: Edit Car</h3>"; $_GET['step'] = isset($_GET['step']) && ctype_digit($_GET['step']) ? abs(@intval($_GET['step'])) : null; switch($_GET['step']) { default: $selectCars = $db->query("SELECT `cID`, `cName` FROM `cars` ORDER BY `cName` ASC"); if(!$db->num_rows($selectCars)) { error("There are no cars to edit"); } ?><form action='staff_cars.php?action=edit&step=1' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Car</th> <td width='55%'><select name='car' type='dropdown'><? while($row = $db->fetch_row($selectCars)) { printf("<option value='%u'>%s</option>", $row['cID'], format($row['cName'])); } ?></select></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Edit the selected car' /></td> </tr> </table> </form><? break; case 1: $_POST['car'] = isset($_POST['car']) && ctype_digit($_POST['car']) ? abs(@intval($_POST['car'])) : null; if(empty($_POST['car'])) { error("You didn't select a valid car"); } $select = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); if(!$db->num_rows($select)) { error("That car doesn't exist"); } $car = $db->fetch_row($select); ?><form action='staff_cars.php?action=edit&step=2' method='post'> <input type='hidden' name='carID' value='<? echo $_POST['car']; ?>' /> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Name</th> <td width='55%'><input type='text' name='carName' value='<? echo format($car['cName']); ?>' /></td> </tr> <tr> <th>Description</th> <td><textarea name='carDesc' rows='10' cols='70'><? echo format($car['cDesc']); ?></textarea></td> </tr> <tr> <th>Speed</th> <td><input type='number' name='carSpeed' value='<? echo $car['cSpeed']; ?>' /></td> </tr> <tr> <th>Handling</th> <td><input type='number' name='carHandling' value='<? echo $car['cHandling']; ?>' /></td> </tr> <tr> <th>Acceleration</th> <td><input type='number' name='carAccel' value='<? echo $car['cAccel']; ?>' /></td> </tr> <tr> <th>Braking</th> <td><input type='number' name='carBrake' value='<? echo $car['cBrake']; ?>' /></td> </tr> <tr> <th>Cost</th> <td><input type='number' name='carCost' value='<? echo $car['cCost']; ?>' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Edit' /></td> </tr> </table> </form><? break; case 2: $texts = array( 'carName' => 'name', 'carDesc' => 'description' ); $nums = array( 'carSpeed' => 'speed', 'carHandling' => 'handling', 'carAccel' => 'acceleration', 'carBrake' => 'braking', 'carCost' => 'cost', 'carID' => 'car' ); foreach($_POST[$texts] as $what => $value) { $_POST[$texts] = isset($_POST[$texts]) && is_string($_POST[$texts]) ? trim($_POST[$texts]) : null; if(empty($_POST[$texts])) { error("You didn't enter a valid ".$value); } } foreach($_POST[$nums] as $what => $value) { $_POST[$nums] = isset($_POST[$nums]) && ctype_digit($_POST[$texts]) ? abs(@intval($_POST[$texts])) : null; if(empty($_POST[$nums])) { error("You didn't enter a valid ".$nums." value"); } } $selectCar = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE (`cID` = %u)", $_POST['carID'])); if(!$db->num_rows($selectCar)) { error("That car doesn't exist"); } $selectCarName = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE ((`cName` = '%s') AND (`cID` != %u))", $db->escape($_POST['carName']), $_POST['carID'])); if($db->num_rows($selectCarName)) { error("Another car with that name already exists"); } $oldName = $db->fetch_single($selectCar); $db->query(sprintf("UPDATE `cars` SET `cName` = '%s', `cDesc` = '%s', `cSpeed` = %u, `cHandling` = %u, `cAccel` = %u, `cBrake` = %u, `cCost` = %u WHERE (`cID` = %u)", $db->escape($_POST['carName']), $db->escape($_POST['carDesc']), $_POST['carSpeed'], $_POST['carHandling'], $_POST['carAccel'], $_POST['carBrake'], $_POST['carCost'], $_POST['carID'])); $log = ($_POST['carName'] == stripslashes($oldName)) ? $_POST['carName'] : $oldName." > ".format($_POST['carName']); stafflog_add("Edited the car: ".$log); success("The “".stripslashes($log)."” has been edited"); break; } } function deleteCar() { global $db; echo "<h3>Cars: Delete Car</h3>"; if(isset($_POST['submit'])) { $_POST['car'] = isset($_POST['car']) && ctype_digit($_POST['car']) ? abs(@intval($_POST['car'])) : null; if(empty($_POST['car'])) { error("You didn't select a valid car"); } $select = $db->query(sprintf("SELECT `cName` FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); if(!$db->num_rows($select)) { error("That car doesn't exist"); } $name = $db->fetch_single($select); $db->query(sprintf("DELETE FROM `cars` WHERE (`cID` = %u)", $_POST['car'])); stafflog_add("Deleted the car: ".$name); success("You've deleted the car: ".format($name)); } $selectCars = $db->query("SELECT `cID`, `cName` FROM `cars` ORDER BY `cName` ASC"); if(!$db->num_rows($selectCars)) { error("There are no cars to delete"); } ?><form action='staff_cars.php?action=del' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Car</th> <td width='55%'><select name='car' type='dropdown'><? while($row = $db->fetch_row($selectCars)) { printf("<option value='%u'>%s</option>", $row['cID'], format($row['cName'])); } ?></select></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Delete the selected car' /></td> </tr> </table> </form><? } $h->endpage(); ?> Edit your staff menu (smenu.php) Add this where you want it <hr /><strong>Cars</strong><br /> > <a href='staff_cars.php?action=add'>Add Car</a><br /> > <a href='staff_cars.php?action=edit'>Edit Car</a><br /> > <a href='staff_cars.php?action=del'>Delete Car</a><br />
-
SQLs CREATE TABLE `cars` ( `cID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `cName` VARCHAR( 255 ) NOT NULL DEFAULT '', `cDesc` TEXT NOT NULL, `cSpeed` INT( 11 ) NOT NULL DEFAULT 0, `cHandling` INT( 11 ) NOT NULL DEFAULT 0, `cAccel` INT( 11 ) NOT NULL DEFAULT 0, `cBrake` INT( 11 ) NOT NULL DEFAULT 0, `cCost` INT( 11 ) NOT NULL DEFAULT 0 ); Get those in, I'm just finishing up the staff side so you can start creating the cars for your players ;)
-
Good stuff, writing up the staff side now :)
-
Not what I asked lol. You wanted cars, do you also want car brands?
-
Right, before I continue, do you want car brands (Mercedes, BMW, etc. (obviously, for legal reasons, you'd have to invent your own or get permission from each company to use their name)
-
Any specific time limit on how many times a player can race said car(s)? Is there a limit on the amount of races by x amount of time? Limit on how many cars a player can have/win/lose? Again, limits? Do you want the players to be able to nickname their cars? Similar to the Item Market, I assume? How much money per upgrade? Does the upgrade count for all car "stats" or just one specifically per upgrade purchase? Would the car have a "car level"? If so, would this level limit the amount a car can be upgraded? Upgrading a garage gives you how many more parking spots? Do you want the garage to be upgraded into something different per "garage level"? (i.e. Garage -> Sheltered Garage -> Showroom -> Complex, etc..)
-
Loan System for Bank (ideas bounced around too)
Magictallguy replied to Script47's topic in Requests & In Production
Want to stop cheating? As "Nyna" once said.. The best way is this: <tt>Site Offline</tt> -
Loan System for Bank (ideas bounced around too)
Magictallguy replied to Script47's topic in Requests & In Production
Is that 100,000 per player, or 100,000 in total? As that is what Dave was saying -
Continuing on from my original post.. * You will need my time2readable() function found in one of my gang mods SQLs ALTER TABLE `guildAlliances` ADD `gaTime` INT( 11 ) NOT NULL DEFAULT 0; Edit yourgang.php In the gang_staff_alliance_decide() function Find $db->query(sprintf("INSERT INTO `gangAlliances` VALUES ('', %u, %u)", $gangdata['gangID'], $req['gangID'])); Replace with $db->query(sprintf("INSERT INTO `gangAlliances` VALUES ('', %u, %u, %s)", $gangdata['gangID'], $req['gangID'], time())); In the gang_staff_alliance_view() Find <th width='80%'>Gang</th> <th width='20%'>Action</th> Replace with <th width='60%'>Gang</th> <th width='20%'>Time Left</th> <th width='20%'>Action</th> Find echo "<tr><td colspan='2' class='center'>You don't have any Allies</td></tr>"; Replace with echo "<tr><td colspan='3' class='center'>You don't have any Allies</td></tr>"; Find printf("<td class='center'><a href='yourgang.php?action=staff&act2=allianceb&ID=%u'><img src='/silk/link_break.png' title='Break this alliance' alt='Break' /></a></td>", $yellow['gaID']); Add above printf("<td class='center'>%s</td>", time2readable(($yellow['gaTime'] + 2592000) - time())); Edit your five minute cron [Default setup - cron_fivemins.php] At the bottom of the file Add $selectAlliances = $db->query("SELECT * FROM `guildAlliances` WHERE ((`gaTime` + 2592000) > unix_timestamp())"); while($row = $db->fetch_row($select)) { $getName1 = $db->fetch_single($db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $row['gaGuild1']))); $getName2 = $db->fetch_single($db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $row['gaGuild2']))); $db->query(sprintf("DELETE FROM `guildAlliances` WHERE (`gaID` = %u)", $row['gaID'])); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, 'The alliance between <a href=\'gangs.php?action=view&ID=%u\'>%s</a> and <a href=\'gangs.php?action=view&ID=%u\'>%s</a> has come to an end')", $row['gaGuild1'], time(), $row['gaGuild1'], $getName1, $row['gaGuild2'], $getName2)); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, 'The alliance between <a href=\'gangs.php?action=view&ID=%u\'>%s</a> and <a href=\'gangs.php?action=view&ID=%u\'>%s</a> has come to an end')", $row['gaGuild2'], time(), $row['gaGuild1'], $getName1, $row['gaGuild2'], $getName2)); }
-
This mod was requested by Bennyh789 on this topic. PHP5.6 complaint Staff Gang Delete Add the following code into staff_gangs.php case 'gdelete': admin_gang_delete($db, $ir); break /** * @param database $db * @param array $ir * @return void */ function admin_gang_delete($db, $ir) { if (2 != $ir['user_level']) { clean_kill('You can\'t do that'); } ?> <h3>Gang Management: Deletion</h3> <?php $select = $db->query('SELECT gangID, gangNAME FROM gangs ORDER BY gangNAME'); if (!$db->num_rows($select)) { clean_kill('There are no gangs to delete'); } if (!array_key_exists('submit', $_POST)) { ?> <form action="staff_gangs.php?action=gdelete" method="post"> <div class="form-control"> <label for="gang">Gang</label> <select name="gang" id="gang" class="form-control"> <?php while ($row = $db->fetch_row($select)) { printf('<option value="%u">%s</option>', $row['gangID'], stripslashes(htmlspecialchars($row['gangNAME']))); } ?> </select> </div> <div class="form-control"> <label for="reason">Reason</label> <input type="text" name="reason" id="reason" class="form-control"> </div> <div class="form-check"> <input type="checkbox" name="notify" id="notify" value="1" class="form-check-input" checked> <label for="notify" class="form-check-label">Notify members</label> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Delete the selected gang </button> </form> <?php } else { $_POST['gang'] = array_key_exists('gang', $_POST) && is_numeric($_POST['gang']) && (int)$_POST['gang'] > 0 ? (int)$_POST['gang'] : null; $_POST['reason'] = array_key_exists('reason', $_POST) && is_string($_POST['reason']) && strlen($_POST['reason']) > 0 ? strip_tags(trim($_POST['reason'])) : null; if (empty($_POST['gang'])) { clean_kill('You didn\'t select a valid gang'); } if (empty($_POST['reason'])) { clean_kill('You didn\'t enter a valid reason'); } $select = $db->query('SELECT gangNAME FROM gangs WHERE gangID = ' . $_POST['gang']); if (!$db->num_rows($select)) { clean_kill('That gang doesn\'t exist'); } $gangName = $db->fetch_single($select); if (isset($_POST['notify']) && $_POST['notify']) { $selectMembers = $db->query('SELECT userid FROM users WHERE gang = ' . $_POST['gang']); if ($db->num_rows($selectMembers)) { while ($row = $db->fetch_row($selectMembers)) { event_add($row['userid'], 'Your gang has been disbanded by the Administration'); } } } $db->query('DELETE FROM gangs WHERE gangID = ' . $_POST['gang']); $db->query('DELETE FROM gangwars WHERE ' . $_POST['gang'] . ' IN (warDECLARED, warDECLARER)'); $db->query('DELETE FROM gangevents WHERE gevGANG = ' . $_POST['gang']); $checkForMTGsGangArmoury = $db->query('SHOW COLUMNS FROM inventory WHERE (field = "inv_borrowed")'); if ($db->num_rows($checkForMTGsGangArmoury)) { $db->query('DELETE FROM inventory WHERE (inv_borrowed = \'Yes\')'); $db->query('DELETE FROM gang_armoury WHERE gang = ' . $_POST['gang']); $db->query('DELETE FROM gang_armoury_loans WHERE gang = ' . $_POST['gang']); $db->query( 'UPDATE users SET IF(equip_primary_loaned = \'Yes\', (equip_primary_loaned = \'No\', equip_primary = 0), equip_primary_loaned = \'No\'), IF(equip_secondary_loaned = \'Yes\', (equip_secondary_loaned = \'No\', equip_secondary = 0), equip_secondary_loaned = \'No\'), IF(equip_armor_loaned = \'Yes\', (equip_armor_loaned = \'No\', equip_armor = 0), equip_armor_loaned = \'No\') WHERE gang = ' . $_POST['gang'] ); } $db->query('UPDATE users SET gang = 0 WHERE gang = ' . $_POST['gang']); stafflog_add('Deleted the gang named “' . $gangName . '” with the reason: ' . $_POST['reason']); echo 'You\'ve deleted the gang “' . $gangName . '”'; } } Add your link to the staff menu (smenu.php by default) staff_gangs.php?action=gdelete
-
This mod was requested by Bennyh789 on this topic Gang Alliance PHP 5.6 compliant Edit yourgang.php, add to the bottom (above the endpage..) /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } /** * Applies stripslashes() and htmlspecialchars() to strings, and number_format() to integers/floats. * @param int|float|string $str * @return string */ function format($str) { return is_numeric($str) ? number_format($str) : stripslashes(htmlspecialchars($str)); } /** * Adds an event to the gangevents table. * @param database $db * @param int $gangID * @param string $event * @return void */ function gang_event_add($db, $gangID, $event) { $db->query('INSERT INTO gangevents (gevGANG, gevTIME, gevTEXT) VALUES (' . $gangID . ', ' . time() . ', \'' . $db->escape($event) . '\')'); } $_GET['ID'] = array_key_exists('ID', $_GET) && is_numeric($_GET['ID']) && (int)$_GET['ID'] > 0 ? (int)$_GET['ID'] : null; /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_request($db, $gangdata) { if (!array_key_exists('submit', $_POST)) { $pikachu = $db->query('SELECT gangID, gangNAME FROM gangs WHERE gangID <> ' . $gangdata['gangID']); ?> <h3>Request an Alliance</h3> <form action="yourgang.php?action=staff&act2=alliancer" method="post"> <div class="form-group"> <label for="gang">Gang</label> <select name="gang" id="gang" class="form-control"> <?php if (!$db->num_rows($pikachu)) { ?> <option value="0">There are no gangs</option> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { printf('<option value="%u">%s</option>', $yellow['gangID'], format($yellow['gangNAME'])); } } ?> </select> </div> <div class="form-group"> <label for="message">Message</label> <textarea name="message" id="message" rows="10" cols="70" placeholder="Enter a reason as to why you want to become allies"></textarea> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Request Alliance </button> </form> <?php } else { $_POST['gang'] = array_key_exists('gang', $_POST) && ctype_digit($_POST['gang']) && $_POST['gang'] > 0 ? $_POST['gang'] : null; $_POST['message'] = array_key_exists('message', $_POST) && is_string($_POST['message']) && strlen($_POST['message']) > 0 ? strip_tags(trim($_POST['message'])) : null; if ($_POST['gang'] === null) { clean_kill('You didn\'t select a valid gang'); } if ($_POST['message'] === null) { clean_kill('You didn\'t enter a valid message'); } $blue = $db->query('SELECT gangID, gangNAME FROM gangs WHERE gangID = ' . $_POST['gang']); if (!$db->num_rows($blue)) { clean_kill('That gang doesn\'t exist'); } $row = $db->fetch_row($blue); $froob = $db->query('SELECT gaID FROM gangs_alliances WHERE (gaGuild1 = ' . $_POST['gang'] . ' AND gaGuild2 = ' . $gangdata['gangID'] . ') OR (gaGuild2 = ' . $_POST['gang'] . ' AND gaGuild1 = ' . $gangdata['gangID'] . ')'); if ($db->num_rows($froob)) { clean_kill('You\'re already allied with ' . format($row['gangNAME'])); } if ($_POST['gang'] == $gangdata['gangID']) { clean_kill('You can\'t ally with yourself!'); } $selectRequest = $db->query('SELECT garID FROM gangs_alliances_requests WHERE (garGuildFrom = ' . $_POST['gang'] . ' AND garGuildTo = ' . $gangdata['gangID'] . ') OR (garGuildTo = ' . $_POST['gang'] . ' AND garGuildFrom = ' . $gangdata['gangID'] . ')'); if ($db->num_rows($selectRequest)) { clean_kill('You\'ve already sent an alliance request'); } $db->query('INSERT INTO gangs_alliances_requests VALUES (NULL, ' . time() . ', ' . $gangdata['gangID'] . ', ' . $_POST['gang'] . ', \'' . $db->escape($_POST['message']) . '\')'); $eventText = '<a href="gangs.php?action=view&ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has sent an alliance request to <a href="gangs.php?action=view&ID=' . $_POST['gang'] . '">' . $row['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $_POST['gang'], $eventText); echo 'You\'ve requested to become allied with ' . format($row['gangNAME']); } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_decide($db, $gangdata) { if ($_GET['ID'] === null) { clean_kill('You didn\'t select a valid alliance request to decide on'); } $select = $db->query('SELECT gar.*, g.gangID, g.gangNAME FROM gangs_alliances_requests AS gar INNER JOIN gangs AS g ON g.gangID = gar.garGuildFrom WHERE gar.garGuildTo = ' . $gangdata['gangID'] . ' AND gar.garID = ' . $_GET['ID'] . ' LIMIT 1' ); if (!$db->num_rows($select)) { clean_kill('That request doesn\'t exist'); } $_GET['what'] = array_key_exists('what', $_GET) && in_array($_GET['what'], ['accept', 'decline']) ? $_GET['what'] : null; if ($_GET['what'] === null) { clean_kill('You didn\'t select a valid decision'); } $req = $db->fetch_row($select); if ('accept' == $_GET['what']) { $db->query('INSERT INTO gangs_alliances VALUES (NULL, ' . $gangdata['gangID'] . ', ' . $req['gangID'] . ')'); $db->query('DELETE FROM gangs_alliances_requests WHERE garID = ' . $_GET['ID']); $eventText = '<a href="gangs.php?action=view&ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has accepted the alliance request from <a href="gangs.php?action=view&ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $req['gangID'], $eventText); echo 'You\'ve accepted the alliance request from <a href="gangs.php?action=view&ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; } else { $eventText = '<a href="gangs.php?action=view&ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> have declined the alliance request from <a href="gangs.php?action=view&ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; $db->query('DELETE FROM gangs_alliances_requests WHERE garID = ' . $_GET['ID']); gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $req['gangID'], $eventText); echo 'You\'ve declined the alliance request from <a href="gangs.php?action=view&ID=' . $req['gangID'] . '">' . $req['gangNAME'] . '</a>'; } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_break($db, $gangdata) { if (!array_key_exists('submit', $_POST)) { $pikachu = $db->query('SELECT gi.gaID, g.gangID, g.gangNAME FROM gangs_alliances AS gi INNER JOIN gangs AS g ON g.gangID = gi.gaGuild2 WHERE ' . $gangdata['gangID'] . ' IN (gi.gaGuild1, gi.gaGuild2)' ); ?> <h3>Break an Alliance</h3> <form action="yourgang.php?action=staff&act2=allianceb" method="post"> <div class="form-group"> <label for="alliance">Gang</label> <select name="alliance" id="alliance" class="form-control"> <?php if (!$db->num_rows($pikachu)) { ?> <option value="0">You have no allies</option> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { printf('<option value="%u"%s>%s</option>', $yellow['gaID'], $yellow['gaID'] == $_GET['ID'] ? ' selected' : '', format($yellow['gangNAME'])); } } ?> </select> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Break Alliance </button> </form> <?php } else { $_POST['alliance'] = array_key_exists('alliance', $_POST) && ctype_digit($_POST['alliance']) && $_POST['alliance'] > 0 ? $_POST['alliance'] : null; if ($_POST['alliance'] === null) { clean_kill('You didn\'t select a valid alliance'); } $blue = $db->query('SELECT ga.gaID, g.gangID, g.gangNAME FROM gangs_alliances AS ga INNER JOIN gangs AS g ON g.gangID = ga.gaGuild2 WHERE (ga.gaID = ' . $_POST['alliance'] . ' AND ga.gaGuild1 = ' . $gangdata['gangID'] . ') OR ga.gaGuild2 = ' . $gangdata['gangID'] ); if (!$db->num_rows($blue)) { clean_kill('Either that alliance doesn\'t exist, or it\'s not yours!'); } $row = $db->fetch_row($blue); $db->query('DELETE FROM gangs_alliances WHERE gaID = ' . $_POST['alliance']); $eventText = '<a href="gangs.php?action=view&ID=' . $gangdata['gangID'] . '">' . $gangdata['gangNAME'] . '</a> has broken the alliance with <a href="gangs.php?action=view&ID=' . $row['gangID'] . '">' . $row['gangNAME'] . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $row['gangID'], $eventText); echo 'You have broken the alliance'; } } /** * @param database $db * @param array $gangdata * @return void */ function gang_staff_alliance_view($db, $gangdata) { $pikachu = $db->query('SELECT ga.*, g.gangID, g.gangNAME FROM gangs_alliances AS ga INNER JOIN gangs AS g ON g.gangID = ga.gaGuild2 WHERE ga.gaGuild1 = ' . $gangdata['gangID'] . ' OR ga.gaGuild2 = ' . $gangdata['gangID'] ); $froob = $db->query('SELECT gar.*, g.gangID, g.gangNAME FROM gangs_alliances_requests AS gar INNER JOIN gangs AS g ON gar.garGuildFrom = g.gangID WHERE gar.garGuildTo = ' . $gangdata['gangID'] . ' ORDER BY gar.garTime' ); ?> <table class="table w-100"> <thead> <tr> <th class="w-80">Gang</th> <th class="w-20">Action</th> </tr> </thead> <tfoot> <tr> <th>Gang</th> <th>Action</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($pikachu)) { ?> <tr> <td colspan="2" class="text-center">You do not have any Allies</td> </tr> <?php } else { while ($yellow = $db->fetch_row($pikachu)) { ?> <tr> <td><a href="gangs.php?action=view&ID=<?php echo $yellow['gaGuild2']; ?>"><?php echo format($yellow['gangNAME']); ?></a></td> <td class="text-center"> <a href="yourgang.php?action=staff&act2=allianceb&ID=<?php echo $yellow['gaID']; ?>"> <img src="/silk/link_break.png" alt="Break" /> Break this alliance </a> </td> </tr> <?php } } ?> </tbody> </table><br /><br /> <h3>Alliance Requests</h3> <table class="table w-100"> <thead> <tr> <th class="w-40">Gang</th> <th class="w-40">Message</th> <th class="w-20">Links</th> </tr> </thead> <tfoot> <tr> <th>Gang</th> <th>Message</th> <th>Links</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($froob)) { ?> <tr> <td colspan="3" class="text-center">You do not have any alliance requests</td> </tr> <?php } else { while ($blue = $db->fetch_row($froob)) { ?> <tr> <td><a href="gangs.php?action=view&ID=<?php echo $blue['gangID']; ?>"><?php echo format($blue['gangNAME']); ?></a></td> <td><?php echo format($blue['garMessage']); ?></td> <td> <a href="yourgang.php?action=staff&act2=alliance&ID=<?php echo $blue['garID']; ?>&what=accept"> <img src="/silk/accept.png" alt="Accept"> Accept this request </a> <a href="yourgang.php?action=staff&act2=alliance&ID=<?php echo $blue['garID']; ?>&what=decline"> <img src="/silk/delete.png" alt="Decline"> Decline this request </a> </td> </tr> <?php } } ?> </tbody> </table> <?php } Edit the function gang_staff_wardeclare() Find if ($_POST['gang'] == $gangdata['gangID']) { echo "You can't declare war on your own gang.<br /> > <a href='yourgang.php?action=staff&act2=declare'>Go back</a>"; $h->endpage(); exit; } Add below $selectGangAlliance = $db->query('SELECT gaID FROM gangs_alliances WHERE ' . $gangdata['gangID'] . ' IN (gaGuild1, gaGuild2) AND ' . $_POST['gang'] . ' IN (gaGuild1, gaGuild2)'); if ($db->num_rows($selectGangAlliance)) { ?> Your gang is currently allied with that gang. You cannot attack them<br /> > <a href="yourgang.php?action=staff&act2=declare">Go back</a> <?php $h->endpage(); exit; } Still in gang_staff_wardeclare() Find $db->query( "INSERT INTO `gangwars` VALUES(NULL, {$gangdata['gangID']}, {$_POST['gang']}, " . time() . ")"); Add above $time = time(); $query = ''; $selectAllies1 = $db->query('SELECT gaGuild2 FROM gangs_alliances WHERE gaGuild1 = ' . $_POST['gang']); if ($db->num_rows($selectAllies1)) { while ($row = $db->fetch_row($selectAllies1)) { $query .= '(' . $gangdata['gangID'] . ', ' . $row['gaGuild2'] . ', ' . $time . '), '; } } $selectAllies2 = $db->query('SELECT gaGuild1 FROM gangs_alliances WHERE gaGuild2 = ' . $_POST['gang']); if ($db->num_rows($selectAllies2)) { while ($row = $db->fetch_row($selectAllies2)) { $query .= '(' . $gangdata['gangID'] . ', ' . $row['gaGuild1'] . ', ' . $time . '), '; } } if ('' != $query) { $db->query('INSERT INTO gangwars (warDECLARER, warDECLARED, warTIME) VALUES ' . substr($query, -2)); } Add the gang staff cases case 'alliancer': guild_staff_alliance_request($db, $gangdata); break; case 'alliancea': guild_staff_alliance_decide($db, $gangdata); break; case 'alliancev': guild_staff_alliance_view($db, $gangdata); break; case 'allianceb': guild_staff_alliance_break($db, $gangdata); break; SQLs CREATE TABLE `gangs_alliances_requests` ( `garID` int NOT NULL auto_increment, `garTime` int NOT NULL default '0', `garGuildFrom` int NOT NULL default '0', `garGuildTo` int NOT NULL default '0', `garMessage` text NOT NULL, PRIMARY KEY (`garID`) ); CREATE TABLE `gangs_alliances` ( `gaID` int NOT NULL auto_increment, `gaGuild1` int NOT NULL default '0', `gaGuild2` int NOT NULL default '0', PRIMARY KEY (`gaID`) ); Edit attack.php, add this where the rest of the if() statements are (towards the top of the file) if ($odata['gang'] > 0) { $selectGangAlliance = $db->query('SELECT COUNT(gaID) FROM gangs_lliances WHERE ' . $ir['gang'] . ' IN (gaGuild1, gaGuild2) AND ' . $odata['gang'] . ' IN (gaGuild1, gaGuild2)'); if ($db->fetch_single($selectGangAlliance)) { echo 'Your gang is currently allied with ' . $odata['username'] . '\'s gang. You can\'t attack ' . (('Male' === $odata['gender']) ? 'him' : 'her'); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; $h->endpage(); exit; } } And finally, the CSS; .w-20 { width: 20%; } .w-40 { width: 40%; } .w-80 { width: 80%; } .w-100 { width: 100%; } .text-center { text-align: center; }
-
This mod was requested by Bennyh789 on this topic This can also be found on my site here: http://magictallguy.tk/mods.php?mod=13 Edit yourgang.php Find case "masspayment": gang_staff_masspayment(); break; Add below case 'delete': gang_staff_delete($db, $gangdata, $ir); break; Find <br /> <a href='yourgang.php?action=staff&act2=tag'>Change Gang Tag</a> Add below <br /> <a href='yourgang.php?action=staff&act2=delete'>Disband Gang</a> Find the closing brace at the end of the gang_staff_apps() function Add below if (!function_exists('clean_kill')) { /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } } function gang_staff_delete($db, $gangdata, $ir) { if ($gangdata['gangPRESIDENT'] != $ir['userid']) { clean_kill('You don\'t have access to this'); } if (!array_key_exists('ans', $_GET)) { ?> Once you have disbanded your gang, it is permanent. This can <strong>not</strong> be reversed.<br> Are you sure you want to do this? <a href="yourgang.php?action=staff&act2=delete&ans=yes">Yes</a> · <a href="yourgang.php">No</a> <?php } else { $select = $db->query('SELECT userid FROM users WHERE gang = ' . $gangdata['gangID']); while ($row = $db->fetch_row($select)) { event_add($row['userid'], 'Your gang has been disbanded'); } $db->query('DELETE FROM gangs WHERE gangID = ' . $gangdata['gangID']); $db->query('DELETE FROM gangwars WHERE ' . $gangdata['gangID'] . ' IN (warDECLARED, warDECLARER)'); $db->query('DELETE FROM gangevents WHERE gevGANG = ' . $gangdata['gangID']); $checkForMTGsGangArmoury = $db->query('SHOW COLUMNS FROM inventory WHERE (Field = \'inv_borrowed\')'); if ($db->num_rows($checkForMTGsGangArmoury)) { $db->query('DELETE FROM inventory WHERE (inv_borrowed = \'Yes\')'); $db->query('DELETE FROM gang_armoury WHERE gang = ' . $_POST['gang']); $db->query('DELETE FROM gang_armoury_loans WHERE gang = ' . $_POST['gang']); $db->query( 'UPDATE users SET IF(equip_primary_loaned = \'Yes\', (equip_primary_loaned = \'No\', equip_primary = 0), equip_primary_loaned = \'No\'), IF(equip_secondary_loaned = \'Yes\', (equip_secondary_loaned = \'No\', equip_secondary = 0), equip_secondary_loaned = \'No\'), IF(equip_armor_loaned = \'Yes\', (equip_armor_loaned = \'No\', equip_armor = 0), equip_armor_loaned = \'No\') WHERE gang = ' . $gangdata['gangID'] ); } $db->query('UPDATE users SET gang = 0 WHERE gang = ' . $gangdata['gangID']); echo 'Your gang has been disbanded.<br><a href="index.php">Home</a>'; } }
-
This mod was requested by Bennyh789 on this topic Gang Kidnap Edit gangs.php Find <th>Days In Gang</th> Add below <th>Links</th> Find case 'applys': gang_applysubmit(); break; Add below case 'kidnap': gang_kidnap($db, $gangdata, $ir); break; Find <td>{$r['daysingang']}</td> Add below <td>" . ($gangdata['gangID'] != $ir['gang'] ? '<a href="gangs.php?action=kidnap&ID='.$gangdata['gangID'].'&u='.$r['userid'].'">Kidnap</a>' : '')."</td> Find $h->endpage(); Add above if (!function_exists('format')) { /** * Applies stripslashes() and htmlspecialchars() to strings, and number_format() to integers/floats. * @param int|float|string $str * @return string */ function format($str) { return is_numeric($str) ? number_format($str) : stripslashes(htmlspecialchars($str)); } } if (!function_exists('clean_kill')) { /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } } if (!function_exists('gang_event_add')) { /** * Adds an event to the gangevents table. * @param database $db * @param int $gangID * @param string $event * @return void */ function gang_event_add($db, $gangID, $event) { $db->query('INSERT INTO gangevents (gevGANG, gevTIME, gevTEXT) VALUES (' . $gangID . ', ' . time() . ', \'' . $db->escape($event) . '\')'); } } /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_kidnap($db, $gangdata, $ir) { $_GET['u'] = array_key_exists('u', $_GET) && is_numeric($_GET['u']) && (int)$_GET['u'] > 0 ? (int)$_GET['u'] : null; if (empty($_GET['u'])) { clean_kill('You didn\'t select a valid gang member'); } if ($_GET['u'] == $ir['userid']) { clean_kill('You can\'t kidnap yourself'); } if (!$ir['gang']) { clean_kill('You\'re not in a gang, you can\'t do this'); } if ($ir['gang'] == $gangdata['gangID']) { clean_kill('You can\'t kidnap your own members...'); } $select = $db->query('SELECT COUNT(gangID) FROM gangs WHERE gangID = ' . $ir['gang'] . ' AND ' . $ir['userid'] . ' IN (gangPRESIDENT, gangVICEPRES)'); if (!$db->fetch_single($select)) { clean_kill('You\'re not the President or Vice President of your gang. You can\'t do that'); } if (in_array($_GET['u'], [$gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']])) { clean_kill('You can\'t kidnap the President or Vice President'); } $select = $db->query('SELECT username, gang FROM users WHERE userid = ' . $_GET['u']); if (!$db->num_rows($select)) { clean_kill('That player doesn\'t exist'); } $row = $db->fetch_row($select); if ($row['gang'] != $gangdata['gangID']) { clean_kill($row['username'] . ' isn\'t in that gang'); } $selectRansoms = $db->query('SELECT gkID FROM gangs_kidnaps WHERE gkUser = ' . $_GET['u']); if ($db->num_rows($selectRansoms)) { clean_kill($row['username'] . ' is already being held ransom'); } if (!array_key_exists('submit', $_POST)) { echo '<h3>Kidnapping ' . stripslashes(htmlspecialchars($row['username'])) . ' from ' . stripslashes(htmlspecialchars($gangdata['gangNAME'])) . '</h3>'; ?> <form action="gangs.php?action=kidnap&ID=<?php echo $gangdata['gangID']; ?>&u=<?php echo $_GET['u']; ?>" method="post"> <div class="form-group"> <label for="ransom">Ransom</label> <input type="number" name="ransom" id="ransom" class="form-control"> </div> <button type="submit" name="submit" class="btn btn-primary"> <span class="fas fa-check"></span> Kidnap </button> </form> <?php } else { $_POST['ransom'] = array_key_exists('ransom', $_POST) && is_numeric($_POST['ransom']) && (int)$_POST['ransom'] > 0 ? (int)$_POST['ransom'] : null; if (empty($_POST['ransom'])) { clean_kill('You didn\'t enter a valid ransom'); } $db->query('INSERT INTO gangs_kidnaps (gkGangKidnapper, gkGangKidnapped, gkUser, gkTime, gkRansom) VALUES (' . $ir['gang'] . ', ' . $gangdata['gangID'] . ', ' . $_GET['u'] . ', ' . (time() + 3600) . ', ' . $_POST['ransom'] . ')'); gang_event_add($db, $gangdata['gangID'], '<a href="viewuser.php?u=' . $ir['userid'] . '">' . format($ir['username']) . '</a> has kidnapped <a href="viewuser.php?u=' . $_GET['u'] . '">' . format($row['username']) . '</a> from ' . format($gangdata['gangNAME']) . '. You have 1 hour to pay the ransom'); gang_event_add($db, $ir['gang'], '<a href="viewuser.php?u=' . $ir['userid'] . '">' . format($ir['username']) . '</a> has kidnapped <a href="viewuser.php?u=' . $_GET['u'] . '">' . format($row['username']) . '</a> from ' . format($gangdata['gangNAME']) . '. They have 1 hour to pay the ransom'); echo 'You\'ve kidnapped ' . format($row['username']) . ' from ' . format($gangdata['gangNAME']); } } Edit yourgang.php Find (at the bottom of the file) if ($db->fetch_single($wq) > 0) { echo " <h3> <a href='yourgang.php?action=warview'> <span style='color: red;'>Your gang is currently in " . $db->fetch_single($wq) . " war(s).</span> </a> </h3> "; } Add below $select = $db->query('SELECT COUNT(gkUser) FROM gangs_kidnaps WHERE gkGangKidnapped = ' . $gangdata['gangID']); $kidCnt = $db->fetch_single($select); if ($kidCnt > 0) { ?> <h3><a href="yourgang.php?action=viewkidnap" style="color: #ff0000;"><?php echo $kidCnt . ' member' . (1 == $kidCnt ? ' has' : 's have'); ?> been kidnapped</a></h3> <?php } Find case "crimes": gang_crimes(); break; Add case 'viewkidnaps': gang_view_kidnaps($db, $gangdata, $ir); break; Find function gang_crimes() { global $gangdata; if ($gangdata['gangCRIME'] > 0) { echo "This is the crime your gang is planning at the moment.<br /> <b>Crime:</b> {$gangdata['ocNAME']}<br /> <b>Hours Left:</b> {$gangdata['gangCHOURS']}"; } else { echo "Your gang is not currently planning a crime."; } } Add below /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function viewKidnaps($db, $gangdata, $ir) { ?> <h3>Members kidnapped from your gang</h3> <?php $select = $db->query( 'SELECT gk.gkGangKidnapper, gk.gkTime, gk.gkUser, g.gangNAME, u.username FROM gangs_kidnaps AS gk INNER JOIN gangs AS g ON g.gangID = gk.gkGangKidnapper INNER JOIN users AS u ON u.userid = gk.gkUser WHERE gk.gkGangKidnapped = ' . $gangdata['gangID'] . ' ORDER BY gk.gkTime' ); $width = in_array($ir['userid'], [$gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']]) ? 20 : 25; ?> <table class="table w-100"> <thead> <tr> <th style="width: <?php echo $width; ?>%;">Kidnapper</th> <th style="width: <?php echo $width; ?>%;">Member</th> <th style="width: <?php echo $width; ?>%;">Ransom</th> <th style="width: <?php echo $width; ?>%;">Time Left</th> <?php if (20 == $width) { ?> <th style="width: 20%;">Links</th> <?php } ?> </tr> </thead> <tbody> <?php if (!$db->num_rows($select)) { ?> <tr> <td colspan="4" class="center">Good news! No-one has been kidnapped from <?php echo stripslashes(htmlspecialchars($gangdata['gangNAME'])); ?> ... yet!</td> </tr> <?php } else { $time = time(); while ($row = $db->fetch_row($select)) { ?> <tr> <td><a href="gangs.php?action=view&ID=<?php echo $row['gkGangKidnapper']; ?>"><?php echo stripslashes(htmlspecialchars($row['gangNAME'])); ?></a></td> <td><a href="viewuser.php?u=<?php echo $row['gkUser']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a></td> <td>$<?php echo number_format($row['gkRansom']); ?></td> <td><?php echo time2readable($row['gkTime'] - $time); ?></td> <?php if (20 == $width) { ?> <td><a href="yourgang.php?action=staff&act2=pay&u=<?php echo $row['gkUser']; ?>">Pay</a></td> <?php } ?> </tr> <?php } } ?> </tbody> </table> <?php } Find case "masspayment": gang_staff_masspayment(); break; Add below case 'payransom': gang_staff_payransom($db, $gangdata, $ir); break; Find the closing brace of the gang_staff_idx() function Add below /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_staff_payransom($db, $gangdata, $ir) { if (!in_array($ir['userid'], [$gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']])) { clean_kill('You\'re not the President or Vice President. You can\'t do that'); } $_GET['u'] = array_key_exists('u', $_GET) && is_numeric($_GET['u']) && (int)$_GET['u'] > 0 ? (int)$_GET['u'] : null; if (empty($_GET['u'])) { clean_kill('You didn\'t select a valid ransom to pay'); } $select = $db->query( 'SELECT gk.gkRansom, gk.gkGangKidnapper, g.gangID, g.gangNAME, u.username FROM gangs_kidnaps AS gk INNER JOIN gangs AS g ON g.gangID = gk.gkGangKidnapper INNER JOIN users AS u ON u.userid = gk.gkUser WHERE gkUser = ' . $_GET['u'] . ' AND gkGangKidnapped = ' . $gangdata['gangID'] ); if (!$db->num_rows($select)) { clean_kill('That player hasn\'t been kidnapped'); } $row = $db->fetch_row($select); ?> <h3>Paying a ransom</h3> <?php if (!array_key_exists('ans', $_GET)) { ?> The ransom stands at $<?php echo number_format($row['gkRansom']); ?> to save <a href="viewuser.php?u=<?php echo $_GET['u']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a> from <a href="gangs.php?action=view&ID=<?php echo $row['gangID']; ?>"><?php echo stripslashes(htmlspecialchars($row['gangNAME'])); ?></a><br /> If you choose to pay this, it will come from the gang vault<br /> Pay the ransom?<br /> <a href="yourgang.php?action=staff&act2=payransom&u=<?php echo $_GET['u']; ?>&ans=yes">Yes</a> · <a href="yourgang.php">No</a> <?php } else { if ($gangdata['gangMONEY'] < $row['gkRansom']) { clean_kill('You don\'t have enough in the gang vault to pay the ransom'); } $db->query('DELETE FROM gangs_kidnaps WHERE gkUser = ' . $_GET['u']); $db->query('UPDATE gangs SET gangMONEY = gangMONEY - ' . $row['gkRansom'] . ' WHERE gangID = ' . $r['gangID']); $db->query('UPDATE gangs SET gangMONEY = gangMONEY + ' . $row['gkRansom'] . ' WHERE gangID = ' . $row['gangID']); $eventText = '<a href="gangs.php?action=view&ID=' . $gangdata['gangID'] . '">' . stripslashes(htmlspecialchars($gangdata['gangNAME'])) . '</a> have paid the ransom demand for <a href="viewuser.php?u=' . $_GET['u'] . '">' . stripslashes(htmlspecialchars($row['username'])) . '</a>'; gang_event_add($db, $gangdata['gangID'], $eventText); gang_event_add($db, $row['gangID'], $eventText); echo 'You\'ve paid the $' . number_format($row['gkRansom']) . ' ransom and <a href="viewuser.php?u=' . $_GET['u'] . '">' . stripslashes(htmlspecialchars($row['username'])) . '</a> has returned safely'; } } Edit global_func.php Add at the bottom /** * @param int|float $seconds * @param string $mode * @param bool $ago * @param int $display * @return string */ function time2readable($seconds, $mode = 'long', $ago = false, $display = 3) { if (!$seconds) { return $ago ? 'Now' : 'Never'; } $names = [ 'long' => ['millennia', 'year', 'month', 'day', 'hour', 'minute', 'second'], 'short' => ['mil', 'yr', 'mth', 'day', 'hr', 'min', 'sec'], ]; $seconds = floor($seconds); $minutes = (int)($seconds / 60); $seconds -= $minutes * 60; $hours = (int)($minutes / 60); $minutes -= $hours * 60; $days = (int)($hours / 24); $hours -= $days * 24; $months = (int)($days / 31); $days -= $months * 31; $years = (int)($months / 12); $months -= $years * 12; $millennia = (int)($years / 1000); // lulwut $years -= $millennia * 1000; $displayed = 0; $result = []; $increments = [$millennia, $years, $months, $days, $hours, $minutes]; foreach ($increments as $increment) { if ($$increment > 0 && $displayed < $display) { $result[] = sprintf('%s %s', number_format($$increment), $names[$mode][0]); ++$displayed; } } if (($seconds > 0 && $displayed < $display) || !count($result)) { $result[] = sprintf('%s %s%s', number_format($seconds), $names[$mode][6], $this->pluralize($seconds)); } return implode(', ', $result) . ($ago ? ' ago' : ''); } Find in the menuarea() function global $ir, $c; Change to global $db, $ir, $c; Find if ($ir['jail']) { echo "<b>NB:</b> You are currently in jail for {$ir['jail']} minutes.<br />"; } Add below $select = $db->query( 'SELECT gk.gkGangKidnapper, gk.gkTime, g1.gangNAME AS kidnapper, g2.gangNAME AS kidnapped FROM gangs_kidnaps AS gk INNER JOIN gangs AS g1 ON g1.gangID = gk.gkGangKidnapper INNER JOIN gangs AS g2 ON g2.gangID = gk.gkGangKidnapped WHERE gk.gkUser = ' . $ir['userid'] ); if ($db->num_rows($select)) { $row = $db->fetch_row($select); $time = time(); ?> <strong>NB:</strong> You're currently being held ransom by <a href="gangs.php?action=view&ID=<?php echo $row['gkGangKidnapper']; ?>"><?php echo stripslashes(htmlspecialchars($row['kidnapper'])); ?></a><br /> Your gang has <?php echo time2readable($row['gkTime'] - $time); ?> left to pay.<br /> <?php if ($row['gkTime'] <= $time) { $db->query('UPDATE users SET hospital = ' . mt_rand(30, 60) . ', new_events = new_events + 1 WHERE userid = ' . $ir['userid']); $db->query('DELETE FROM gangs_kidnaps WHERE gkUser = ' . $ir['userid']); event_add($ir['userid'], 'Your gang failed to pay your ransom in time. You were beaten and hospitalized by your kidnappers'); gang_event_add($db, $ir['gang'], $row['kidnapped']); gang_event_add($db, $ir['gang'], $row['kidnapped']); $h->endpage(); exit; } } SQLs CREATE TABLE `gangs_kidnaps` ( `gkID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, `gkGangKidnapper` INT NOT NULL DEFAULT 0, `gkGangKidnapped` INT NOT NULL DEFAULT 0, `gkUser` INT NOT NULL DEFAULT 0, `gkTime` INT NOT NULL DEFAULT 0, `gkRansom` INT NOT NULL DEFAULT 0 );
-
This mod was requested by Bennyh789 on this topic This can also be found on my site here: http://magictallguy.tk/mods.php?mod=11 Gang House SQLs ALTER TABLE `gangs` ADD `gangHOUSE` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `users` ADD `oldMaxWill` INT NOT NULL DEFAULT 0; CREATE TABLE `gang_rentals_requests` ( `grrID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, `grrGang` INT NOT NULL DEFAULT 0, `grrUser` INT NOT NULL DEFAULT 0 ); CREATE TABLE `gangs_rentals` ( `grID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, `grGang` INT NOT NULL DEFAULT 0, `grUser` INT NOT NULL DEFAULT 0 ); Edit creategang.php Find $db->query( "INSERT INTO `gangs` (`gangNAME`, `gangDESC`, `gangRESPECT`, `gangPRESIDENT`, `gangVICEPRES`, `gangCAPACITY`) VALUES('$name', '$desc', 100, $userid, $userid, 5)"); Replace with $db->query('INSERT INTO gangs (gangNAME, gangDESC, gangRESPECT, gangPRESIDENT, gangVICEPRES, gangCAPACITY, gangAMENT) VALUES(' . $name . ', ' . $desc . ', 100, ' . $userid . ', ' . $userid . ', 5, 1, \'\')'); Edit yourgang.php Find default: gang_index(); break; Add above case 'ganghouse': gang_house($db, $gangdata); break; case 'reqhouse': gang_request_house($db, $gangdata, $ir); break; Find <td> "; if ($gangdata['gangPRESIDENT'] == $userid || $gangdata['gangVICEPRES'] == $userid) { echo "<a href='yourgang.php?action=staff&act2=idx'>Staff Room</a>"; } else { echo " "; } echo " </td> </tr> Add below <tr> <td colspan="2" class="center"><a href="yourgang.php?action=ganghouse">Gang House</a></td> </tr> Find the closing brace of the gang_index() function Add below if (!function_exists('clean_kill')) { /** * A simple function to kill the page with the given message * @param string $str * @param string|null $heading * @return void */ function clean_kill($str, $heading = null) { global $h; $message = ''; if (!empty($heading)) { $message = '<h3>' . $heading . '</h3>' . PHP_EOL; } echo $message . $str; $h->endpage(); exit; } } /** * @param database $db * @param array $gangdata * @return void */ function gang_house($db, $gangdata) { $select = $db->query( 'SELECT gr.grUser, u.username FROM gangs_rentals AS gr INNER JOIN users AS u ON gr.grUser = u.userid WHERE gr.grGang = ' . $gangdata['gangID'] ); $selectGangHouse = $db->query('SELECT hNAME FROM houses WHERE hID = ' . $gangdata['gangHOUSE']); $house = $db->fetch_single($selectGangHouse); ?> <h3>Gang House</h3> Your gang currently owns the <?php echo stripslashes(htmlspecialchars($house)); ?><br /> The house is being used by <?php if ($db->num_rows($select)) { $row = $db->fetch_row($select); ?> <a href="viewuser.php?u=<?php echo $row['grUser']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a><br /><?php } else { echo 'no one<br />'; } ?> <a href='yourgang.php?action=reqhouse'>Apply to move in</a> <?php if ($ir['userid'] == $gangdata['gangPRESIDENT']) { ?> · <a href='yourgang.php?action=staff&act2=kickhouse'>Kick the current tenant</a> · <a href='yourgang.php?action=staff&act2=upgradehouse'>Upgrade House</a><?php } } /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_request_house($db, $gangdata, $ir) { $select = $db->query('SELECT grrID FROM gangs_rentals_requests WHERE grrUser = ' . $ir['userid']); if ($db->num_rows($select)) { clean_kill('You\'ve already applied to move into your gang\'s house'); } $db->query('INSERT INTO gangs_rentals_requests VALUES (NULL, ' . $gangdata['gangID'] . ', ' . $ir['userid'] . ')'); echo 'You\'ve applied to move into your gang\'s house'; } Find default: gang_staff_idx(); break; Add above case 'viewhousereqs': gang_staff_view_house_requests($db, $gangdata, $ir); break; case 'decidehousereq': gang_staff_decide_house_request($db, $gangdata, $ir); break; case 'kickhouse': gang_staff_kick_house($db, $gangdata, $ir); break; case 'upgradehouse': gang_staff_upgrade_house($db, $gangdata, $ir); break; Find <br /> <a href='yourgang.php?action=staff&act2=tag'>Change Gang Tag</a> Add below <br /> <a href="yourgang.php?action=staff&act2=viewhousereqs">View House Requests</a> Find the closing brace of the gang_staff_idx() function Add below /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_staff_view_house_requests($db, $gangdata, $ir) { if ($ir['userid'] != $gangdata['gangPRESIDENT']) { clean_kill('You\'re not the President. You can\'t do that'); } $select = $db->query( 'SELECT grr.grrID, grr.grrUser, u.username FROM gangs_rentals_requests AS grr INNER JOIN users AS u ON u.userid = grr.grrUser WHERE grr.grrGang = ' . $gangdata['gangID'] . ' ORDER BY u.username' ); ?> <h3>House Requests</h3> <table class="table w-100"> <thead> <tr> <th class="w-50">Member</th> <th class="w-50">Links</th> </tr> </thead> <tfoot> <tr> <th>Member</th> <th>Links</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($select)) { ?> <tr> <td colspan="2" class="center">There are no requests</td> </tr> <?php } else { while ($row = $db->fetch_row($select)) { ?> <tr> <td><a href="viewuser.php?u=<?php echo $row['grrUser']; ?>"><?php echo stripslashes(htmlspecialchars($row['username'])); ?></a></td> <td> <a href="yourgang.php?action=staff&act2=decidehousereq&ID=<?php echo $row['grrID']; ?>&dir=accept" style="color:#79A888;">Accept</a> · <a href="yourgang.php?action=staff&act2=decidehousereq&ID=<?php echo $row['grrID']; ?>&dir=decline" style="color:#AF4035;">Decline</a> </td> </tr> <?php } } ?> </tbody> </table> <?php } /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_staff_decide_house_request($db, $gangdata, $ir) { if ($ir['userid'] != $gangdata['gangPRESIDENT']) { clean_kill('You\'re not the President. You can\'t do that'); } $_GET['ID'] = array_key_exists('ID', $_GET) && is_numeric($_GET['ID']) && (int)$_GET['ID'] > 0 ? (int)$_GET['ID'] : null; if (empty($_GET['ID'])) { clean_kill('You didn\'t select a valid request'); } $select = $db->query(sprintf('SELECT grrUser FROM gangs_rentals_requests WHEERE ((grrID = %u) AND (grrGang = %u))', $_GET['ID'], $gangdata['gangID'])); if (!$db->num_rows($select)) { clean_kill('Either that request doesn\'t exist, or it\'s not yours'); } $row = $db->fetch_row($select); $_GET['dir'] = array_key_exists('dir', $_GET) && in_array($_GET['dir'], ['accept', 'decline']) ? $_GET['dir'] : null; if (null === $_GET['dir']) { clean_kill('You didn\'t specify what to do with this request'); } $selectCurrent = $db->query( 'SELECT gr.grUser, u.username FROM gangs_rentals AS gr INNER JOIN users AS u ON gr.grUser = u.username WHERE gr.grGang = ' . $gangdata['gangID'] ); if ('accept' == $_GET['dir']) { if ($db->num_rows($selectCurrent)) { $user = $db->fetch_row($selectCurrent); $db->query('DELETE FROM gangs_rentals WHERE grGang = ' . $gangdata['gangID']); $db->query('UPDATE users SET maxwill = oldMaxWill, oldMaxWill = 0 WHERE userid = ' . $user['grUser']); event_add($user['grUser'], 'You\'ve been kicked from the gang house'); echo stripslashes(htmlspecialchars($user['username'])) . ' has been kicked from the gang house<br />'; } $db->query('INSERT INTO gangs_rentals VALUES (NULL, ' . $gangdata['gangID'] . ', ' . $row['grrUser'] . ')'); $selectHouseWill = $db->query('SELECT hWILL FROM houses WHERE hID = ' . $gangdata['gangHOUSE']); $houseWill = $db->fetch_single($selectHouseWill); $db->query('UPDATE users SET oldMaxWill = maxwill, maxwill = ' . $houseWill . ' WHERE userid = ' . $row['grrUser']); } $db->query('DELETE FROM gangs_rentals_requests WHERE grrID = ' . $_GET['ID']); $what = 'accept' == $_GET['dir'] ? 'accepted' : 'declined'; event_add($row['grrUser'], 'Your request to move in to your gang\'s house has been ' . $what); echo stripslashes(htmlspecialchars($row['username'])), '\'s request has been ', $_GET['dir'], $what; } /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_staff_kick_house($db, $gangdata, $ir) { if ($ir['userid'] != $gangdata['gangPRESIDENT']) { clean_kill('You\'re not the President. You can\'t do that'); } $select = $db->query( 'SELECT gr.grUser, u.username FROM gangs_rentals AS gr INNER JOIN users AS u ON gr.grUser = u.userid WHERE gr.grGang = ' . $gangdata['gangID'] ); if (!$db->num_rows($select)) { clean_kill('None of your members are currently using the house'); } $row = $db->fetch_row($select); $db->query('DELETE FROM gangs_rentals WHERE grGang = ' . $gangdata['gangID']); $db->query('UPDATE users SET maxwill = oldMaxWill, oldMaxWill = 0 WHERE userid = ' . $row['grUser']); event_add($row['grUser'], 'You\'ve been kicked from the gang house'); echo 'You\'ve kicked <a href="viewuser.php?u=' . $row['grUser'] . '">' . stripslashes(htmlspecialchars($row['username'])) . '</a> from that gang house</a>'; } /** * @param database $db * @param array $gangdata * @param array $ir * @return void */ function gang_staff_upgrade_house($db, $gangdata, $ir) { if ($gangdata['gangPRESIDENT'] != $ir['userid']) { clean_kill('You\'re not the President. You can\'t do that'); } $_GET['house'] = array_key_exists('house', $_GET) && is_numeric($_GET['house']) && (int)$_GET['house'] > 0 ? (int)$_GET['house'] : null; if (empty($_GET['house'])) { $selectCurrentHouse = $db->query('SELECT hNAME FROM houses WHERE hID = ' . $gangdata['gangID']); $currentHouse = $db->fetch_single($selectCurrentHouse); $selectHouses = $db->query('SELECT * FROM houses WHERE hID > ' . $gangdata['gangHOUSE'] . ' ORDER BY hWILL'); ?> Your gang currently owns the <?php echo stripslashes(htmlspecialchars($currentHouse)); ?><br /> <table class="table w-100"> <thead> <tr> <th class="w-33">House/Will</th> <th class="w-34">Price</th> <th class="w-33">Buy</th> </tr> </thead> <tfoot> <tr> <th>House/Will</th> <th>Price</th> <th>Buy</th> </tr> </tfoot> <tbody> <?php if (!$db->num_rows($selectHouses)) { ?> <tr> <td colspan="3" class="center">There are currently no upgrades</td> </tr> <?php } else { while ($row = $db->fetch_row($selectHouses)) { ?> <tr> <td> <?php echo stripslashes(htmlspecialchars($row['hNAME'])); ?><br> Will: <?php echo number_format($row['hWILL']); ?> </td> <td><?php echo number_format($row['hPRICE'] * 10); ?></td> <td><a href="yourgang.php?action=staff&act2=upgradehouse&house=<?php echo $row['hID']; ?>">Buy</a></td> </tr> <?php } } ?> </tbody> </table> <?php } else { $select = $db->query('SELECT hNAME, hPRICE FROM houses WHERE hID = ' . $_GET['house']); if (!$db->num_rows($select)) { clean_kill('That house doesn\'t exist'); } $row = $db->fetch_row($select); $cost = $row['hPRICE'] * 10; if ($cost > $gangdata['gangMONEY']) { clean_kill('Your gang\'s vault doesn\'t have enough for that'); } $db->query('UPDATE gangs SET gangMONEY = gangMONEY - ' . $cost . ', gangHOUSE = ' . $_GET['house'] . ' WHERE gangID = ' . $gangdata['gangID']); gang_event_add($gangdata['gangID'], 'The gang house has been upgraded to the ' . stripslashes(htmlspecialchars($row['hNAME']))); echo 'You\'ve upgraded the gang house to the ', stripslashes(htmlspecialchars($row['hNAME'])); } }
-
I'll do that now :) Original post updated
-
Gang House SQLs ALTER TABLE `gangs` ADD `gangHOUSE` INT( 11 ) NOT NULL DEFAULT 1; ALTER TABLE `users` ADD `oldMaxWill` INT( 11 ) NOT NULL DEFAULT 0; CREATE TABLE `gangRentalRequests` ( `grrID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `grrGang` INT( 11 ) NOT NULL DEFAULT 0, `grrUser` INT( 11 ) NOT NULL DEFAULT 0 ); CREATE TABLE `gangRentals` ( `grID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `grGang` INT( 11 ) NOT NULL DEFAULT 0, `grUser` INT( 11 ) NOT NULL DEFAULT 0 ); Edit creategang.php Find $db->query( "INSERT INTO `gangs` (`gangNAME`, `gangDESC`, `gangRESPECT`, `gangPRESIDENT`, `gangVICEPRES`, `gangCAPACITY`) VALUES('$name', '$desc', 100, $userid, $userid, 5)"); Replace with $db->query( "INSERT INTO `gangs` (`gangNAME`, `gangDESC`, `gangRESPECT`, `gangPRESIDENT`, `gangVICEPRES`, `gangCAPACITY`) VALUES('$name', '$desc', 100, $userid, $userid, 5, 1)"); Edit yourgang.php Find default: gang_index(); break; Add above case 'ganghouse': gang_house(); break; case 'reqhouse': gang_request_house(); break; Find <td> "; if ($gangdata['gangPRESIDENT'] == $userid || $gangdata['gangVICEPRES'] == $userid) { echo "<a href='yourgang.php?action=staff&act2=idx'>Staff Room</a>"; } else { echo " "; } echo " </td> </tr> Add below <tr> <td colspan='2' class='center'><a href='yourgang.php?action=ganghouse'>Gang House</a></td> </tr> Find the closing brace of the gang_index() function Add below function gang_house() { global $db, $gangdata; $house = $db->fetch_single($db->query(sprintf("SELECT `hNAME` FROM `houses` WHERE (`hID` = %u)", $gangdata['gangHOUSE']))); ?><h3>Gang House</h3>Your gang currently owns the <? echo stripslashes(htmlspecialchars($house)); ?><br /> The house is being used by<? $select = $db->query(sprintf("SELECT `gr`.`grUser`, `u`.`username` " . "FROM `gangRentals` AS `gr` " . "LEFT JOIN `users` AS `u` ON (`gr`.`grUser` = `u`.`userid`) " . "WHERE (`grGang` = %u)", $gangdata['gangID'])); if($db->num_rows($select)){ $row = $db->fetch_row($select); printf("<a href='viewuser.php?u=%u'>%s</a><br />", $row['grUser'], stripslashes(htmlspecialchars($row['username']))); } else { echo "no one<br />"; } ?><a href='yourgang.php?action=reqhouse'>Apply to move in</a><? if($ir['userid'] == $gangdata['gangPRESIDENT']) { ?>· <a href='yourgang.php?action=staff&act2=kickhouse'>Kick the current tenant</a>· <a href='yourgang.php?action=staff&act2=upgradehouse'>Upgrade House</a><? } } function request_gang_house() { global $db, $ir, $gangdata; $select = $db->query(sprintf("SELECT `grrID` FROM `gangRentalRequests` WHERE (`grrUser` = %u)", $ir['userid'])); if($db->num_rows($select)) { cleanKill("You've already applied to move into your gang's house"); } $db->query(sprintf("INSERT INTO `gangRentalRequests` VALUES ('', %u, %u)", $gangdata['gangID'], $ir['userid'])); echo "You've applied to move into your gang's house"; } Find default: gang_staff_idx(); break; Add above case 'viewhousereqs': gang_staff_view_house_requests(); break; case 'decidehousereq': gang_staff_decide_house_request(); break; case 'kickhouse': gang_staff_kick_house(); break; case 'upgradehouse': gang_staff_upgrade_house(); break; Find <br /> <a href='yourgang.php?action=staff&act2=tag'>Change Gang Tag</a> Add below <br /> <a href='yourgang.php?action=staff&act2=viewhousereqs'>View House Requests</a> Find the closing brace of the gang_staff_idx() function Add below function gang_staff_view_house_requests() { global $db, $ir, $gangdata; if($ir['userid'] != $gangdata['gangPRESIDENT']) { cleanKill("You're not the President. You can't do that"); } echo "<h3>House Requests</h3>"; $select = $db->query(sprintf("SELECT `grr`.`grrID`, `grr`.`grrUser`, `u`.`username` " . "FROM `gangRentalRequests` AS `grr` " . "LEFT JOIN `users` AS `u` ON (`u`.`userid` = `grr`.`grrUser`) " . "WHERE (`grr`.`grrGang` = %u) " . "ORDER BY `u`.`username` ASC", $gangdata['gangID'])); ?><table class='table' width='75%' cellspacing='1'> <tr> <th width='50%'>Member</th> <th width='50%'>Links</th> </tr><? if(!$db->num_rows($select)) { ?><tr><td colspan='2' class='center'>There are no requests</td></tr><? } else { while($row = $db->fetch_row($select)) { echo "<tr>"; printf("<td><a href='viewuser.php?u=%u'>%s</a></td>", $row['grrUser'], stripslashes(htmlspecialchars($row['username']))); printf("<td><a href='yourgang.php?action=staff&act2=decidehousereq&ID=%1$u&dir=accept' style='color:#79A888;'>Accept</a> · <a href='yourgang.php?action=staff&act2=decidehousereq&ID=%1$u&dir=decline' style='color:#AF4035;'>Decline</a></td>", $row['grrID']); echo "</tr>"; } } echo "</table>"; } function gang_staff_decide_house_request() { global $db, $ir, $gangdata; if($ir['userid'] != $gangdata['gangPRESIDENT']) { cleanKill("You're not the President. You can't do that"); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; if(empty($_GET['ID'])) { cleanKill("You didn't select a valid request"); } $select = $db->query(sprintf("SELECT `grrUser` FROM `gangRentalRequests` WHEERE ((`grrID` = %u) AND (`grrGang` = %u))", $_GET['ID'], $gangdata['gangID'])); if(!$db->num_rows($select)) { cleanKill("Either that request doesn't exist, or it's not yours"); } $row = $db->fetch_row($select); $_GET['dir'] = isset($_GET['dir']) && ctype_alpha($_GET['dir']) && in_array($_GET['dir'], array('accept', 'decline')) ? strtolower(trim($_GET['dir'])) : null; if(empty($_GET['dir'])) { cleanKill("You didn't specify what to do with this request"); } $selectCurrent = $db->query(sprintf("SELECT `gr`.`grUser`, `u`.`username` " . "FROM `gangRentals` AS `gr` " . "LEFT JOIN `users` AS `u` ON (`gr`.`grUser` = `u`.`username`) " . "WHERE (`gr`.`grGang` = %u)", $gangdata['gangID'])); if($_GET['dir'] == 'accept') { if($db->num_rows($selectCurrent)) { $user = $db->fetch_row($selectCurrent); $db->query(sprintf("DELETE FROM `gangRentals` WHERE (`grGang` = %u)", $gangdata['gangID'])); $db->query(sprintf("UPDATE `users` SET `maxwill` = `oldMaxWill`, `oldMaxWill` = 0 WHERE (`userid` = %u)", $user['grUser'])); event_add($user['grUser'], "You've been kicked from the gang house"); echo stripslashes(htmlspecialchars($user['username']))." has been kicked from the gang house<br />"; } $db->query(sprintf("INSERT INTO `gangRentals` VALUES ('', %u, %u)", $gangdata['gangID'], $row['grrUser'])); $houseWill = $db->fetch_single($db->query(sprintf("SELECT `hWILL` FROM `houses` WHERE (`hID` = %u)", $gangdata['gangHOUSE']))); $db->query(sprintf("UPDATE `users` SET `oldMaxWill` = `maxwill`, `maxwill` = %u WHERE (`userid` = %u)", $houseWill, $row['grrUser'])); } $db->query(sprintf("DELETE FROM `gangRentalRequests` WHERE (`grrID` = %u)", $_GET['ID'])); $what = ($_GET['dir'] == 'accept') ? 'accepted' : 'declined'; event_add($row['grrUser'], "Your request to move in to your gang's house has been ".$what); echo stripslashes(htmlspecialchars($row['username'])),"'s request has been ",$_GET['dir'],$what; } function gang_staff_kick_house() { global $db, $ir, $gangdata; if($ir['userid'] != $gangdata['gangPRESIDENT']) { cleanKill("You're not the President. You can't do that"); } $select = $db->query(sprintf("SELECT `gr`.`grUser`, `u`.username` " . "FROM `gangRentals` AS `gr` " . "LEFT JOIN `users` AS `u` ON (`gr`.`grUser` = `u`.`userid`) " . "WHERE (`gr`.`grGang` = %u)", $gangdata['gangID'])); if(!$db->num_rows($select)) { cleanKill("None of your members are currently using the house"); } $row = $db->fetch_row($select); $db->query(sprintf("DELETE FROM `gangRentals` WHERE (`grGang` = %u)", $gangdata['gangID'])); $db->query(sprintf("UPDATE `users` SET `maxwill` = `oldMaxWill`, `oldMaxWill` = 0 WHERE (`userid` = %u)", $row['grUser'])); event_add($row['grUser'], "You've been kicked from the gang house"); echo "You've kicked <a href='viewuser.php?u=",$row['grUser'],"'>",stripslashes(htmlspecialchars($row['username'])),"</a> from that gang house</a>"; } function gang_staff_upgrade_house() { global $db, $ir, $gangdata; $_GET['house'] = isset($_GET['house']) && ctype_digit($_GET['house']) ? abs(@intval($_GET['house'])) : null; if(empty($_GET['house'])) { $selectCurrentHouse = $db>query(sprintf("SELECT `hNAME` FROM `houses` WHERE (`hID` = %u)", $gangdata['gangID'])); ?>Your gang currently owns the <? echo stripslashes(htmlspecialchars($db->fetch_single($selectCurrentHouse))); ?><br /> <table class='table' width='75%' cellspacing='1'> <tr> <th width='33%'>House/Will</th> <th width='34%'>Price</th> <th width='33%'>Buy</th> </tr><? $selectHouses = $db->query(sprintf("SELECT * FROM `houses` WHERE (`hID` > %u) ORDER BY `hWILL` ASC", $gangdata['gangID'])); if(!$db->num_rows($selectHouses)) { ?><tr><td colspan='3' class='center'>There are currently no upgrades</td></tr><? } else { while($row = $db->fetch_row($selectHouses)) { echo "<tr>"; printf("<td>%s<br />Will: %s</td>", stripslashes(htmlspecialchars($row['hNAME'])), number_format($row['hWILL'])); printf("<td>\$%s</td>", number_format($row['hPRICE'] * 10)); printf("<td><a href='yourgang.php?action=staff&act2=upgradehouse&house=%u'>Buy</a></td>", $row['hID']); echo "</tr>"; } } echo "</table>"; } else { $select = $db->query(sprintf("SELECT `hNAME`, `hPRICE` FROM `houses` WHERE (`hID` = %u)", $_GET['house'])); if(!$db->num_rows($select)) { cleanKill("That house doesn't exist"); } $row = $db->fetch_row($select); $cost = $row['hPRICE'] * 10; if($cost > $gangdata['gangMONEY']) { cleanKill("Your gang's vault doesn't have enough for that"); } $db->query(sprintf("UPDATE `gangs` SET `gangMONEY` = `gangMONEY` - %u, `gangHOUSE` = %u WHERE (`gangID` = %u)", $cost, $_GET['house'], $gangdata['gangID'])); gang_event_add($gangdata['gangID'], "The gang house has been upgraded to the ".stripslashes(htmlspecialchars($row['hNAME']))); echo "You've upgraded the gang house to the ",stripslashes(htmlspecialchars($row['hNAME'])); } }
-
I am indeed in the UK. Nothing with peanuts please xD
-
Gang Kidnap Edit gangs.php Find <th>Days In Gang</th> Add below <th>Links</th> Find case 'applys': gang_applysubmit(); break; Add below case 'kidnap': gang_kidnap(); break Find <td>{$r['daysingang']}</td> Add below <td>",(($gangdata['gangID'] != $ir['gang']) ? "<a href='gangs.php?action=kidnap&ID=".$gangdata['gangID']."&u=".$r['userid']."'>Kidnap</a>" : ''),"</td> Find $h->endpage(); Add above function cleanKill($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong>",$msg; $h->endpage(); exit; } function gang_event_add($gangID, $event) { global $db; $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '%s')", $gangID, time(), $db->escape($event))); } function gang_kidnap() { global $db, $ir, $h, $gangdata; $_GET['u'] = isset($_GET['u']) && ctype_digit($_GET['u']) ? abs(@intval($_GET['u'])) : null; if(empty($_GET['u'])) { cleanKill("You didn't select a valid gang member"); } if(!$ir['gang']) { cleanKill("You're not in a gang, you can't do this"); } if($ir['gang'] == $gangdata['gangID']) { cleanKill("You can't kidnap your own members..."); } $select = $db->query(sprintf("SELECT `gangID` FROM `gangs` WHERE ((`gangPRESIDENT` = %1$u) OR (`gangVICEPRES` = %1$u))", $ir['userid'])); if(!$db->num_rows($select)) { cleanKill("You're not the President or Vice President of your gang. You can't do that"); } if(in_array($_GET['u'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) { cleanKill("You can't kidnap the President or Vice President"); } $select = $db->query(sprintf("SELECT `username`, `gang` FROM `users` WHERE (`userid` = %u)", $_GET['u'])); if(!$db->num_rows($select)) { cleanKill("That player doesn't exist"); } $row = $db->fetch_row($select); if($row['gang'] != $gangdata['gangID']) { cleanKill($row['username']." isn't in that gang"); } $selectRansoms = $db->query(sprintf("SELECT `gkID` FROM `gangKidnaps` WHERE (`gkUser` = %u)", $_GET['u'])); if($db->num_rows($selectRansom)) { cleanKill($row['username']." is already being held ransom"); } if(!isset($_POST['submit'])) { echo "<h3>Kidnapping ",stripslashes(htmlspecialchars($row['username']))," from ",stripslashes(htmlspecialchars($gangdata['gangNAME'])),"</h3>"; ?><form action='gangs.php?action=view&ID=<? echo $gangdata['gangID']; ?>&u=<? echo $_GET['u']; ?>' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Ransom</th> <td width='55%'>$<input type='number' name='ransom' value='2000' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Kidnap' /></td> </tr> </table> </form><? } else { $_POST['ransom'] = isset($_POST['ransom']) && ctype_digit($_POST['ransom']) ? abs(@intval($_POST['ransom'])) : null; if(empty($_POST['ransom'])) { cleanKill("You didn't enter a valid ransom"); } $db->query(sprintf("INSERT INTO `gangKidnaps` VALUES ('', %u, %u, %u, %s, %u)", $ir['gang'], $gangdata['gangID'], $_GET['u'], time(), $_POST['ransom'])); gang_event_add($gangdata['gangID'], sprintf("<a href='viewuser.php?u=%u'>%s</a> has kidnapped <a href='viewuser.php?u=%u'>%s</a> from %s. You have 1 hour to pay the ransom", $ir['userid'], stripslashes(htmlspecialchars($ir['username'])), $_GET['u'], stripslashes(htmlspecialchars($row['username'])), stripslashes(htmlspecialchars($gangdata['gangNAME'])))); gang_event_add($ir['gang'], sprintf("<a href='viewuser.php?u=%u'>%s</a> has kidnapped <a href='viewuser.php?u=%u'>%s</a> from %s. They have 1 hour to pay the ransom", $ir['userid'], stripslashes(htmlspecialchars($ir['username'])), $_GET['u'], stripslashes(htmlspecialchars($row['username'])), stripslashes(htmlspecialchars($gangdata['gangNAME'])))); echo "You've kidnapped ",stripslashes(htmlspecialchars($row['username']))," from ",stripslashes(htmlspecialchars($gangdata['gangNAME'])); } } Edit yourgang.php Find (at the bottom of the file) if ($db->fetch_single($wq) > 0) { echo " <h3> <a href='yourgang.php?action=warview'> <span style='color: red;'>Your gang is currently in " . $db->fetch_single($wq) . " war(s).</span> </a> </h3> "; } Add below $select = $db->query(sprintf("SELECT `gkUser` FROM `gangKidnaps` WHERE (`gkGangKidnapped` = %u)", $gangdata['gangID'])); if($db->num_rows($select)) { echo "<h3><a href='yourgang.php?action=viewkidnap' style='color: red;'>",$db->num_rows($select)," member",(($db->num_rows($select) == 1) ? ' has' : 's have')," been kidnapped</a></h3>"; } Find case "crimes": gang_crimes(); break; Add case 'viewkidnaps': gang_view_kidnaps(); break; Find function gang_crimes() { global $gangdata; if ($gangdata['gangCRIME'] > 0) { echo "This is the crime your gang is planning at the moment.<br /> <b>Crime:</b> {$gangdata['ocNAME']}<br /> <b>Hours Left:</b> {$gangdata['gangCHOURS']}"; } else { echo "Your gang is not currently planning a crime."; } } Add below function viewKidnaps() { global $db; ?><h3>Members kidnapped from your gang</h3><? $select = $db->query(sprintf("SELECT `gk`.`gkGangKidnapper`, `gk`.`gkTime`, `gk`.`gkUser`, `g`.`gangNAME`, `u`.`username` FROM `gangKidnaps` AS `gk` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `gk`.`gkGangKidnapper`) " . "LEFT JOIN `users` AS `u` ON (`u`.userid` = `gk`.`gkUser`) " . "WHERE (`gk`.`gkGangKidnapped` = %u) " . "ORDER BY `gk`.`gkTime` ASC", $gangdata['gangID'])); $width = in_array($ir['userid'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES'])) ? '20' : '25'; ?><table class='table' width='75%' cellspacing='1'> <tr> <th width='<? echo $width; ?>%'>Kidnapper</th> <th width='<? echo $width; ?>%'>Member</th> <th width='<? echo $width; ?>%'>Ransom</th> <th width='<? echo $width; ?>%'>Time Left</th><? if(in_array($ir['userid'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) { ?><th width='20%'>Links</th><? } ?></tr><? if(!$db->num_rows($select)) { ?><tr><td colspan='4' class='center'>Good news! No-one has been kidnapped from <? echo stripslashes(htmlspecialchars($gangdata['gangNAME'])); ?> ... yet!</td></tr><? } else { while($row = $db->fetch_row($select)) { echo "<tr>"; printf("<td><a href='gangs.php?action=view&ID=%u'>%s</a></td>", $row['gkGangKidnapper'], stripslashes(htmlspecialchars($row['gangNAME']))); printf("<td><a href='viewuser.php?u=%u'>%s</a></td>", $row['gkUser'], stripslashes(htmlspecialchars($row['username']))); printf("<td>\$%s</td>", number_format($row['gkRansom'])); printf("<td>%s</td>", time2readable(time() - ($row['gkTime'] + 3600))); if(in_array($ir['userid'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) { printf("<td><a href='yourgang.php?action=staff&act2=pay&u=%u'>Pay</a></td>", $row['gkUser']); } echo "</tr>"; } } ?></table><? } Find case "masspayment": gang_staff_masspayment(); break; Add below case 'payransom': case "masspayment": gang_staff_payransom(); break; Find the closing brace of the gang_staff_idx() function Add below function gang_staff_payransom() { global $db, $ir, $gangdata; if(!in_array($ir['userid'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) { cleanKill("You're not the President or Vice President. You can't do that"); } $_GET['u'] = isset($_GET['u']) && ctype_digit($_GET['u']) ? abs(@intval($_GET['u'])) : null; if(empty($_GET['u'])) { cleanKill("You didn't select a valid ransom to pay"); } $select = $db->query(sprintf("SELECT `gk`.`gkRansom`, `gk`.`gkGangKidnapper`, `g`.`gangID`, `g`.`gangNAME`, `u`.`username` " . "FROM `gangKidnaps` AS `gk` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `gk`.`gkGangKidnapper`) " . "LEFT JOIN `users` AS `u` ON (`u`.`userid` = `gk`.`gkUser`) " . "WHERE ((`gkUser` = %u) AND (`gkGangKidnapped` = %u))", $_GET['u'], $gangdata['gangID'])); if(!$db->num_rows($select)) { cleanKill("That player hasn't been kidnapped"); } $row = $db->fetch_row($select); echo "<h3>Paying a ransom</h3>"; if(!isset($_GET['ans'])) { ?>The ransom stands at $<? echo number_format($row['gkRansom']); ?> to save <a href='viewuser.php?u=<? echo $_GET['u']; ?>'><? echo stripslashes(htmlspecialchars($row['username'])); ?></a> from <a href='gangs.php?action=view&ID=<? echo $row['gangID']; ?>'><? echo stripslashes(htmlspecialchars($row['gangNAME'])); ?></a><br /> If you choose to pay this, it will come from the gang vault<br /> Pay the ransom?<br /> <a href='yourgang.php?action=staff&act2=payransom&u=<? echo $_GET['u']; ?>&ans=yes'>Yes</a> · <a href='yourgang.php'>No</a><? } else { if($gangdata['gangMONEY'] < $row['gkRansom']) { cleanKill("You don't have enough in the gang vault to pay the ransom"); } $db->query(sprintf("DELETE FROM `gangKidnaps` WHERE (`gkUser` = %u)", $_GET['u'])); gang_event_add($gangdata['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> have paid the ransom demand for <a href='viewuser.php?u=%u'>%s</a>", $gangdata['gangID'], stripslashes(htmlspecialchars($gangdata['gangNAME'])), $_GET['u'], stripslashes(htmlspecialchars($row['username'])))); gang_event_add($row['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> have paid the ransom demand for <a href='viewuser.php?u=%u'>%s</a>", $gangdata['gangID'], stripslashes(htmlspecialchars($gangdata['gangNAME'])), $_GET['u'], stripslashes(htmlspecialchars($row['username'])))); echo "You've paid the \$",number_format($row['gkRansom'])," ransom and <a href='viewuser.php?u=",$_GET['u'],"'>",stripslashes(htmlspecialchars($row['username'])),"</a> has returned safely"; } } Edit header.php Find function menuarea() { Add above function time2readable($ss) { $s = $ss % 60; $m = floor(($ss % 3600) / 60); $h = floor(($ss % 86400) / 3600); $d = floor(($ss % 2592000) / 86400); $Mo = floor(($ss % 31536000) / 2592000); $y = floor($ss / 31536000); $ret = ""; $ret .= $y ? $y . " year" . $this->s($y) . " " : ''; $ret .= $Mo ? $Mo . " month" . $this->s($Mo) . " " : ''; $ret .= $d ? $d . " day" . $this->s($d) . " " : ''; $ret .= $h ? $h . " hour" . $this->s($h) . " " : ''; $ret .= $m ? $m . " minute" . $this->s($m) . " " : ''; $ret .= $s ? $s . " second" . $this->s($s) : ''; $face = $ss ? $ret : 'no time'; return $face; } Find in the menuarea() function global $ir, $c; Change to global $db, $ir, $c; Find if ($ir['jail']) { echo "<b>NB:</b> You are currently in jail for {$ir['jail']} minutes.<br />"; } Add below $select = $db->query(sprintf("SELECT `gk`.`gkGangKidnapper`, `gk`.`gkTime`, `g1`.`gangNAME` AS `kidnapper`, `g2`.`gangNAME` AS `kidnapped`" . "FROM `gangKidnaps` AS `gk` " . "LEFT JOIN `gangs` AS `g1` ON (`g1`.`gangID` = `gk`.`gkGangKidnapper`) " . "LEFT JOIN `gangs` AS `g2` ON (`g2`.`gangID` = `gk`.`gkGangKidnapped`) " . "WHERE (`gk`.`gkUser` = %u) ", $ir['userid'])); if($db->num_rows($select)) { $row = $db->fetch_row($select); printf("<strong>NB:</strong> You're currently being held ransom by <a href='gangs.php?action=view&ID=%u'>%s</a><br />Your gang has %s left to pay.<br />", $row['gkGangKidnapper'], stripslashes(htmlspecialchars($row['kidnapper'])), $this->time2readable(time() - ($row['gkTime'] + 3600))); if(($row['gkTime'] + 3600) >= time()) { $db->query(sprintf("UPDATE `users` SET `hospital` = %u, `new_events` = `new_events` + 1 WHERE (`userid` = %u)", mt_rand(30, 60), $ir['userid'])); $db->query(sprintf("DELETE FROM `gangKidnaps` WHERE (`gkUser` = %u)", $ir['userid'])); $db->query(sprintf("INSERT INTO `events` VALUES ('', %u, %s, 0, 'Your gang failed pay your ransom in time. You were beaten and hospitalized by your kidnappers')", $ir['userid'], time())); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '<a href=\'gangs.php?action=view&ID=%s\'>%s</a> failed to pay %s\'s ransom')", $ir['gang'], time(), $ir['gang'], $row['kidnapped'], $ir['username'])); $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '<a href=\'gangs.php?action=view&ID=%s\'>%s</a> failed to pay %s\'s ransom')", $row['gkGangKidnapper'], time(), $ir['gang'], $row['kidnapped'], $ir['username'])); } } SQLs CREATE TABLE `gangKidnaps` ( `gkID` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT, `gkGangKidnapper` INT( 11 ) NOT NULL DEFAULT 0, `gkGangKidnapped`INT( 11 ) NOT NULL DEFAULT 0, `gkUser` INT( 11 ) NOT NULL DEFAULT 0, `gkTime` INT( 11 ) NOT NULL DEFAULT 0, `gkRansom` INT( 11 ) NOT NULL DEFAULT 0 );
-
Well, I won't say no ^.^ [email protected]
-
I like sprintf(), it works perfectly for what I need it to do :P
-
Edit yourgang.php Find case "masspayment": gang_staff_masspayment(); break; Add below case 'delete': gang_staff_delete(); break; Find <br /> <a href='yourgang.php?action=staff&act2=tag'>Change Gang Tag</a> Add below <br /> <a href='yourgang.php?action=staff&act2=delete'>Disband Gang</a> Find the closing brace at the end of the gang_staff_apps() function Add below function gang_staff_delete() { global $db, $ir, $gangdata; if($gangdata['gangPRESIDENT'] != $ir['userid']) { echo "You don't have access to this"; $h->endpage(); exit; } if(!isset($_GET['ans'])) { ?>Once you have disbanded your gang, that's it. This can <strong>not</strong> be reversed<br /> Are you sure you want to do this?<br /> <a href='yourgang.php?action=staff&act2=delete&ans=yes'>Yes</a> · <a href='yourgang.php'>No</a><? } else { $select = $db->query(sprintf("SELECT `userid` FROM `users` WHERE (`gang` = %u)", $gangdata['gangID'])); while($row = $db->fetch_row($select)) { event_add($row['userid'], "Your gang has been disbanded"); } $db->query(sprintf("UPDATE `users` SET `gang` = 0 WHERE (`gang` = %u)", $gangdata['gangID'])); $db->query(sprintf("DELETE FROM `gangs` WHERE (`gangID` = %u)", $gangdata['gangID'])); $db->query(sprintf("DELETE FROM `gangwars` WHERE ((`warDECLARED = %u) OR (`warDECLARER` = %u))", $gangdata['gangID'], $gangdata['gangID'])); $db->query(sprintf("DELETE FROM `gangevents` WHERE (`gevGANG` = %u)", $gangdata['gangID'])); echo "Your gang has been disbanded.<br /><a href='index.php'>Home</a>"; } }