Mweather
From SA-MP Wiki
MWeather is an include that expands the weather functionalities of SA-MP by things like (moving) weather zones, and the ability to set real world weather using yahoo weather. This page explains the functions provided by the MWeather include by User:Mauzen To use the functions, you need to use at least SA-MP server version 0.3b and of course the include that you can get here: http://forum.sa-mp.com/showthread.php?t=181897
Contents |
[edit]
Defines
Real weather observers use the following defines to represent the weather state of their url. Not all are used automatically in the script yet.
#define WEATHER_UNKNOWN 0 #define WEATHER_SUNNY 1 #define WEATHER_MOSTLY_SUNNY 2 #define WEATHER_PARTLY_CLOUDY 3 #define WEATHER_MOSTLY_CLOUDY 4 #define WEATHER_CLOUDY 5 #define WEATHER_LIGHT_RAIN 6 #define WEATHER_SHOWERS 7 #define WEATHER_RAIN 8 #define WEATHER_LIGHT_THUNDERSTORM 9 #define WEATHER_THUNDERSTORM 10 #define WEATHER_MIST 11 #define WEATHER_SNOWRAIN 12 #define WEATHER_LIGHT_SNOW 13
[edit]
General
[edit]
SetWeatherEx
Use this function to set the server's global weather.
(weatherid)
| weatherid | WeatherID to set. |
| Returns | This function doesn't return a specific value |
[edit]
GetWeatherEx
This function returns the actual global weather.
| Returns | The current WeatherID, -1 if a global real weather is set. |
[edit]
SetPlayerWeatherEx
Use this function to set a player's weather.
(playerid, weatherid)
| playerid | The ID of the player to change the weather for. |
| weatherid | WeatherID to set. |
| Returns | This function doesn't return a specific value |
[edit]
GetPlayerWeatherEx
This function returns the player's actual weather.
(playerid)
| playerid | The ID of the player to get the weather from. |
| Returns | The current WeatherID for the player, -1 if a real weather is set for the player. |
[edit]
SetRealWeatherEx
Use this function to set the server's global weather from a real weather observer, created before using AddWeatherObserver.
The weather is updated everytime the observer gets new data.
(observerid)
| observerid | The observerid of a valid real weather observer. |
| Returns | This function doesn't return a specific value |
[edit]
GetRealWeatherEx
This function returns the actual real weather observer.
| Returns | The current observerid, -1 if a normal global weather is set. |
[edit]
SetPlayerRealWeatherEx
Use this function to set a player's weather from a real weather observer, created before using AddWeatherObserver.
(playerid, observerid)
| playerid | The ID of the player to change the weather for. |
| observerid | The observerid of a valid real weather observer. |
| Returns | This function doesn't return a specific value |
[edit]
GetPlayerRealWeatherEx
This function returns the player's actual weather.
(playerid)
| playerid | The ID of the player to get the weather from. |
| Returns | The current observerid for the player, -1 if a normal weather is set. |
[edit]
Real weather
[edit]
AddWeatherObserver
Creates a weather observer that updates the data for the url every specified milliseconds.
(url[], updatetime)
| url[] | The link to the wanted position from weather.yahoo.com. |
| updatetime | Interval in ms in which the weather is checked (10 mins are more than enough for normal use). |
| Returns | The observerid of the created observer, -1 if it could not be added. |
| Note: To get the URL, go to weather.yahoo.com and search for the town/area you want.
Use the link up to the last slash (e.g. http://weather.yahoo.com/bahrain/capital/manama-1967057/) |
Example:
//This example creates a weather observer for Chicago //and sets it as global weather public OnGameModeInit() { new chicago = AddWeatherObserver("http://weather.yahoo.com/united-states/illinois/chicago-2379574/", 900000); SetRealWeatherEx(chicago); }
[edit]
RemoveWeatherObserver
Removes a weather observer. It will stop all update processes
(observerid)
| observerid | The ID to remove. |
| Returns | 1 if removed successfully, 0 if not. |
[edit]
Weather zones
[edit]
AddWeatherZone
This creates a weatherzone with the specified size at the given position.
It will set the weather (normal or real weather) for every player that enters the zone.
(Float:x, Float:y, Float:z, Float:length, Float:width, Float:height, weatherid, bool:observer)
| Float:x/y/z | The center position of the zone. |
| Float:length/width/height | The measurement of the zone |
| weatherid | The WeatherID or a valid observerid of the weather to set in the zone. |
| observer | Set this to false, if weatherid is a samp WeatherID, and to true, if it is an observerid |
| Returns | The ID of the created zone, or -1 if the creation failed. |
[edit]
MoveWeatherZone
Moves a weather zone from its current position to the specified coords.
(zoneid, Float:tox, Float:toy, Float:toz, Float:speed)
| zoneid | The ID of the zone to move. |
| Float:tox/toy/toz | The target position to move to. |
| Float:speed | The speed in meters/sec (not exactly in current version) the zone moves with. |
| Returns | 1 if it is a valid zone, 0 if not |
Example:
//This example creates a rain weatherzone which width covers all SA in the north //and moves it down slowly. new northsouth; public OnGameModeInit() { northsouth = AddWeatherZone(0.0, 3000.0, 50.0, 6000.0, 500.0, 100.0, 8, false); MoveWeatherZone(northsouth, 0.0, 3000.0, 50.0, 20.0); }
[edit]
StopWeatherZone
Stops the movement of a weather zone
(zoneid)
| zoneid | The ID of the zone to stop. |
| Returns | 1 if it is a valid zone, 0 if not |
[edit]
Callbacks
[edit]
OnPlayerWeatherZoneChange
This callback is called, when the weather zone, a player is currently in, changes.
(playerid, oldzone, newzone)
| playerid | The ID of the player, who enters/leaves a zone. |
| oldzone | The ID of the zone, the player was in previously (-1 means no zone). |
| newzone | The ID of the zone, the player is now in (-1 means no zone). |
| Returns | This callback does not handle returns. |
[edit]
OnWeatherZoneMoved
This callback is called, when a weather zone finished its movement. It is not called, when using StopWeatherZone.
(zoneid)
| zoneid | The ID of the zone, that stops moving. |
| Returns | This callback does not handle returns. |
[edit]
OnRealWeatherUpdate
This callback is called, when a real weather observer gets new data. It is also called, when the weatherstate did not change.
(observerid, oldstate, newstate)
| observerid | The ID of the real weather observer. |
| oldstate | The previous weather state of the observer. |
| newstate | The new weather state of the observer. |
| Returns | This callback does not handle returns. |
