Skip to content

Functions

Ryan Lockard edited this page Jul 12, 2018 · 1 revision

Functions:

AddWeatherObserver(interval, city[]);

Creates a new weather observer that targets the specified city.

interval - Time, in minutes, between when the observer sends the HTTP request to the weather API.

city[] - City that's weather will be grabbed.

AddWeatherObserver(10, "Los Angeles, CA");

AddWeatherZone(observerid, Float:minX, Float:minY, Float:maxX, Float:maxY, bool:movable = false);

Creates a new weatherzone linked to the speicifed observer.

observerid - Observer ID (returned from AddWeatherObserver) to link the weather zone too.

Float:minX - Bottom X-coordinate for the left corner of the rectangular zone.

Float:minY - Bottom Y-coordinate for the left corner of the rectangular zone.

Float:maxY - Top X-coordinate for the right corner of the rectangular zone.

Float:maxY - Top Y-coordinate for the right corner of the rectangular zone.

new LS_Observer = AddWeatherObserver(...);
AddWeatherZone(LS_Observer, 65, -2967, 2999, -662, false);

RemoveWeatherObserver(observerid);

Used to remove a weather observer.

observerid - The weather observer to remove.

new LS_Observer;

public OnGamemodeInit() {
    LS_Observer = AddWeatherObserver(...);
}

public OnGameModeExit() {
    RemoveWeatherObserver(LS_Observer);
}

RemoveWeatherZone(weatherzoneid);

Used to remove a weather zone.

weatherzoneid - The weather zone to remove.

new LS_Zone;

public OnGamemodeInit() {
    LS_Zone = AddWeatherZone(...);
}

public OnGameModeExit() {
    RemoveWeatherZone(LS_Zone);
}

ResetWeatherZone(weatherzoneid);

Used when zones are moving/have moved. Resets their position to the default specified when created.

weatherzoneid - The weatherzone to reset's position.

new LS_Zone;
LS_Zone = AddWeatherZone(...);
ResetWeatherZone(LS_Zone);

SetPlayerWeatherEx(playerid, weather);

Use this instead of SA-MP's native SetPlayerWeather.

playerid - Player whos weather you wish to set.

weather - Weather ID to set the player to.

SetPlayerWeather(playerid, 9);

The above sets the players weather to WEATHER_FOGGY


GetPlayerWeather(playerid);

Used to get a player's current weather (as set by SetPlayerWeatherEx).

playerid - Players who weather you wish to retrieve.

new pWeather = GetPlayerWeather(0);

Say for example player 0's weather is set to 1. pWeather will now equal 1.


IsPlayerInAnyWeatherZone(playerid)

Checks to see if a player is standing in any weather zone. If they are, return that zone's ID.

playerid - Player to check if they're standing in any zones.

if(new zone = IsPlayerInAnyWeatherZone(playerid) != -1) {
    printf("Player %d is standing in zone %d.", playerid, zone);
}

Note: This function returns -1 if the player is not standing in any weather zones.


IsPlayerInWeatherZone(playerid, weatherzoneid)

Checks if a player is standing in the specified weather zone.

playerid - Player to check if standing in the specified weather zone.

weatherzoneid - The specified weather zone.

if(IsPlayerInWeatherZone(playerid, LS_Zone)) {
    SendClientMessage(playerid, -1, "You're experiencing Los Angeles weather!");
}

IsPlayerInMultipleZones(playerid)

Check to see if a player is standing in more than 1 weather zone.

playerid - Playerid to check if they're standing in multiple zones.

if(IsPlayerInMultipleZones(playerid)) {
    SencClientMessage(playerid, -1, "Hey! You're standing in more than 1 zone!");
}

Note: This function returns true if the player is standing in more than 1 zone. False if they are standing in 1 or no zones.


SetWeatherZoneMovable(weatherzoneid, bool:movable);

Sets a weatherzones ability to move.

weatherzoneid - The weatherzone to toggle the moving status.

bool:movable - True - Weather zone can move. False - Weather zone cannot move.

SetWeatherZoneMovable(LS_Zone, true);

Note: This function only allows a weather zone the ability to move. For it to move, the wind speed of the observer will need to be > WEATHER_SPEED_LIMITER


MoveWeatherZone(weatherzoneid, Float:speed);

Override an observer's wind speed with a manual value.

weatherzoneid - The weather zone to change the speed of.

Float:speed - Speed to move the zone at.

MoveWeatherZone(LS_Zone, 9.0);

Note: Ensure that 'speed' is set to a higher value than you have WEATHER_SPEED_LIMITER set to (default 5.0)