Scripting/Squirrel/Functions/Game/GetWeather

From VC-MP Wiki

Jump to: navigation, search

This returns the current weather in the server.

Syntax

int GetWeather()

Arguments

  • None

Example

This example will return the weather id when a player types '/c weather'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "weather" )
     {
          MessagePlayer( "Current weather: " + GetWeather(), player );
     }
}

or

Example, Weather Name

This example will return the weather name when a player types '/c weathername'.

================================

You need to add it to your script!

================================
function GetWeatherName( iweather )
{
	switch( iweather )
	{
		case 0:
			return "Partly Cloudy";
			break;
 
		case 1:
			return "Overcast Cloudy Skies";
			break;
 
		case 2:
			return "Lightning";
			break;
 
		case 3:
			return "Fog with Low Visibility";
			break;
 
		case 4:
			return "Clear Skies";
			break;
 
		case 5:
			return "Rain";
			break;
 
		case 6:
			return "Darkness from the Eclipse";
			break;
 
		case 7:
			return "Light sky partly cloudy";
			break;
 
		case 8:
			return "Overcast partly cloudy";
			break;
 
		case 9:
			return "Grey sky black clouds";
			break;
 
		case 10:
			return "Fog And Gray";
			break;
	}
}

command:

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "weathername" )
     {
          MessagePlayer( "Current weather: " + GetWeatherName( GetWeather() ), player );
     }
}

Notes

The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
squirrel scripting