Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QB Weathersync issues. #3

Open
ShaAlexander opened this issue Dec 20, 2021 · 7 comments
Open

QB Weathersync issues. #3

ShaAlexander opened this issue Dec 20, 2021 · 7 comments

Comments

@ShaAlexander
Copy link

Hi Again,

You make such amazing stuff, so yep, we use them a lot. But now I started to use your weather sync because of the map. But since we are on QB it kinda flashes at some times, I tried to disable the QB one but some other resources such as houses and apartments are depending on it.

Is there a way to let them both work together? Maybe a method for your plugin to look if QB or esx is weather sync is installed, then do use that one or kill it without losing other dependencies?

@kibook
Copy link
Owner

kibook commented Dec 20, 2021

I'm not familiar with QB(core?) or it's weather sync system, I assume you mean this? https://github.com/qbcore-framework/qb-weathersync

And is this the housing system you mentioned? https://github.com/qbcore-framework/qb-houses

From what I can tell from a quick glance at the code, the housing system disables weather syncing while you're inside the house, is that correct? My weathersync has a similar feature, so I think it would be possible to replace calls like this:

https://github.com/qbcore-framework/qb-houses/blob/053f87a3b931d95e7a29f66f1714d7e8a65573c0/client/main.lua#L154

TriggerEvent('qb-weathersync:client:EnableSync')

with:

TriggerEvent("weathersync:setSyncEnabled", true)

Although, I'm slightly confused as to why there is no instance of that resource using qb-weathersync:client:DisableSync to turn off the weather sync in the first place, it seems to only be re-enabling the weather sync.

I think maybe a simpler solution than making weathersync intermingle with with qb-weathersync (and potentially dozens of other weather sync systems out there for other frameworks) would be to create a small compatibility layer resource, which would be named qb-weathersync but would replace the normal events with calls to equivalent weathersync events/exports, like this:

AddEventHandler("qb-weathersync:client:EnableSync", function()
    TriggerEvent("weathersync:setSyncEnabled", true)
end)

AddEventHandler("qb-weathersync:client:DisableSync", function()
    TriggerEvent("weathersync:setSyncEnabled", false)
end)

What other resources that you use depend on qb-weathersync?

@ShaAlexander
Copy link
Author

I'm not familiar with QB(core?) or it's weather sync system, I assume you mean this? https://github.com/qbcore-framework/qb-weathersync

And is this the housing system you mentioned? https://github.com/qbcore-framework/qb-houses

From what I can tell from a quick glance at the code, the housing system disables weather syncing while you're inside the house, is that correct? My weathersync has a similar feature, so I think it would be possible to replace calls like this:

https://github.com/qbcore-framework/qb-houses/blob/053f87a3b931d95e7a29f66f1714d7e8a65573c0/client/main.lua#L154

TriggerEvent('qb-weathersync:client:EnableSync')

with:

TriggerEvent("weathersync:setSyncEnabled", true)

Although, I'm slightly confused as to why there is no instance of that resource using qb-weathersync:client:DisableSync to turn off the weather sync in the first place, it seems to only be re-enabling the weather sync.

I think maybe a simpler solution than making weathersync intermingle with with qb-weathersync (and potentially dozens of other weather sync systems out there for other frameworks) would be to create a small compatibility layer resource, which would be named qb-weathersync but would replace the normal events with calls to equivalent weather sync events/exports, like this:

AddEventHandler("qb-weathersync:client:EnableSync", function()
    TriggerEvent("weathersync:setSyncEnabled", true)
end)

AddEventHandler("qb-weathersync:client:DisableSync", function()
    TriggerEvent("weathersync:setSyncEnabled", false)
end)

What other resources that you use depend on qb-weathersync?

Yes, With QB I mean QBCore and also the housing and apartments (two scripts) are both QB.

As for the depending on resources, those are the only two for QB vanilla, lots of custom frameworks are actually based on QBCore and there is ESX as well.

@ShaAlexander
Copy link
Author

Replacing the triggers seems to work but don't forget to change the fxmanifest as well, change the dependencies, or you will have other issues…

dependencies {
	'rbp-core',
	'rbp-interior',
	'rbp-clothing',
	--'rbp-weathersync',
	'weathersync'
}

@kibook
Copy link
Owner

kibook commented Dec 20, 2021

Replacing the triggers seems to work but don't forget to change the fxmanifest as well, change the dependencies, or you will have other issues…

That is another way to do it. The way I was suggesting was to replace the rbp-weathersync resource, in your case, with basically a shell resource that hands off the qb-weathersync:... event triggers to weathersync:... ones. That way, you don't need to modify the qb-houses resource or its manifest, just the resource you're replacing anyways (qb-weathersync).

@kibook
Copy link
Owner

kibook commented Dec 20, 2021

Here's a more complete example: https://gist.github.com/kibook/3b2178b168a0f31f7be6cf46e7c7f8f4

If you replace your rbp-weathersync resource with this, assuming you haven't also renamed events like qb-weathersync:client:EnableSync to rbp-weathersync:client:EnableSync or whatever, it should also work (make sure to update weathersync as well, since the exports used were just added today). Now when other resources trigger qb-weathersync:client:EnableSync, it just gets handed off to exports.weathersync:setSyncEnabled.

@ShaAlexander
Copy link
Author

Replacing the triggers seems to work but don't forget to change the fxmanifest as well, change the dependencies, or you will have other issues…

That is another way to do it. The way I was suggesting was to replace the rbp-weathersync resource, in your case, with basically a shell resource that hands off the qb-weathersync:... event triggers to weathersync:... ones. That way, you don't need to modify the qb-houses resource or its manifest, just the resource you're replacing anyways (qb-weathersync).

Yeah, i was definitely thinking about that, but rather did a clean job, so I made a back-up of the original ones, then I did a switcheroo within the code.

@didevlab
Copy link

didevlab commented Oct 15, 2022

Event fix ClockTime in RedM ->
NetworkClockTimeOverride(14, 30, 0, 10000, false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants