Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

Get Current weather C++


XXDestroyer89
 Share

Recommended Posts

XXDestroyer89

I need to determine the current weather in C++. I have found native: _GET_CURRENT_WEATHER_TYPE  But this is not supported anymore. How do I get the current weather?

Link to comment
Share on other sites

This is the old native and hash:

 

Hash _GET_CURRENT_WEATHER_TYPE() // 564B884A05EC45A3 A8171E9E

 

The one that matches that is this:

 

static Hash GET_PREV_WEATHER_TYPE_HASH_NAME() { return invoke<Hash>(0x564B884A05EC45A3);

 

So it looks like they finally found the proper name for it, as it no longer has the _ at the start of the name.

 

If ever a name changes or something seems to have disappeared, search for the hash value (the 564B884A05EC45A3 number) and you should find the new version. If the hash isn't there, then the native has probably been removed.

Edited by LeeC22
  • Like 1
Link to comment
Share on other sites

XXDestroyer89

Okay, so GET_PREV_WEATHER_TYPE_HASH_NAME is also the current weather? that's strange, but if it works, it works. 

'

Link to comment
Share on other sites

Rockstar doesn't always make sense sadly, I'm sure there's some logic in there somewhere... maybe. :)

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
waynieoaks

Hi, 

 

Sorry for such a noob coder question, but I am trying to get the current weather in a Rage Plugin Hook script and cannot for the life of me work out how to do it. I have been trying: 

 

var GetWeather = NativeFunction.Natives.GET_PREV_WEATHER_TYPE_HASH_NAME()

 

Does anybody know how to do this for RPH? 

 

Many thanks in advance. 

Link to comment
Share on other sites

@waynieoaksThere seems to be a World.Weather property that returns the current weather as a WeatherType value.

public static WeatherType Weather { get; set; }

So I am guessing you'd do something like

WeatherType currentWeather = World.Weather;

Don't use RPH, so I could be wrong on that.

 

That was found here btw http://docs.ragepluginhook.net

Edited by LeeC22
Link to comment
Share on other sites

waynieoaks

Hi @LeeC22

 

Thanks for the reply, and for trying to help

 

Sadly World.Weather was my first point of call, but found it was throwing a NotImplementedException error. It appears set was implemented, but get was not. 

 

So the only option left I believe is using NativeFunctions, which I really don't understand in RPH and struggling to find working examples of it. I may ask a fresh thread about native functions in RPH. 

 

I fear I may need to rewrite everything to scripthook which will be painful :-(

Link to comment
Share on other sites

1 hour ago, waynieoaks said:

Hi @LeeC22

 

Thanks for the reply, and for trying to help

 

Sadly World.Weather was my first point of call, but found it was throwing a NotImplementedException error. It appears set was implemented, but get was not. 

 

So the only option left I believe is using NativeFunctions, which I really don't understand in RPH and struggling to find working examples of it. I may ask a fresh thread about native functions in RPH. 

 

I fear I may need to rewrite everything to scripthook which will be painful 😞

Just had another look at those docs and I noticed something that caught my eye with your post. I use ScriptHookVDotNet and when you call a native, you do this:

Function.Call<return type>(Hash.NATIVE NAME etc...);

You can see how the return type is specified. So maybe what you are missing in your native call, based on what I can see on those docs page, is a return type.For example, in one section I was reading, there's some code that says:

int playerHealth = TempApi.CallNative<int>(0xEEF059FAD016D209, TempApi.GetPlayerPed());

And that's returning a bool, so maybe you could try something like:

int weather = TempApi.CallNative<int>(0x564B884A05EC45A3);

I mean, it looks like you should be able to call it like this:

int weather = NativeFunction.Native.GetPrevWeatherTypeHashName<int>();

I'm just throwing ideas in here based on what I am seeing in various doc pages, they might be worth trying at least.

Edited by LeeC22
Link to comment
Share on other sites

waynieoaks

You @LeeC22, are amazing... Thank you... 

 

So my code is now: 

int GetWeather = NativeFunction.Natives.GetPrevWeatherTypeHashName<int>();

 

This returns an int that matches with the following table: 

 

name         hash (int)
BLIZZARD  ,   669657108,
CLEAR     ,   916995460,
CLEARING  ,  1840358669,
CLOUDS    ,   821931868,
EXTRASUNNY, -1750463879,
FOGGY     , -1368164796,
HALLOWEEN ,  -921030142,
OVERCAST  , -1148613331,
RAIN      ,  1420204096,
SMOG      ,   282916021,
SNOWLIGHT ,   603685163,
THUNDER   , -1233681761,
XMAS      , -1429616491,

 

So I can now convert the int to the name so it can be set back later. 

 

Thank you so much - Days tying to find out how to do native calls and google thinking I am completely mad. 

Link to comment
Share on other sites

Just to throw another wild idea in there, instead of returning an int, try returning a WeatherType instead. It might fail but then again, it might just return a value that is easier to work with... worth a shot anyway.

 

So...

WeatherType GetWeather = NativeFunction.Natives.GetPrevWeatherTypeHashName<WeatherType>();

 

Edited by LeeC22
Link to comment
Share on other sites

waynieoaks

Sadly I could not get that to work, but have this working (as a basic for me to tidy up properly): 

Dictionary<int, string> LookupWeather = new Dictionary<int, string>()
        {
            { 669657108, "BLIZZARD" },
            { 916995460, "CLEAR" },
            { 1840358669, "CLEARING" },
            { 821931868, "CLOUDS" },
            { -1750463879, "EXTRASUNNY" },
            { -1368164796, "FOGGY" },
            { -921030142, "HALLOWEEN" },
            { -1530260698, "NEUTRAL" },
            { -1148613331, "OVERCAST" },
            { 1420204096, "RAIN" },
            { 282916021, "SMOG" },
            { -273223690, "SNOW" },
            { 603685163, "SNOWLIGHT" },
            { -1233681761, "THUNDER" },
            { -1429616491, "XMAS" },
        };



           string result;
           int GetWeather = NativeFunction.Natives.GetPrevWeatherTypeHashName<int>();
            if (.LookupWeather.TryGetValue(GetWeather, out result) )
            {
                Game.DisplayNotification(result);
            } else
            {
                Game.DisplayNotification("Weather unknown: " + GetWeather.ToString());
                Game.LogTrivial("Weather unknown: " + GetWeather.ToString());
            }

 

I have also managed to understand a couple of other native commands - thank you for providing the detail of how they work as that was the key I was missing. 

Edited by waynieoaks
Formatting
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.