XXDestroyer89 Posted May 3, 2020 Share Posted May 3, 2020 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 More sharing options...
LeeC22 Posted May 3, 2020 Share Posted May 3, 2020 (edited) 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 May 3, 2020 by LeeC22 XXDestroyer89 1 Link to comment Share on other sites More sharing options...
XXDestroyer89 Posted May 3, 2020 Author Share Posted May 3, 2020 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 More sharing options...
LeeC22 Posted May 3, 2020 Share Posted May 3, 2020 Rockstar doesn't always make sense sadly, I'm sure there's some logic in there somewhere... maybe. XXDestroyer89 1 Link to comment Share on other sites More sharing options...
waynieoaks Posted May 12, 2020 Share Posted May 12, 2020 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 More sharing options...
LeeC22 Posted May 13, 2020 Share Posted May 13, 2020 (edited) @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 May 13, 2020 by LeeC22 Link to comment Share on other sites More sharing options...
waynieoaks Posted May 13, 2020 Share Posted May 13, 2020 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 More sharing options...
LeeC22 Posted May 13, 2020 Share Posted May 13, 2020 (edited) 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 May 13, 2020 by LeeC22 Link to comment Share on other sites More sharing options...
waynieoaks Posted May 13, 2020 Share Posted May 13, 2020 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. LeeC22 1 Link to comment Share on other sites More sharing options...
LeeC22 Posted May 13, 2020 Share Posted May 13, 2020 (edited) 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 May 13, 2020 by LeeC22 Link to comment Share on other sites More sharing options...
waynieoaks Posted May 13, 2020 Share Posted May 13, 2020 (edited) 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 May 13, 2020 by waynieoaks Formatting LeeC22 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now