Jump to content
MakeWebGames

[ v1 ] [ v2 ] Need code?


Recommended Posts

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

Could use a v2 car mod?

Specifics please :)

 

Depends how much time you have. The "mccodes free" admin panel (now called New_staff.php) needs to be removed and completely reworked. I should worn you it may simply give you something to do rather then stop you being bored.

Same again, specifics please :)

Link to comment
Share on other sites

Same again, specifics please :)

Honestly I'm just going to suggest you look. I'm sure you can pick something out of the mess.

I would also ask if you're only willing to do Mccodes mods? NWE has had several mod requests over the last few days, and would give you something new to try out.

http://makewebgames.io/forumdisplay.php/398-Free-Modules-%28Requests-or-Offers%29

Link to comment
Share on other sites

Honestly I'm just going to suggest you look. I'm sure you can pick something out of the mess.

I would also ask if you're only willing to do Mccodes mods? NWE has had several mod requests over the last few days, and would give you something new to try out.

http://makewebgames.io/forumdisplay.php/398-Free-Modules-%28Requests-or-Offers%29

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 :)

Link to comment
Share on other sites

I'm bored and itching for something to do? Who wants some free code for lite, v1 or v2?

Afternoon,

What a generous offer!!

I was looking at an advanced gang system. I have seen dribs and drabs of things but all very buggy and exploitable.

My ideas are:

A gang house; when a gang is started the gang also starts with a default house which all members of the gang can train in. The house can of course be sold and upgraded.

An armoury; a gang armoury that works would be great. So weapons can be loaned and 'summoned' back by leader. Armour would be nice in this as well

Delete gang function: as far as I know v2 doesn't come with a gang delete option would be great if it can be added on

Allies: if 2 gangs decide to be allies then they cannot war each other for set amount of days. Or have it so if they are allies when one goes to war their allie automatically starts war with the 3rd gang

Kidnap: seen this before but again buggy. A gang can kidnap a random member of another gang. The user is then frozen out of the game for say an hour unless the ransom is paid. If it is not paid then the user goes to hospital

All this would be great in v2 and would DEFINATLY give the gang system a spicing up!!

Thanks

Ben

Link to comment
Share on other sites

Afternoon,

What a generous offer!!

I was looking at an advanced gang system. I have seen dribs and drabs of things but all very buggy and exploitable.

My ideas are:

A gang house; when a gang is started the gang also starts with a default house which all members of the gang can train in. The house can of course be sold and upgraded.

An armoury; a gang armoury that works would be great. So weapons can be loaned and 'summoned' back by leader. Armour would be nice in this as well

Delete gang function: as far as I know v2 doesn't come with a gang delete option would be great if it can be added on

Allies: if 2 gangs decide to be allies then they cannot war each other for set amount of days. Or have it so if they are allies when one goes to war their allie automatically starts war with the 3rd gang

Kidnap: seen this before but again buggy. A gang can kidnap a random member of another gang. The user is then frozen out of the game for say an hour unless the ransom is paid. If it is not paid then the user goes to hospital

All this would be great in v2 and would DEFINATLY give the gang system a spicing up!!

Thanks

Ben

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

Edited by Magictallguy
Added "note"
Link to comment
Share on other sites

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

Edited by Magictallguy
Fixed the code tags - they no longer allow attributes -.-
Link to comment
Share on other sites

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

 

Wow very quick start thank you!!

Everything you complete I will add on my game ASAP. Whilst you have done the above code would it be quick to create it so the user can actually delete their gang if they wanted as now they are stuck as they HAVE to transfer the gang to someone else before they can leave.

Link to comment
Share on other sites

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;
}
}
Link to comment
Share on other sites

Wow very quick start thank you!!

Everything you complete I will add on my game ASAP. Whilst you have done the above code would it be quick to create it so the user can actually delete their gang if they wanted as now they are stuck as they HAVE to transfer the gang to someone else before they can leave.

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>";
}
}
Link to comment
Share on other sites

I like sprintf(), it works perfectly for what I need it to do :P

Thanks a bunch mate

What's your PayPal?

I will throw a small amount of cash your way just for your efforts when you finish the other couple of requests

And above is right there is still a community here!!!

Thanks again look forward to seeing the other 2

Will add them to my game tonight and have a play around

Thanks again

Link to comment
Share on other sites

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
);
Edited by Magictallguy
Added SQL
Link to comment
Share on other sites

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']));
}
}
Edited by Magictallguy
Added SQLs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...