Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Register your account to receive email notifications when new services and mods are added.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Simple Weather Mod  (Read 486 times)

BlackVengeance

  • Basic Member
  • *
  • Reputation Power: 18
  • BlackVengeance has no influence.
  • Offline Offline
  • Posts: 22
    • View Profile
Simple Weather Mod
« on: January 17, 2011, 10:45:07 AM »
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

Code: [Select]
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:
Code: [Select]
<b>Crystals:</b> {$ir['crystals']}<br />
Below Add This:
Code: [Select]
<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:
Code: [Select]
$h->menuarea();
Below that add this:
Code: [Select]
$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

Code: [Select]
<?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. :)
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.