Well i had a weather mod a while back i was working on, but i cant find it so i made this. This mod isnt really finished with what im going to do with it, but you can add it to your game and do what you want to with it. This simply selects a weather by a cron and you can make that weather have different affects on your game. While all our games are different they should all be able to fit in your game differently.
So simply add this bit of SQL into your MYSQL database
CREATE TABLE IF NOT EXISTS `weather` (
`wID` int(11) NOT NULL DEFAULT '0',
`wNAME` varchar(255) DEFAULT '',
`wACTIVE` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`wID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;Make this edit in your header.php file
Find:
<b>Crystals:</b> {$ir['crystals']}<br />Below Add This:
<br><br>";
$wea=mysql_query("SELECT * FROM weather WHERE wACTIVE=1",$c);
$we=mysql_fetch_array($wea);
$check=mysql_num_rows($wea);
if($check == 0)
{
$weather="Sunny";
}
else
{
$weather="{$we['wNAME']}";
}
print"Current weather is <b><i>$weather</i></b>";Now Open your monorail.php file and find this:
$h->menuarea();Below that add this:
$wea=mysql_query("SELECT * FROM weather WHERE wACTIVE=1",$c);
$we=mysql_fetch_array($wea);
if($we['wNAME'] == 'Snow')
{
die("Due to snow all flights have been canceled");
}Make a Cron called weathercron.php
<?php
session_start();
require "global_func.php";
$userid=$_SESSION['userid'];
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
$wee=mysql_query("SELECT * FROM weather",$c) or die(mysql_error());
$we=mysql_fetch_array($wee);
mysql_query("UPDATE weather SET wACTIVE=0 WHERE wACTIVE=1",$c) or die(mysql_error());
$rand=rand(1,4);
mysql_query("UPDATE weather SET wACTIVE=1 WHERE wID=$rand",$c) or die(mysql_error());
?>Like i said not that much really, but that should give you some ideas. If you make any additions please feel free to post! i will also be adding on to it and i will share with you guys.
