Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,142
  • Joined

  • Last visited

  • Days Won

    148

Everything posted by Magictallguy

  1. Gang Alliance Edit yourgang.php, add to the bottom (above the endpage..) function gang_event_add($gangID, $event) { global $db; $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '%s')", $gangID, time(), $db->escape($event))); } function output($str, $dec = 0) { return is_numeric($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } 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; } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; function gang_staff_alliance_request() { global $db, $gangdata; if(!isset($_POST['submit'])) { ?><h3>Request an Alliance</h3> <form action='yourgang.php?action=staff&act2=alliancer' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Gang</th> <td width='55%'><select name='gang' type='dropdown'><? $pikachu = $db->query(sprintf("SELECT `gangID`, `gangNAME` FROM `gangs` WHERE (`gangID` != %u)", $gangdata['gangID'])); if(!$db->num_rows($pikachu)) { echo "<option value='0'>There are no gangs</option>"; } else { while($yellow = $db->fetch_row($pikachu)) { printf("<option value='%u'>%s</option>", $yellow['gangID'], output($yellow['gangNAME'])); } } ?></select></td> </tr> <tr> <th>Message</th> <td><textarea name='message' rows='10' cols='70' placeholder='Enter a reason as to why you want to become allies'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Request Alliance' /></td> </tr> </table> </form><? } else { $_POST['gang'] = isset($_POST['gang']) && ctype_digit($_POST['gang']) ? abs(@intval($_POST['gang'])) : null; $_POST['message'] = isset($_POST['message']) && is_string($_POST['message']) ? trim($_POST['message']) : null; if(empty($_POST['gang'])) { cleanKill("You didn't select a valid gang"); } if(empty($_POST['message'])) { cleanKill("You didn't enter a valid message"); } $blue = $db->query(sprintf("SELECT `gangID`, `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $_POST['gang'])); if(!$db->num_rows($blue)) { cleanKill("That gang doesn't exist"); } $row = $db->fetch_row($blue); $froob = $db->query(sprintf("SELECT `gaID` FROM `gangAlliances` WHERE (((`gaGuild1` = %u) AND (`gaGuild2` = %u)) OR ((`gaGuild2` = %u) AND (`gaGuild1` = %u)))", $_POST['gang'], $gangdata['gangID'], $_POST['gang'], $gangdata['gangID'])); if($db->num_rows($froob)) { cleanKill("You're already allied with ".output($row['gangNAME'])); } if($_POST['gang'] == $gangdata['gangID']) { cleanKill("You can't ally with yourself!"); } $selectRequest = $db->query(sprintf("SELECT `garID` FROM `gangAllianceRequests` WHERE (((`garGuildFrom` = %u) AND (`garGuildTo` = %u)) OR ((`garGuildTo` = %u) AND (`garGuildFrom` = %u)))", $_POST['gang'], $gangdata['gangID'], $_POST['gang'], $gangdata['gangID'])); if($db->num_rows($selectRequest)) { cleanKill("You've already sent an alliance request"); } $db->query(sprintf("INSERT INTO `gangAllianceRequests` VALUES ('', %s, %u, %u, '%s')", time(), $gangdata['gangID'], $_POST['gang'], $db->input($_POST['message']))); gang_event_add($gangdata['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has sent an alliance request to <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $_POST['gang'], $row['gangNAME'])); gang_event_add($_POST['gang'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has sent an alliance request to <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $_POST['gang'], $row['gangNAME'])); echo "You've requested to become allied with ".output($row['gangNAME']); } } function gang_staff_alliance_decide() { global $db, $gangdata; if(empty($_GET['ID'])) { cleanKill("You didn't select a valid alliance request to decide on"); } $select = $db->query(sprintf("SELECT `gar`.*, `g`.`gangID`, `g`.`gangNAME` FROM `gangAllianceRequests` AS `gar` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `gar`.`garGuildFrom`) " . "WHERE ((`gar`.`garGuildTo` = %u) AND (`gar`.`garID` = %u)) LIMIT 1", $gangdata['gangID'], $_GET['ID'])); if(!$db->num_rows($select)) { cleanKill("That request doesn't exist"); } $_GET['what'] = isset($_GET['what']) && ctype_alpha($_GET['what']) && in_array($_GET['what'], array('accept', 'decline')) ? strtolower(trim($_GET['what'])) : null; if(empty($_GET['what'])) { cleanKill("You didn't select a valid decision"); } $req = $db->fetch_row($select); if($_GET['what'] == 'accept') { $db->query(sprintf("INSERT INTO `gangAlliances` VALUES ('', %u, %u)", $gangdata['gangID'], $req['gangID'])); $db->query(sprintf("DELETE FROM `gangAllianceRequests` WHERE (`garID` = %u)", $_GET['ID'])); gang_event_add($gangdata['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has accepted the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $req['gangID'], $req['gangNAME'])); gang_event_add($req['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has accepted the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $req['gangID'], $req['gangNAME'])); echo (sprintf("You've accepted the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $req['gangID'], output($req['gangNAME']))); } else { $db->query(sprintf("DELETE FROM `gangAllianceRequests` WHERE (`garID` = %u)", $_GET['ID'])); gang_event_add($gangdata['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> have declined the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $req['gangID'], $req['gangNAME'])); gang_event_add($req['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> have declined the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], $gangdata['gangNAME'], $req['gangID'], $req['gangNAME'])); printf("You've declined the alliance request from <a href='gangs.php?action=view&ID=%u'>%s</a>", $req['gangID'], output($req['gangNAME'])); } } function gang_staff_alliance_break() { global $db, $gangdata; if(!isset($_POST['submit'])) { ?><h3>Break an Alliance</h3> <form action='yourgang.php?action=staff&act2=allianceb' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Gang</th> <td width='55%'><select name='alliance' type='dropdown'><? $pikachu = $db->query(sprintf("SELECT `gi`.`gaID`, `g`.`gangID`, `g`.`gangNAME` FROM `gangAlliances` AS `gi` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `gi`.`gaGuild2`) " . "WHERE ((`gi`.`gaGuild1` = %u) OR (`gi`.`gaGuild2` = %u))", $gangdata['gangID'], $gangdata['gangID'])); if(!$db->num_rows($pikachu)) { echo "<option value='0'>You have no allies</option>"; } else { while($yellow = $db->fetch_row($pikachu)) { if($_GET['ID']) { if($_GET['ID'] == $yellow['gaID']) { printf("<option value='%u' selected='selected'>%s</option>", $yellow['gaID'], output($yellow['gangNAME'])); } } else { printf("<option value='%u'>%s</option>", $yellow['gaID'], output($yellow['gangNAME'])); } } } ?></select></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Break Alliance' /></td> </tr> </table> </form><? } else { $_POST['alliance'] = isset($_POST['alliance']) && ctype_digit($_POST['alliance']) ? abs(@intval($_POST['alliance'])) : null; if(empty($_POST['alliance'])) { cleanKill("You didn't select a valid Alliance"); } $blue = $db->query(sprintf("SELECT `ga`.`gaID`, `g`.`gangID`, `g`.`gangNAME` FROM `gangAlliances` AS `ga` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `ga`.`gaGuild2`) " . "WHERE ((`ga`.`gaID` = %u) AND ((`ga`.`gaGuild1` = %u) OR (`ga`.`gaGuild2` = %u)))", $_POST['alliance'], $gangdata['gangID'], $gangdata['gangID'])); if(!$db->num_rows($blue)) { cleanKill("Either that alliance doesn't exist, or it's not yours!"); } $row = $db->fetch_row($blue); $db->query(sprintf("DELETE FROM `gangAlliances` WHERE (`gaID` = %u)", $_POST['alliance'])); gang_event_add($gangdata['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has broken the alliance with <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], output($gangdata['gangNAME']), $row['gangID'], output($row['gangNAME']))); gang_event_add($row['gangID'], sprintf("<a href='gangs.php?action=view&ID=%u'>%s</a> has broken the alliance with <a href='gangs.php?action=view&ID=%u'>%s</a>", $gangdata['gangID'], output($gangdata['gangNAME']), $row['gangID'], output($row['gangNAME']))); echo "You have broken the alliance"; } } function gang_staff_alliance_view() { global $db, $gangdata; ?><table class='table' width='75%' cellspacing='1'> <tr> <th width='80%'>Gang</th> <th width='20%'>Action</th> </tr><? $pikachu = $db->query(sprintf("SELECT `ga`.*, `g`.`gangID`, `g`.`gangNAME` FROM `gangAlliances` AS `ga` " . "LEFT JOIN `gangs` AS `g` ON (`g`.`gangID` = `ga`.`gaGuild2`) " . "WHERE ((`ga`.`gaGuild1` = %u) OR (`ga`.`gaGuild2` = %u))", $gangdata['gangID'], $gangdata['gangID'])); if(!$db->num_rows($pikachu)) { echo "<tr><td colspan='2' class='center'>You don't have any Allies</td></tr>"; } else { while($yellow = $db->fetch_row($pikachu)) { echo "<tr>"; printf("<td><a href='gangs.php?action=view&ID=%u'>%s</a></td>", $yellow['gaGuild2'], output($yellow['gangNAME'])); 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']); echo "</tr>"; } } echo "</table><br /><br />"; ?><h3>Alliance Requests</h3> <table class='table' width='75%' cellspacing='1'> <tr> <th width='40%'>Gang</th> <th width='40%'>Message</th> <th width='20%'>Links</th> </tr><? $froob = $db->query(sprintf("SELECT `gar`.*, `g`.`gangID`, `g`.`gangNAME` FROM `gangAllianceRequests` AS `gar` " . "LEFT JOIN `gangs` AS `g` ON (`gar`.`garGuildFrom` = `g`.`gangID`) " . "WHERE (`gar`.`garGuildTo` = %u) ORDER BY `gar`.`garTime` ASC", $gangdata['gangID'])); if(!$db->num_rows($froob)) { echo "<tr><td colspan='3' class='center'>You don't have any alliance requests</td></tr>"; } else { while($blue = $db->fetch_row($froob)) { echo "<tr>"; printf("<td><a href='gangs.php?action=view&ID=%u'>%s</a></td>", $blue['gangID'], output($blue['gangNAME'])); printf("<td>%s</td>", output($blue['garMessage'])); printf("<td><a href='yourgang.php?action=staff&act2=alliancea&ID=%u&what=accept'><img src='/silk/accept.png' title='Accept this request' alt='Accept' /></a> · <a href='yourgang.php?action=staff&act2=alliancea&ID=%u&what=decline'><img src='/silk/delete.png' title='Decline this request' alt='Decline' /></a></td>", $blue['garID'], $blue['garID']); echo "</tr>"; } } echo "</table>"; }   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(sprintf("SELECT `gaID` FROM `guildAlliances` WHERE (((`gaGuild1` = %u) AND (`gaGuild2` = %u)) OR ((`gaGuild1` = %u) AND (`gaGuild2` = %u)))", $gangdata['gangID'], $_POST['gang'], $_POST['gang'], $gangdata['gangID'])); if($db->num_rows($selectGangAlliance)) { echo "Your gang is currently allied with that gang. You can't attack them<br />> <a href='yourgang.php?action=staff&act2=declare'>Go back</a>"; $h->endpage(); exit; }   Still in gang_staff_wardeclare() Find $db->query( "INSERT INTO `gangwars` VALUES(NULL, {$gangdata['gangID']}, {$_POST['gang']}, " . time() . ")"); Add above $selectAllies1 = $db->query(sprintf("SELECT `gaGuild2` FROM `guildAlliances` WHERE (`gaGuild1` = %u)", $_POST['gang'])); if($db->num_rows($selectAllies1)) { while($row = $db->fetch_row($selectAllies1)) { $db->query(sprintf("INSERT INTO `gangwars` VALUES ('', %u, %u, %s)", $gangdata['gangID'], $db->fetch_single($selectAllies1), time())); } } $selectAllies2 = $db->query(sprintf("SELECT `gaGuild1` FROM `guildAlliances` WHERE (`gaGuild2` = %u)", $_POST['gang'])); if($db->num_rows($selectAllies2)) { while($row = $db->fetch_row($selectAllies2)) { $db->query(sprintf("INSERT INTO `gangwars` VALUES ('', %u, %u, %s)", $gangdata['gangID'], $db->fetch_single($selectAllies2), time())); } }   Add the gang staff cases case 'alliancer': guild_staff_alliance_request(); break; case 'alliancea': guild_staff_alliance_decide(); break; case 'alliancev': guild_staff_alliance_view(); break; case 'allianceb': guild_staff_alliance_break(); break;   SQLs CREATE TABLE `guildAllianceRequests` ( `garID` int(11) NOT NULL auto_increment, `garTime` int(11) NOT NULL default '0', `garGuildFrom` int(11) NOT NULL default '0', `garGuildTo` int(11) NOT NULL default '0', `garMessage` text NOT NULL, PRIMARY KEY (`garID`) ); CREATE TABLE `guildAlliances` ( `gaID` int(11) NOT NULL auto_increment, `gaGuild1` int(11) NOT NULL default '0', `gaGuild2` int(11) 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']) { $selectGangAlliance = $db->query(sprintf("SELECT `gaID` FROM `guildAlliances` WHERE (((`gaGuild1` = %u) AND (`gaGuild2` = %u)) OR ((`gaGuild1` = %u) AND (`gaGuild2` = %u)))", $ir['gang'], $odata['gang'], $odata['gang'], $ir['gang'])); if($db->num_rows($selectGangAlliance)) { echo "Your gang is currently allied with ",$odata['username'],"'s gang. You can't attack ",(($odata['gender'] == 'Male') ? 'him' : 'her'); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; $h->endpage(); exit; } }
  2. Staff Gang Delete Add the following code into staff_gangs.php case 'gdelete': admin_gang_delete(); break   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><br />",$msg; $h->endpage(); exit; } function admin_gang_delete() { global $db, $ir, $h; if($ir['user_level'] != 2) { cleanKill("You can't do that"); } echo "<h3>Gang Management: Dleteion</h3>"; $select = $db->query("SELECT `gangID`, `gangNAME` FROM `gangs` ORDER BY `gangNAME` ASC"); if(!$db->num_rows($select)) { cleanKill("There are no gangs to delete"); } if(!isset($_POST['submit'])) { ?><form action='staff_gangs.php?action=gdelete' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Gang</th> <td width='55%'><select name='gang' type='dropdown'><? while($row = $db->fetch_row($select)) { printf("<option value='%u'>%s</option>", $row['gangID'], stripslashes(htmlspecialchars($row['gangNAME']))); } ?></select></td> </tr> <tr> <th>Reason</th> <td><input type='text' name='reason' size='40' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Delete the selected gang' /></td> </tr> </table> </form><? } else { $_POST['gang'] = isset($_POST['gang']) && ctype_digit($_POST['gang']) ? abs(intval($_POST['gang'])) : null; $_POST['reason'] = isset($_POST['reason']) && is_string($_POST['reason']) ? trim($_POST['gang']) : null; if(empty($_POST['gang'])) { cleanKill("You didn't select a valid gang"); } if(empty($_POST['reason'])) { cleanKill("You didn't enter a valid reason"); } $select = $db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE (`gangID` = %u)", $_POST['gang'])); if(!$db->num_rows($select)) { cleanKill("That gang doesn't exist"); } $db->query(sprintf("UPDATE `users` SET `gang` = 0 WHERE (`gang` = %u)", $_POST['gang'])); $db->query(sprintf("DELETE FROM `gangs` WHERE (`gangID` = %u)", $_POST['gang'])); $db->query(sprintf("DELETE FROM `gangwars` WHERE ((`warDECLARED = %u) OR (`warDECLARER` = %u))", $_POST['gang'], $_POST['gang'])); $db->query(sprintf("DELETE FROM `gangevents` WHERE (`gevGANG` = %u)", $_POST['gang'])); stafflog_add(sprintf("Deleted the gang named “%s” with the reason: %s", $db->fetch_single($select), $db->escape($_POST['reason']))); printf("You've deleted the gang “%s”", stripslashes(htmlspecialchars($db->fetch_single($select)))); } }   Add your link to the staff menu (smenu.php by default) staff_gangs.php?action=gdelete
  3. That is a brilliant set of ideas, I'll get straight on it! NOTE: These codes are testing for parse errors only. Any further errors are *not* tested. Please post any bugs here
  4. I'm happy to do anything. If it's for anything but MC Craps, then I'll need around an hour to familiarize myself with the engine - but I'm still happy to do so :)   Thanks DJK :)
  5. Specifics please :)   Same again, specifics please :)
  6. Haha, spaz :P Thanks :D I AM TEH HOLY SOCKNESS!
  7. I'm bored and itching for something to do? Who wants some free code for lite, v1 or v2? All requested mods (and more) can be found on my site (with URLs linking back to the MWG mirror) http://magictallguy.tk/mods.php
  8. Dot.tk completely free :) yourdomain.tk (http://magictallguy.tk - for example)
  9. Bringing us back on topic.. I'd be happy to run a new forum with the old favourites.. Or staff this one and sort it out. What do you guys think?
  10. I did, but I was forced into that.. Read here for more information about that.. I "fixed up the HTML"? I really don't think so. My HTML, even back then, was much better than that...
  11. Updated SQL - seeing as Script forgot to :P CREATE TABLE `breports` ( `id` INT AUTO_INCREMENT PRIMARY KEY NOT NULL, `title` VARCHAR( 25 ), `bugtype` VARCHAR( 25 ), `bugdetail` VARCHAR( 255 ), `bstatus` INT( 11 ) NOT NULL DEFAULT 1, `buser` INT( 11 ) NOT NULL DEFAULT 0 );
  12. Welcome to MWG!
  13. I can confirm that Sim is an excellent developer, and would definitely recommend him :)
  14. For the most part, all I need to do is flick a switch and it's on ;)
  15. Ah, I misunderstood you then. Yes, I did use MC Craps as a template. I don't have much of an imagination, so that worked for me. I'm shortly going to be implementing a brand new system - I'm just allowing people to get used to the feel of the game as it is.
  16. Oh wow, I'd completely forgotten about that! May recreate it, may not lol
  17. Well, don't copy me then haha
  18. I've recoded MC Craps in its' entirety. Now, there's not a shred of Crap anywhere on Ageless Chaos. I've also said multiple times throughout the forum that I'm absolute sh*te when it comes to layouts, so I stuck with what I know - whilst the layout is *similar* to MC Craps, it is most definitely not MC Craps. I will provide code snippets upon request
  19. That's due to this server's lack of decent HTML version lol. It validates perfectly for HTML5
  20. Crimes are currently undergoing a brand new system (one I've never personally seen before). Simply said, they're not ready yet, but everything else is. You can break yourself out of jail.
  21. Damn moving servers! Haha, fixed, thanks :)
  22. After 2 months of virtually non-stop development, Ageless Chaos is now ready to be played. Advance through the ages, unlock new technologies, visit the eras from the Ice Age to the Space Age - Ageless Chaos is a text-based RPG, rated PG15. It is powered by entirely my own code, and runs like a dream! Daily updates (be it server-side, or client-side), and plenty of new content (which currently on 9 pieces of paper taped together with masking tape!) up and coming, this is a fun game to play.   Please keep in mind that it was released today (22/04/2013), so the amount of players is, naturally, low. There's still plenty for you to do.   -- To the developers: This is a real time game that is not cron based.
  23. Edit line 30 in send.php Change $userid to ".$db->escape($ir['username'])."
  24. Oi! My code practise works, and it works well! :P
  25. Hooray! Another script kiddie! Yay!!!! *dances with such joy, it makes him die inside*
×
×
  • Create New...