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

feat: implements the use of the police badge #849

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions server-data/resources/[esx]/stevo_lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## stevo_lib - 1.6.8
A library of functions & a bridge for Stevo Scripts resources.

Documentation: https://docs.stevoscripts.com/free-scripts/stevo_lib
<br>
Discord: https://discord.gg/stevoscripts
<br>
Website: https://www.stevoscripts.com


Credit: [Renewed Scripts](https://github.com/Renewed-Scripts) (bridge logic)

15 changes: 15 additions & 0 deletions server-data/resources/[esx]/stevo_lib/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
return {

useInteract = false, -- If https://github.com/darktrovx/interact should be used where possible

NotifyType = 'esx', -- Support for 'ox_lib' 'qb' 'esx' 'QBOX' 'okok' and 'custom' (custom requires editing)

TextUIType = 'ox_lib', -- Support for 'ox_lib' 'gtabasic' 'okok' and 'custom' (custom requires editing)

businesses = {
logs = false, -- Can be 'discord' or 'oxlogs' Check the documentation for info on installing discord logs.
},

skillsCommand = true,
skillsKeybind = true
}
34 changes: 34 additions & 0 deletions server-data/resources/[esx]/stevo_lib/customize.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local config = lib.require('config')



function stevo_lib.Notify(msg, type, duration)

if not duration then duration = 3000 end

if config.NotifyType == 'qb' or config.NotifyType == 'ESX' or config.NotifyType == 'QBOX' then
if stevo_lib.framework == config.NotifyType then
stevo_lib.bridgeNotify(msg, type, duration)
else
return error('config.NotifyType = '..config.NotifyType..' but server is not '..config.NotifyType..'')
end
end



if config.NotifyType == 'ox_lib' then
lib.notify({
title = msg,
type = type,
duration = duration
})
return true
elseif config.NotifyType == 'okok' then
exports['okokNotify']:Alert("🔔 Notification 🔔", msg, duration, type)
return true
elseif config.NotifyType == 'custom' then
return error('config.NotifyType = custom but no custom Notify was added.') -- Remove me if using custom notify.
end
end


38 changes: 38 additions & 0 deletions server-data/resources/[esx]/stevo_lib/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
fx_version 'cerulean'
game 'gta5'
use_experimental_fxv2_oal 'yes'
lua54 'yes'

author "Stevo Scripts | steve"
description 'A library of functions & a bridge for Stevo Scripts resources.'
version '1.6.9'

shared_script {
'@ox_lib/init.lua',
'config.lua'
}

client_scripts {
'init/client.lua',
'customize.lua',
'modules/functions/client.lua',
--'modules/skills/client.lua',
}

server_scripts {
'init/server.lua',
'modules/functions/server.lua',
--'modules/skills/server.lua',
'@oxmysql/lib/MySQL.lua'
}

files {
'modules/bridge/**/*.lua',
'modules/targets/*.lua',
'locales/*.json'
}

dependencies {
'ox_lib',
'oxmysql'
}
54 changes: 54 additions & 0 deletions server-data/resources/[esx]/stevo_lib/init/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
stevo_lib = {}

exports("import", function()
return stevo_lib
end)

-- Framework
local qb = GetResourceState('qb-core')
local qbx = GetResourceState('qbx_core')
local esx = GetResourceState('es_extended')
local ox = GetResourceState('ox_core')
local framework = ox == 'started' and 'ox' or qbx == 'started' and 'qbx' or qb == 'started' and 'qb' or esx == 'started' and 'esx' or nil
stevo_lib.framework = framework

if not framework then return error('Unable to find framework, This could be because you are using a modified framework name.') end


-- Target
local qb_trgt = GetResourceState('qb-target')
local ox_trgt = GetResourceState('ox_target')
local trgt = ox_trgt == 'started' and 'ox_target' or qb_trgt == 'started' and 'qb-target' or nil
stevo_lib.target = trgt

if ox_trgt == 'started' then
stevo_lib.target = 'ox_target'
end


if not trgt then return error('Unable to find target, This could be because you are using a modified target name.') end



local file_paths = {
('modules/bridge/%s/client.lua'):format(framework),
('modules/targets/%s.lua'):format(trgt),
}

for _, file_path in ipairs(file_paths) do
local resourceFile = LoadResourceFile(cache.resource, file_path)

if not resourceFile then
return error(("Unable to find file at path '%s'"):format(file_path))
end

local ld, err = load(resourceFile, ('@@%s/%s'):format(cache.resource, file_path))

if not ld or err then
return error(err)
end

ld()
end


38 changes: 38 additions & 0 deletions server-data/resources/[esx]/stevo_lib/init/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
stevo_lib = {}

exports("import", function()
return stevo_lib
end)

-- Framework
local qb = GetResourceState('qb-core')
local qbox = GetResourceState('qbx_core')
local esx = GetResourceState('es_extended')
local ox = GetResourceState('ox_core')
local framework = ox == 'started' and 'ox' or qbox == 'started' and 'qb' or qb == 'started' and 'qb' or esx == 'started' and 'esx' or nil

if not framework then return error('Unable to find framework, This could be because you are using a modified framework name.') end

stevo_lib.framework = framework

local file_paths = {
('modules/bridge/%s/server.lua'):format(framework),
}

for _, file_path in ipairs(file_paths) do
local resourceFile = LoadResourceFile(cache.resource, file_path)

if not resourceFile then
return error(("Unable to find script at path '%s'"):format(file_path))
end

local ld, err = load(resourceFile, ('@@%s/%s'):format(cache.resource, file_path))

if not ld or err then
return error(err)
end

ld()
end


32 changes: 32 additions & 0 deletions server-data/resources/[esx]/stevo_lib/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{

"skills_command": "openskills",
"skills_menu_title": "Player Skills",
"skills_no_skills": "You are not skilled. lol",

"deployed_business_database": "Deployed database table for stevo_businesses",
"deployed_employee_database": "Deployed database table for stevo_businesses_employees",
"registered_business" : "Registered Business - %s - %s - %s",
"created_register" : "Created Register - %s - %s ",

"register_label" : "Register",
"staff_register_label" : "Manage Register",
"register_in_use" : "Register currently in use",
"register_availible" : "Register available",
"clear_register" : "Clear Register",
"cleared_register" : "You cleared register: %s",
"use_register" : "Create Bill",
"bill_item" : "Bill item: %s",
"bill_amount" : "Bill Amount: $%s",
"bill_amount_empty" : "Bill Amount: Not Set",
"bill_create" : "Create bill",
"cancelled_input" : "You cancelled this action",
"bill_create_item_set" : "Set Bill item to %s",
"bill_create_amount_set" : "Set Bill amount to $%s",
"bill_create_input_amount" : "Bill Amount",
"bill_create_input_item" : "Bill Item",
"bill_not_set" : "Not Set",
"created_bill" : "Created $%s bill for %s",
"register_not_open" : "Register is closed",
"pay_bill" : "Pay bill"
}
3 changes: 3 additions & 0 deletions server-data/resources/[esx]/stevo_lib/locales/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
3 changes: 3 additions & 0 deletions server-data/resources/[esx]/stevo_lib/locales/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local ESX = exports.es_extended:getSharedObject()
local isDead
local PlayerData = ESX.GetPlayerData()

function stevo_lib.bridgeNotify(msg, type, duration)
ESX.ShowNotification(msg, type, duration)
end

function stevo_lib.GetPlayerGroups()
return PlayerData.job.name, false
end

function stevo_lib.IsDead()
return isDead
end

function stevo_lib.GetSex()
return PlayerData.sex == 'Male' and 1 or 2
end

function stevo_lib.SetOutfit(outfit)
if outfit then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadClothes', skin, outfit)
end)
else
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
end
end

AddEventHandler('esx:onPlayerSpawn', function(noAnim)
isDead = nil
end)

RegisterNetEvent('esx:setJob', function(job)
PlayerData.job = job
end)

AddEventHandler('esx:onPlayerDeath', function(data)
isDead = true
end)

RegisterNetEvent('esx:playerLoaded', function()
TriggerEvent('stevo_lib:playerLoaded')
end)




104 changes: 104 additions & 0 deletions server-data/resources/[esx]/stevo_lib/modules/bridge/esx/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
local ESX = exports.es_extended:getSharedObject()
local ox_inventory = GetResourceState('ox_inventory') == 'started' and true or false

function stevo_lib.GetPlayer(source)
return ESX.GetPlayerFromId(source)
end

function stevo_lib.GetIdentifier(source)
local player = stevo_lib.GetPlayer(source)
return player.getIdentifier()
end

function stevo_lib.GetName(source)
local player = stevo_lib.GetPlayer(source)
return player.getName()
end

function stevo_lib.GetJobCount(source, job)
return ESX.GetExtendedPlayers('job', job)
end

function stevo_lib.GetPlayerGroups(source)
local player = stevo_lib.GetPlayer(source)
local job = player.getJob()
return job.name, false
end

function stevo_lib.GetPlayerJobInfo(source)
local player = stevo_lib.GetPlayer(source)
local job = player.getJob()
local jobInfo = {
name = job.name,
label = job.label,
grade = job.grade,
gradeLabel = job.grade_label,
}
return jobInfo
end

function stevo_lib.GetPlayerGangInfo(source)
return false
end

function stevo_lib.GetPlayers()
local players = ESX.GetExtendedPlayers()
local formattedPlayers = {}
for _, v in pairs(players) do
local player = {
job = v.getJob().name,
gang = false,
source = v.source
}
table.insert(formattedPlayers, player)
end
return formattedPlayers
end

function stevo_lib.GetDob(source)
local player = stevo_lib.GetPlayer(source)
return player.variables.dateofbirth
end

function stevo_lib.GetSex(source)
local player = stevo_lib.GetPlayer(source)
return player.variables.sex
end

function stevo_lib.RemoveItem(source, item, count)
local player = stevo_lib.GetPlayer(source)
return player.removeInventoryItem(item, count)
end

function stevo_lib.AddItem(source, item, count)
local player = stevo_lib.GetPlayer(source)
return player.addInventoryItem(item, count)
end

function stevo_lib.HasItem(source, _item)
local player = stevo_lib.GetPlayer(source)
local item = player.getInventoryItem(_item)
return item?.amount or item?.count or 0
end

function stevo_lib.GetInventory(source)
local player = stevo_lib.GetPlayer(source)
local items = {}
local data = ox_inventory and exports.ox_inventory:GetInventoryItems(source) or player.getInventory()
for i=1, #data do
local item = data[i]
items[#items + 1] = {
name = item.name,
label = item.label,
count = ox_inventory and item.count or item.amount,
weight = item.weight,
metadata = ox_inventory and item.metadata or item.info
}
end
return items
end

function stevo_lib.RegisterUsableItem(item, cb)
ESX.RegisterUsableItem(item, cb)
end

Loading
Loading