Jump to content
MakeWebGames

Marriage Mod Help


Llight
 Share

Recommended Posts

i am using the marriage mod by sniko

but i want to make is so users can share will from there property with who there married to how do i go about doing this? here is my code

<?php

include_once('globals.php');

// global variable - see if they are married or have a pending proposal
$married = ($ir['propose_to'] > 0 OR $ir['married_to'] > 0 OR $ir['propose_from'] > 0) ? TRUE : FALSE;

function links($hide)
{
	global $modName;
	$hide = ($hide != "hide") ? "FALSE" : "hide";
	if($hide == "hide")
		{
	echo "<br />
	      [<a href='explore.php'>Back to City</a>]
		  	<br />
		  [<a href='index.php'>Back Home</a>]";
		}
	else
		{
	echo "<br />
	      [<a href='?action=index'>Back to {$modName}</a>]
			<br />
		  [<a href='explore.php'>Back to City</a>]
		  	<br />
		  [<a href='index.php'>Back Home</a>]";
	  	}
}

if(!$_GET)
{
	return index();
}


switch($_GET['action'])
{
	case 'viewInventory' : viewInventory(); break;
	case 'sendCrystals' : sendCrystals(); break;
	case 'sendBank' : sendBank(); break;
	case 'sendMoney' : sendMoney(); break;

	case 'divorce' : divorce(); break;
	case 'stats' : stats(); break;
	case 'more' : more(); break;

	case 'accept' : accept(); break;
	case 'decline' : decline(); break;

	case 'propose' : propose(); break;

	default: index();
}

function index()
{
	global $ir,$h,$married,$modName;	
	echo "<h3>{$modName}</h3>";
		  if($married == FALSE)
		  	{
			  	echo "Here, you can enter a userid to propose to, if they confirm/accept you will be married, which will give you features such as being able to send money to eachother and looking into eachothers inventory.</i>";
			  	continue_notMarried();
		  	}
		  else
		  	{
			  	if($ir['married_to'] > 0)
			  		{
					  	$mt = mysql_fetch_array(mysql_query("SELECT `username` FROM `users` WHERE `userid`={$ir['married_to']}"));
					  	echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Married to</div>
					  					<div style='height: 10pt;width:380pt;float:left;background:#ccffcc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>{$mt['username']}</div>
					  		  <div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Manage Marriage</div>
					  		  			<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=divorce'>Divorce</a></div>
					  		  			<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=stats'>View Marriage Stats</a></div>
					  		  			<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=more'>More Options</a></div>
					  		  <div style='width: 100%;height: 2em;'></div>";
					  	links("hide");
		  			}
		  		else
		  			{
					    echo "You are either married, you have a pending proposal or someone has proposed to you!";
					  	links("hide");
				  	}
		  	}
}

function continue_notMarried()
{
	global $ir, $h;
	echo "<p align='center'>
		 <strong>Please enter the user's ID which you would like to propose to.</strong>
			<br />
		 <form action='?action=propose' method='post'>
		 <input type='text' name='user_id' length='15' maxlength='15' onchange='showUser(this.value)'/>
		 	<br />

		 <div id='showUser'></div>
		 </p>";
    links("");
}

function propose()
{
	global $ir, $h, $modName, $userid, $c;
	$prop = abs(@intval($_POST['user_id']));

	$ro = mysql_fetch_array(mysql_query("SELECT `username`,`gender` FROM `users` WHERE `userid`={$prop}"));

	$g = ($ro['gender'] == 'Male') ? 'him' : 'her';

	echo "<h3>{$modName}</h3>

	<font family='verdana'>You have proposed to <a href='viewuser.php?u={$prop}'>{$ro['username']}</a></font>. Please wait for {$g} to accept/decline!";
	mysql_query("UPDATE `users` SET `propose_to`={$prop} WHERE `userid`=$userid");
	mysql_query("UPDATE `users` SET `propose_from`={$userid} WHERE `userid`=$prop");
	event_add($prop,"{$ir['username']} has just proposed to you! [<a href='zMarriage.php?action=decline'>Decline</a>] [<a href='zMarriage.php?action=accept'>Accept</a>]",$c);	
    links("FALSE");	
}

function accept()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `propose_to`,`propose_from`,`married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->propose_from == 0 OR $r->married_to > 0)
		{
			echo "<strong><font color='red'>You haven't been proposed to!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			$pf = mysql_fetch_array(mysql_query("SELECT `username` FROM `users` WHERE `userid`={$r->propose_from}"));
			echo "<font family='verdana'>You have accepted the proposal from <a href='viewuser.php?u={$r->propose_from}'>{$pf['username']}</a></font> congratulations, you are now married!";
			mysql_query("UPDATE `users` SET `married_to`={$userid},`propose_to`=0 WHERE `userid`={$r->propose_from}");
			mysql_query("UPDATE `users` SET `married_to`={$r->propose_from},`propose_from`=0 WHERE `userid`={$userid}");	
			event_add($ir['married_to'],"{$ir['username']} has accepted your proposal!",$c);

			$date = date('D m Y');
			mysql_query("INSERT INTO `user_marriage` (`user1`,`user2`,`date`) VALUES ($userid, $r->propose_from, '$date')");
		}
	links("FALSE");
}
function decline()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `propose_to`,`propose_from`,`married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->propose_from == 0 OR $r->married_to > 0)
		{
			echo "<strong><font color='red'>You haven't been proposed to!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			$to = $ir['propose_from'];
			event_add($to,"{$ir['username']} has declined your proposal!",$c);	
			$pf = mysql_fetch_array(mysql_query("SELECT `username` FROM `users` WHERE `userid`={$r->propose_from}"));
			echo "<font family='verdana'>You have declined the proposal from <a href='viewuser.php?u={$r->propose_from}'>{$pf['username']}</a></font>!";
			mysql_query("UPDATE `users` SET `propose_to`=0 WHERE `userid`={$r->propose_from}");
			mysql_query("UPDATE `users` SET `propose_from`=0 WHERE `userid`={$userid}");	
		}
	links("FALSE");
}

function divorce()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			$to = $ir['married_to'];
			event_add($to,"{$ir['username']} has divorced you!",$c);	

			$mt = mysql_fetch_array(mysql_query("SELECT `username` FROM `users` WHERE `userid`={$ir['married_to']}"));

			echo "<font family='verdana'>You have divorced your partner, <a href='viewuser.php?u={$ir['married_to']}'>{$mt['username']}</a></font>!";
			mysql_query("UPDATE `users` SET `married_to`=0 WHERE `userid`={$ir['married_to']}");
			mysql_query("UPDATE `users` SET `married_to`=0 WHERE `userid`={$userid}");	
			mysql_query("DELETE FROM `user_marriage` WHERE `user1`=$userid OR `user2`=$userid");
		}
	links("FALSE");
}

function stats()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			$um = mysql_fetch_array(mysql_query("SELECT um.`user1`,um.`user2`,um.`date`,um.`sentmoney`,u.`username`,u.`userid` FROM `user_marriage` um LEFT JOIN `users` u ON `userid`=`user1` OR `userid`=`user2` WHERE `userid`=`user1` OR `userid`=`user2`"));
			$mt = mysql_fetch_array(mysql_query("SELECT `username` FROM `users` WHERE `userid`={$ir['married_to']}"));
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Married to</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>{$mt['username']}</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
					 //married since
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Married Since</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>{$um['date']}</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
					 //combined cash
					 $p = mysql_fetch_array(mysql_query("SELECT `money` FROM `users` WHERE `userid`={$ir['married_to']}"));
					 $combined_cash = $ir['money']+$p['money'];
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Combined Cash</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>$".moneyFormat($combined_cash)."</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
					 //combined bank
					 $p = mysql_fetch_array(mysql_query("SELECT `bankmoney` FROM `users` WHERE `userid`={$ir['married_to']}"));
					 $combined_bank = $ir['bankmoney']+$p['bankmoney'];
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Combined Bank Balance</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>$".moneyFormat($combined_bank)."</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
					 //combined crystals
					 $p = mysql_fetch_array(mysql_query("SELECT `crystals` FROM `users` WHERE `userid`={$ir['married_to']}"));
					 $combined_crys = $ir['crystals']+$p['crystals'];
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Combined Crystals</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>".number_format($combined_crys)."</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
					 //combined money sent
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Money Sent (Total)</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>$".moneyFormat($um['sentmoney'])."</div>
					  		  <div style='width: 100%;height: 1.3em;'></div>";
		}
	links("FALSE");		
}

function more()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			echo "<div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Send</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=sendMoney'>Money</a></div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=sendBank'>Bank Money</a></div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=sendCrystals'>Crystals</a></div>
				       						  		  <div style='width: 100%;height: 1.3em;'></div>
				  <div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>Contact</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='mailbox.php?action=compose&ID={$ir['married_to']}'>Message</a></div>
				       						  		  <div style='width: 100%;height: 1.3em;'></div>
				  <div style='height: 10pt;width:140px;float:left;background:#aacccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'>View</div>
					<div style='height: 10pt;width:140px;float:left;background:#cccccc;font-size:8pt;font-family:verdana;border:1px #FFFFFF solid;'><a href='?action=viewInventory'>Inventory</a></div>
				       						  		  <div style='width: 100%;height: 1.3em;'></div>";
					links("FALSE");
		}		
}	

function sendMoney()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			if(!isset($_POST['submit']))
				{
					echo "You can send money to your partner! ($".number_format($ir['money']).")
							<br />
							  <form action='' method='post'>
							  How much would you like to send?
							  	<br />
							  $<input type='text' name='cash' length='35' maxlength='".strlen($ir['money'])."'>	
							  	<br />
							   <input type='submit' value='Send' name='submit'>
							  </form>";
				}
			else
				{
					$money = abs( (int) $_POST['cash']);
					$_POST['cash'] = NULL;

					if(!is_numeric($money) OR $money > $ir['money'])
						{
							echo "You are sending more than you have!";
						}
					else
						{
							echo "You have successfully sent $".moneyFormat($money)." to your partner!";
							mysql_query("UPDATE `users` SET `money`=`money`+$money WHERE `userid`={$ir['married_to']}");
							mysql_query("UPDATE `users` SET `money`=`money`=$money WHERE `userid`=$userid");
							event_add($ir['married_to'], "{$ir['username']} has just given you $".moneyFormat($money)."!");
							mysql_query("UPDATE `user_marriage` SET `sentmoney`=`sentmoney`+$money WHERE `user1`=$userid OR `user2`=$userid");
						}
				}
		}
	links("FALSE");
}

function sendBank()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			if(!isset($_POST['submit']))
				{
					echo "You can wire money to your partner's bank account! ($".number_format($ir['bankmoney']).")
							<br />
							  <form action='' method='post'>
							  How much would you like to send?
							  	<br />
							  $<input type='text' name='cash' length='35' maxlength='".strlen($ir['bankmoney'])."'>	
							  	<br />
							   <input type='submit' value='Send' name='submit'>
							  </form>";
				}
			else
				{
					$money = abs( (int) $_POST['cash']);
					$_POST['cash'] = NULL;

					if(!is_numeric($money) OR $money > $ir['bankmoney'])
						{
							echo "You are sending more than you have!";
						}
					else
						{
							echo "You have successfully wired $".moneyFormat($money)." to your partner!";
							mysql_query("UPDATE `users` SET `bankmoney`=`bankmoney`+$money WHERE `userid`={$ir['married_to']}");
							mysql_query("UPDATE `users` SET `bankmoney`=`bankmoney`=$money WHERE `userid`=$userid");
							event_add($ir['married_to'], "{$ir['username']} has just wired you $".moneyFormat($money)."!");
							mysql_query("UPDATE `user_marriage` SET `sentmoney`=`sentmoney`+$money WHERE `user1`=$userid OR `user2`=$userid");
						}
				}
		}
 	links("FALSE");
}

function sendCrystals()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			if(!isset($_POST['submit']))
				{
					echo "You can give your partner crystals! (".number_format($ir['crystals']).")
							<br />
							  <form action='' method='post'>
							  How much would you like to send?
							  	<br />
							  <input type='text' name='crys' length='35' maxlength='".strlen($ir['crystals'])."'> crystals	
							  	<br />
							   <input type='submit' value='Send' name='submit'>
							  </form>";
				}
			else
				{
					$crys = abs( (int) $_POST['crys']);
					$_POST['crys'] = NULL;

					if(!is_numeric($crys) OR $crys > $ir['crystals'])
						{
							echo "You are sending more than you have!";
						}
					else
						{
							echo "You have successfully sent ".number_format($crys)." crystals to your partner!";
							mysql_query("UPDATE `users` SET `crystals`=`crystals`+$crys WHERE `userid`={$ir['married_to']}");
							mysql_query("UPDATE `users` SET `crystals`=`crystals`=$crys WHERE `userid`=$userid");
							event_add($ir['married_to'], "{$ir['username']} has just given you ".number_format($crys)." crystals!");
						}
				}
		}
	links("FALSE");
}

function viewInventory()
{
	global $ir, $h, $modName, $userid, $c;
	echo "<h3>{$modName}</h3>";

	$exist = mysql_query("SELECT `married_to` FROM `users` WHERE `userid`={$userid}");
	$r = mysql_fetch_object($exist);

	if(mysql_num_rows($exist) == 0 OR $r->married_to == 0)
		{
			echo "<strong><font color='red'>You are not even married, therefore you have to stats to look at!</font></strong>";
			links("FALSE");
			exit( $h->endpage() );
		}
	else
		{
			inventory($ir['married_to']);	
		}
}
?>
Edited by Llight
Typo
Link to comment
Share on other sites

Do you currently have any property modifications? If not then mc codes uses by default the max will of a property. So what you can do is grab the max will of their spouse if its greater than your max will and change it to that. Now I dont remember if mc has a house column in the users table so then what you can.do is anything that has to do with buying or selling a house you can update that to keep tabs on what they have/had to update when there is a change lime moving out so you can update their max will based on what house they own. So there is a start and you can maybe take it from there since im on my phone and getting ready for work thats all I can offer at this time.

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.

 Share

×
×
  • Create New...