[HELP] weather
#6

This should work for you:
pawn Код:
#include <a_samp>
#include <zcmd>

new WeatherTimer; //This is the timer that will be used for the weather.
new bool:WeatherDisabled; //Will determine whether the wheather (xD) is running or not.

public OnGameModeInit()
{
    WeatherDisabled = false;
    WeatherTimer = SetTimerEx("ChangeWeather", 60000, false, "i", random(20)); //First timer when the gamemode is started will be 1 minute long.
    SetWeather(1);
    return 1;
}

CMD:startweather(playerid, params[])
{
    //This will only be restricted to RCON Admins, change !IsPlayerAdmin with your own admin variables.
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only RCON Administrators can use this command.");
    if(WeatherDisabled == false) return SendClientMessage(playerid, 0xFF0000FF, "The weather is currently running. Use /stopweather to disable it.");
    WeatherDisabled = false;
    WeatherTimer = SetTimerEx("ChangeWeather", 1000, false, "i", random(20));
    return 1;
}

CMD:stopweather(playerid, params[])
{
    //This will only be restricted to RCON Admins, change !IsPlayerAdmin with your own admin variables.
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only RCON Administrators can use this command.");
    if(WeatherDisabled == true) return SendClientMessage(playerid, 0xFF0000FF, "The weather is not currently running. Use /startweather to enable it.");
    WeatherDisabled = true;
    SendClientMessageToAll(0xFFFF00FF, "The weather predictions have stopped, as weather is not expected to change any time soon.");
    KillTimer(WeatherTimer);
    return 1;
}

forward ChangeWeather(Weather);
public ChangeWeather(Weather)
{
    if(WeatherDisabled == true) return 1;
    new NextWeather = random(20);
    new Time = random(60);
    new str[125];
    format(str, sizeof(str), "Good Day listeners, the current weather is {00F0F0}%s{FFFF00}. The next weather prediction will be {00F0F0}%s.", GetWeatherName(Weather), GetWeatherName(NextWeather));
    SendClientMessageToAll(0xFFFF00FF, str);
    WeatherTimer = SetTimerEx("ChangeWeather", (60000 + (Time * 1000)), false, "i", NextWeather);
    return 1;
}

stock GetWeatherName(weatherid)
{
    new Weathername[12];
    switch(weatherid)
    {
        case 0, 6, 13, 17:      Weathername = "Very Sunny";
        case 1, 5, 10, 14, 18:  Weathername = "Sunny";
        case 4, 7, 12, 15:      Weathername = "Cloudy";
        case 8, 16:             Weathername = "Rainy";
        case 2, 3:              Weathername = "Smoggy";
        case 9, 20:             Weathername = "Foggy";
        case 11:                Weathername = "Heatwave";
        case 19:                Weathername = "Sandstorm";
    }
    return Weathername;
}
Reply


Messages In This Thread
[HELP] weather - by Luca12 - 08.12.2013, 16:47
Re: [HELP] weather - by Krakuski - 08.12.2013, 17:21
Re: [HELP] weather - by Luca12 - 09.12.2013, 10:15
Re: [HELP] weather - by Astralis - 09.12.2013, 10:20
Re: [HELP] weather - by Luca12 - 09.12.2013, 11:23
Re: [HELP] weather - by Threshold - 09.12.2013, 12:10
Re: [HELP] weather - by Luca12 - 09.12.2013, 18:53

Forum Jump:


Users browsing this thread: 1 Guest(s)