20.09.2016, 15:30
Una funciуn que cambie el clima automбticamente cada cierto tiempo -> Supongamos que la usaremos dentro de un filterscript -
Ahн declaramos todas las ids de los diferentes climas como static ya que se usarб en todo momento (global static)
Luego creamos la funciуn del temporizador (timer) la cual cambiarб automбticamente los climas y se enviarб un mensaje en el chat del jugador y en la consola indicando que el clima ha cambiado
Luego cuando el filterscript cargue correctamente se aplicara el timer que se repetirб cada X cantidad de tiempo (en el ejemplo de arriba serian 3 horas) y se verнa de esta forma dentro del servidor
PHP Code:
enum weather_info
{
weather_id,
weather_text[39]
};
static WeatherIDS[][weather_info] =
{
{0,"Blue Sky"},
{1,"Blue Sky"},
{2,"Blue Sky"},
{3,"Blue Sky"},
{4,"Blue Sky"},
{5,"Blue Sky"},
{6,"Blue Sky"},
{7,"Blue Sky"},
{08,"Stormy"},
{09,"Cloudy and Foggy"},
{10,"Clear Blue Sky"},
{11,"Heatwave"},
{17,"Heatwave"},
{18,"Heatwave"},
{12,"Dull, Colourless"},
{13,"Dull, Colourless"},
{14,"Dull, Colourless"},
{15,"Dull, Colourless"},
{16,"Dull, Cloudy, Rainy"},
{19,"Sandstorm"},
{20,"Foggy, Greenish"},
{21,"Very Dark, Gradiented Skyline, Purple"},
{22,"Very Dark, Gradiented Skyline, Purple"},
{23,"Pale Orange"},
{24,"Pale Orange"},
{25,"Pale Orange"},
{26,"Pale Orange"},
{27,"Fresh Blue"},
{28,"Fresh Blue"},
{29,"Fresh Blue"},
{30,"Dark, Cloudy, Teal"},
{31,"Dark, Cloudy, Teal"},
{32,"Dark, Cloudy, Teal"},
{33,"Dark, Cloudy, Brown"},
{34,"Blue/Purple, Regular"},
{35,"Dull Brown"},
{36,"Bright, Foggy, Orange"},
{37,"Bright, Foggy, Orange"},
{38,"Bright, Foggy, Orange"},
{39,"Very Bright"},
{40,"Blue/Purple, Cloudy"},
{41,"Blue/Purple, Cloudy"},
{42,"Blue/Purple, Cloudy"},
{43,"Toxic Clouds"},
{44,"Black/White Sky"},
{700,"Stormy with Pink Sky and Crystal Water"},
{150,"Darkest Weather Ever"}
};
PHP Code:
forward RandomWeather();
public RandomWeather()
{
new rand = random(sizeof(WeatherIDS));
new message[51];
format(message, sizeof(message), "Weather changed to %s", WeatherIDS[rand][weather_text]);
SetWeather(WeatherIDS[rand][weather_id]);
SendClientMessageToAll(-1,message);
print(message);
}
PHP Code:
public OnFilterScriptInit()
{
SetTimer("RandomWeather", 3 * 3600 * 1000, 1);
}