Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
v1.1.0 release
Browse files Browse the repository at this point in the history
- 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
IamLation committed Jul 24, 2023
1 parent 1991d9c commit b5236ff
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 191 deletions.
12 changes: 12 additions & 0 deletions .vscode/settings.json
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"
]
}
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ You can open the bottle of oxy and in turn receive individual pills. With those
[Click here to join our Discord](https://discord.gg/9EbY4nM5uu)

## Features
- Supports ESX & QBCore
- Highly detailed config file
- Set as many (or as little) Pharmacy locations you want
- Create a list of as many (or as little) Doctor names
- Enable/disable Discord webhook logs
- Enable/disable health or armor effects upon use
- Enable/disable health effects upon oxycontin use
- Enable/disable armor effects upon oxycontin use
- Enable/disable "speed boost" effects upon oxycontin use
- Enable/disable screen effects upon oxycontin use
- Set random pricing when purchasing a blank script, or a fixed price
- Optimized 0.00 on use & idle
- Only supports ESX / easy to convert
- Highly detailed config file

## Dependencies
- [ox_inventory](https://github.com/overextended/ox_inventory/releases)
- [ox_lib](https://github.com/overextended/ox_lib/releases)
- [ox_target](https://github.com/overextended/ox_target/releases)
- [ox_target](https://github.com/overextended/ox_target/releases), [qb-target](https://github.com/qbcore-framework/qb-target) or [qtarget](https://github.com/overextended/ox_target/releases)

## Installation
- Ensure you have all dependencies installed
Expand Down
67 changes: 67 additions & 0 deletions bridge/client.lua
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
88 changes: 88 additions & 0 deletions bridge/server.lua
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
Loading

0 comments on commit b5236ff

Please sign in to comment.