Giter Site home page Giter Site logo

qb-weathersync's Introduction

qb-weathersync

Synced weather and time for QB-Core Framework ๐ŸŒ…

License

QBCore Framework
Copyright (C) 2021 Joshua Eger

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>

Dependencies

Features

  • Syncs the weather for all players

Installation

Manual

  • Download the script and put it in the [qb] directory.
  • Add the following code to your server.cfg/resouces.cfg
ensure qb-core
ensure qb-weathersync

Configuration

You can adjust available weather and defaults in config.lua to adjust weather patterns you need to modify nextWeatherStage() in server/server.lua

Commands

/freezetime - Toggle time progression

/freezeweather - Toggle dynamic weather

/weather [type] - Set weather

/blackout - Toggle blackout

/morning - Set time to 9am

/noon - Set time to 12pm

/evening - Set time to 6pm

/night - Set time to 11pm

/time [hour] (minute) - Set time to whatever you want

Exports

nextWeatherStage

Triggers event to switch weather to next stage

-- LUA EXAMPLE
local success = exports["qb-weathersync"]:nextWeatherStage();
// JAVASCRIPT EXAMPLE
const success = global.exports["qb-weathersync"].nextWeatherStage();

setWeather [type]

Switch to a specified weather type from Config.AvailableWeatherTypes

-- LUA EXAMPLE
local success = exports["qb-weathersync"]:setWeather("snow");
// JAVASCRIPT EXAMPLE
const success = global.exports["qb-weathersync"].setWeather("snow");

setTime [hour] (minute)

Sets sun position based on time to specified

-- LUA EXAMPLE
local success = exports["qb-weathersync"]:setTime(8, 10); -- 8:10 AM
// JAVASCRIPT EXAMPLE
const success = global.exports["qb-weathersync"].setTime(15, 30); // 3:30PM

setBlackout (true|false)

Sets or toggles blackout state and returns the state

-- LUA EXAMPLE
local newStatus = exports["qb-weathersync"]:setBlackout(); -- Toggle
// JAVASCRIPT EXAMPLE
const newStatus = global.exports["qb-weathersync"].setBlackout(true); // Enable

setTimeFreeze (true|false)

Sets or toggles time freeze state and returns the state

-- LUA EXAMPLE
local newStatus = exports["qb-weathersync"]:setTimeFreeze(); -- Toggle
// JAVASCRIPT EXAMPLE
const newStatus = global.exports["qb-weathersync"].setTimeFreeze(true); // Enable

setDynamicWeather (true|false)

Sets or toggles dynamic weather state and returns the state

-- LUA EXAMPLE
local newStatus = exports["qb-weathersync"]:setDynamicWeather(); -- Toggle
// JAVASCRIPT EXAMPLE
const newStatus = global.exports["qb-weathersync"].setDynamicWeather(true); // Enable

getBlackoutState

Returns if blackout is enabled or disabled

-- LUA EXAMPLE
local state = exports["qb-weathersync"]:getBlackoutState();
// JAVASCRIPT EXAMPLE
const state = global.exports["qb-weathersync"].getBlackoutState();

getTimeFreezeState

Returns if time progression is enabled or disabled

-- LUA EXAMPLE
local state = exports["qb-weathersync"]:getTimeFreezeState();
// JAVASCRIPT EXAMPLE
const state = global.exports["qb-weathersync"].getTimeFreezeState();

getWeatherState

Returns the current weather type

-- LUA EXAMPLE
local currentWeather = exports["qb-weathersync"]:getWeatherState();
// JAVASCRIPT EXAMPLE
const currentWeather = global.exports["qb-weathersync"].getWeatherState();

getDynamicWeather

Returns if time progression is enabled or disabled

-- LUA EXAMPLE
local state = exports["qb-weathersync"]:getDynamicWeather();
// JAVASCRIPT EXAMPLE
const state = global.exports["qb-weathersync"].getDynamicWeather();

Events

qb-weathersync:server:RequestStateSync - Sync time and weather for everyone

qb-weathersync:server:setWeather [type] - Set Weather type (List in Config)

qb-weathersync:server:setTime [hour] (minute) - Set simulated time

qb-weathersync:server:toggleBlackout (true|false) - Enable, disable or toggle blackout

qb-weathersync:server:toggleFreezeTime (true|false) (minute) - Enable, disable or toggle time progression

qb-weathersync:server:toggleDynamicWeather (true|false) - Enable, disable or toggle dynamic weather

qb-weathersync's People

Contributors

berkiebb avatar brandonlazarre avatar codereddev avatar danielcoelh0 avatar darknight2590 avatar dennrick avatar eidertuning avatar evanillaa avatar ghzgarage avatar i-kulgu avatar idrisdose avatar leaudevian avatar lionh34rt avatar mataskc avatar matthewrorke avatar meta-hub avatar newtonzz avatar nicodk6400 avatar revonity avatar s33g avatar sna-aaa avatar synthethics avatar theilleniumstudios avatar tom-osborne avatar trushukas avatar unawarepuma avatar virus18sp avatar youremeh avatar z3rio avatar zfbx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.