Advertisement
Eddlm

Weather Forecast

Apr 3rd, 2016
1,869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.25 KB | None | 0 0
  1. using GTA;
  2. using GTA.Native;
  3. using System;
  4. using System.IO;
  5. using System.Windows.Forms;
  6.  
  7. enum WeatherType
  8. {
  9.     EXTRA_SUNNY = -1750463879,
  10.     CLEAR = 916995460,
  11.     NEUTRAL = -1530260698,
  12.     SMOG = 282916021,
  13.     FOGGY = -1368164796,
  14.     OVERCAST = -1148613331,
  15.     CLOUDS = 821931868,
  16.     CLEARING = 1840358669,
  17.     RAIN = 1420204096,
  18.     THUNDER = -1233681761,
  19.     SNOW = -273223690,
  20.     BLIZZARD = 669657108,
  21.     LIGHT_SNOW = 603685163,
  22.     X_MAS = -1429616491
  23. };
  24.  
  25. public class WeatherForecast : Script
  26. {
  27.  
  28.     WeatherType expectedWeather = WeatherType.NEUTRAL;
  29.     public WeatherForecast()
  30.     {
  31.         Function.Call(Hash.REQUEST_STREAMED_TEXTURE_DICT, "news_weazelnews", true);
  32.  
  33.         Tick += OnTick;
  34.         Interval = 5000;
  35.     }
  36.  
  37.     void OnTick(object sender, EventArgs e)
  38.     {
  39.         if(expectedWeather == WeatherType.NEUTRAL)
  40.         {
  41.             expectedWeather = (WeatherType)Function.Call<int>(GTA.Native.Hash._GET_CURRENT_WEATHER_TYPE);
  42.         }
  43.         if (expectedWeather != (WeatherType)Function.Call<int>(GTA.Native.Hash._GET_NEXT_WEATHER_TYPE))
  44.         {
  45.             expectedWeather = (WeatherType)Function.Call<int>(GTA.Native.Hash._GET_NEXT_WEATHER_TYPE);
  46.  
  47.             WarnPlayer("Weazel News", "Forecast", "Here's the weather forecast: "+ GetForecastText(expectedWeather));
  48.         }
  49.     }
  50.  
  51.  
  52.     void WarnPlayer(string script_name, string title, string message)
  53.     {
  54.         Function.Call(Hash._SET_NOTIFICATION_TEXT_ENTRY, "STRING");
  55.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, message);
  56.         Function.Call(Hash._SET_NOTIFICATION_MESSAGE, "news_weazelnews", "news_weazelnews", true, 0, title, "~b~" + script_name);
  57.     }
  58.  
  59.     bool CanWeUse(Entity entity)
  60.     {
  61.         return entity != null && entity.Exists();
  62.     }
  63.  
  64.     void DisplayHelpTextThisFrame(string text)
  65.     {
  66.         Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
  67.         Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
  68.         Function.Call(Hash._DISPLAY_HELP_TEXT_FROM_STRING_LABEL, 0, false, true, -1);
  69.     }
  70.  
  71.     string GetForecastText(WeatherType weather)
  72.     {
  73.         switch (weather)
  74.         {
  75.             case WeatherType.BLIZZARD:
  76.                 {
  77.                     return "A big blizzard is expected.";
  78.                 }
  79.             case WeatherType.CLEARING:
  80.                 {
  81.                     return "Skies will clear in the next hours.";
  82.                 }
  83.             case WeatherType.CLEAR:
  84.                 {
  85.                     return "The skies will be clear for the next couple of hours.";
  86.                 }
  87.             case WeatherType.FOGGY:
  88.                 {
  89.                     return "Its going to be foggy for a while.";
  90.                 }
  91.             case WeatherType.SMOG:
  92.                 {
  93.                     return "Clear skies accompanied by little fog are expected.";
  94.                 }
  95.             case WeatherType.RAIN:
  96.                 {
  97.                     return "Rain is expected to feature the following hours.";
  98.                 }
  99.             case WeatherType.NEUTRAL:
  100.                 {
  101.                     return "Strange shit happening on the skies soon. Beware.";
  102.                 }
  103.             case WeatherType.THUNDER:
  104.                 {
  105.                     return "Heavy rain accompanied by thunder is expected.";
  106.                 }
  107.             case WeatherType.LIGHT_SNOW:
  108.                 {
  109.                     return "Some snow is expected.";
  110.                 }
  111.             case WeatherType.SNOW:
  112.                 {
  113.                     return "Copious ammounts of snow for the next hours.";
  114.                 }
  115.             case WeatherType.X_MAS:
  116.                 {
  117.                     return "Christmas itself is expected. Ho ho ho!";
  118.                 }
  119.             case WeatherType.EXTRA_SUNNY:
  120.                 {
  121.                     return "Skies will be completely clear for a few hours.";
  122.                 }
  123.             case WeatherType.OVERCAST:
  124.                 {
  125.                     return "Its going to be very cloudy for some time.";
  126.                 }
  127.             case WeatherType.CLOUDS:
  128.                 {
  129.                     return "Clouds will cover the sky for some hours.";
  130.                 }
  131.         }
  132.         return "No idea.";
  133.  
  134.     }
  135.  
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement