This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added bridge for multi-framework support - Supports ESX & QBCore now - Added automatic framework detection for ESX/QB - Lots of code refactoring - Added new drug effects (speed & screen effects) - New drug effects completely customizable - Each effect can be individually toggled - Now supports qb-target & qtarget
- Loading branch information
Showing
8 changed files
with
405 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Lua.diagnostics.globals": [ | ||
"lib", | ||
"sendToDiscord", | ||
"ESX", | ||
"result", | ||
"spawnStartOxyRunPed", | ||
"startOxyRunDialog", | ||
"startOxyRunPed", | ||
"cache" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
PlayerLoaded, PlayerData = nil, {} | ||
|
||
local libState = GetResourceState('ox_lib') | ||
|
||
-- Get framework | ||
if GetResourceState('es_extended') == 'started' then | ||
ESX = exports['es_extended']:getSharedObject() | ||
Framework = 'esx' | ||
|
||
RegisterNetEvent('esx:onPlayerLogout', function() | ||
table.wipe(PlayerData) | ||
PlayerLoaded = false | ||
end) | ||
|
||
AddEventHandler('onResourceStart', function(resourceName) | ||
if GetCurrentResourceName() ~= resourceName or not ESX.PlayerLoaded then | ||
return | ||
end | ||
PlayerData = ESX.GetPlayerData() | ||
PlayerLoaded = true | ||
end) | ||
|
||
elseif GetResourceState('qb-core') == 'started' then | ||
QBCore = exports['qb-core']:GetCoreObject() | ||
Framework = 'qb' | ||
|
||
AddStateBagChangeHandler('isLoggedIn', '', function(_bagName, _key, value, _reserved, _replicated) | ||
if value then | ||
PlayerData = QBCore.Functions.GetPlayerData() | ||
else | ||
table.wipe(PlayerData) | ||
end | ||
PlayerLoaded = value | ||
end) | ||
|
||
AddEventHandler('onResourceStart', function(resourceName) | ||
if GetCurrentResourceName() ~= resourceName or not LocalPlayer.state.isLoggedIn then | ||
return | ||
end | ||
PlayerData = QBCore.Functions.GetPlayerData() | ||
PlayerLoaded = true | ||
end) | ||
else | ||
-- Add support for a custom framework here | ||
return | ||
end | ||
|
||
-- Use ox_lib notifications if ox_lib is found else use framework notifications | ||
ShowNotification = function(title, message, type) | ||
if libState == 'started' then | ||
lib.notify({ | ||
title = title, | ||
description = message, | ||
type = type, | ||
icon = Notifications.icon, | ||
position = Notifications.position | ||
}) | ||
else | ||
if Framework == 'esx' then | ||
ESX.ShowNotification(message) | ||
elseif Framework == 'qb' then | ||
QBCore.Functions.Notify(message, type) | ||
else | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
-- Get framework | ||
if GetResourceState('es_extended') == 'started' then | ||
ESX = exports['es_extended']:getSharedObject() | ||
Framework = 'esx' | ||
elseif GetResourceState('qb-core') == 'started' then | ||
QBCore = exports['qb-core']:GetCoreObject() | ||
Framework = 'qb' | ||
else | ||
-- Add support for a custom framework here | ||
return | ||
end | ||
|
||
-- Get player from source | ||
GetPlayer = function(source) | ||
if Framework == 'esx' then | ||
return ESX.GetPlayerFromId(source) | ||
elseif Framework == 'qb' then | ||
return QBCore.Functions.GetPlayer(source) | ||
else | ||
-- Add support for a custom framework here | ||
end | ||
end | ||
|
||
-- Get player's name from source | ||
GetName = function(source) | ||
local player = GetPlayer(source) | ||
if player then | ||
if Framework == 'esx' then | ||
return player.getName() | ||
elseif Framework == 'qb' then | ||
return player.PlayerData.charinfo.firstname..' '..player.PlayerData.charinfo.lastname | ||
end | ||
end | ||
end | ||
|
||
-- Get a players identifier | ||
GetIdentifier = function(source) | ||
local player = GetPlayer(source) | ||
if player then | ||
if Framework == 'esx' then | ||
return player.identifier | ||
elseif Framework == 'qb' then | ||
return player.PlayerData.citizenid | ||
end | ||
end | ||
end | ||
|
||
-- Function to register a usable item | ||
RegisterUsableItem = function(item, ...) | ||
if Framework == 'esx' then | ||
ESX.RegisterUsableItem(item, ...) | ||
elseif Framework == 'qb' then | ||
QBCore.Functions.CreateUseableItem(item, ...) | ||
else | ||
-- Add support for a custom framework here | ||
end | ||
end | ||
|
||
RemoveMoney = function(source, moneyType, amount) | ||
local player = GetPlayer(source) | ||
moneyType = ConvertMoneyType(moneyType) | ||
if player then | ||
if Framework == 'esx' then | ||
player.removeAccountMoney(moneyType, amount) | ||
elseif Framework == 'qb' then | ||
player.Functions.RemoveMoney(moneyType, amount) | ||
end | ||
end | ||
end | ||
|
||
ConvertMoneyType = function(moneyType) | ||
if moneyType == 'money' and Framework == 'qb' then | ||
moneyType = 'cash' | ||
elseif moneyType == 'cash' and Framework == 'esx' then | ||
moneyType = 'money' | ||
end | ||
return moneyType | ||
end | ||
|
||
GetPlayerAccountFunds = function(source, moneyType) | ||
local player = GetPlayer(source) | ||
moneyType = ConvertMoneyType(moneyType) | ||
if Framework == 'qb' then | ||
return player.PlayerData.money[moneyType] | ||
elseif Framework == 'esx' then | ||
return player.getAccount(moneyType).money | ||
end | ||
end |
Oops, something went wrong.