Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGrubb committed Sep 6, 2024
1 parent f59fef3 commit 0580862
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 192 deletions.
30 changes: 9 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,24 @@ Features:

If you need any support, feel free to reach out to us via our Discord: https://discord.gg/7NATz2Yw5a

### Version 1.0.4
- Added support for fivemerr logs (Thanks simsonas86)

### Version 1.0.3

- Restructured the Bridge table a bit better for frameworks
- Updated how init works for NUI.
- Comments for standalone framework setup

### Version 1.0.2

- Fixed issue with debugging in NUI and NUI path if resource is renamed

### Version 1.0.1

- Fixed issue with getting player source with ESX

### Dependencies

- Supports both ESX and QBCore
- oxmysql
- ox_lib

### Database
### Installation

Run the `__install/database.sql` file in your server's database.
`NOTE: As of v1.1.0, permissions system has changed to run off of ace permissions in your server.cfg`

### Drop the Resource
- Run the `__install/database.sql` file in your server's database.
- Download the main branch and drop the package into your resources folder and remember to `ensure ir8-tickets` after `ox_lib` and `oxmysql`
- Add the permissions principal to your `server.cfg`:

Download the main branch and drop the package into your resources folder and remember to `ensure ir8-tickets` after `ox_lib` and `oxmysql`
```
# Ticket Administration Ace
add_ace group.admin ticket.admin allow
```

### Configuration

Expand Down
4 changes: 4 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ if IR8.Bridge.Client.EventPlayerLoaded then
init()
end
end)
else
if not PlayerLoaded then
init()
end
end

-- Show the NUI
Expand Down
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'cerulean'
game 'gta5'
author 'IR8 Scripts'
description 'Ticket Manager'
version '1.0.4'
version '1.1.0'
lua54 'yes'

client_script 'client/main.lua'
Expand All @@ -15,7 +15,7 @@ server_script {
shared_script {
"@ox_lib/init.lua",
"shared/config.lua",
"shared/core.lua",
"shared/bridge.lua",
"shared/utilities.lua",
"shared/database.lua"
}
Expand Down
12 changes: 4 additions & 8 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ lib.addCommand(IR8.Config.Commands.Tickets, {
help = IR8.Config.Commands.TicketsDescription,
params = {}
}, function(source, args, raw)
if type(IR8.Bridge.Server.GetPlayerPermission) == "function" then
local hasAdminPermission = IR8.Utilities.HasPermission(IR8.Config.AdminPermissions, IR8.Bridge.Server.GetPlayerPermission(source))
TriggerClientEvent(IR8.Config.ClientCallbackPrefix .. "ShowNUI", source, hasAdminPermission)
else
print("[Error] Unable to call Bridge.Server.GetPlayerPermission")
end
local hasAdminPermission = IR8.Utilities.HasPermission(source)
TriggerClientEvent(IR8.Config.ClientCallbackPrefix .. "ShowNUI", source, hasAdminPermission)
end)

-------------------------------------------------
Expand All @@ -60,15 +56,15 @@ end

-- Return admin privs (bool)
lib.callback.register(IR8.Config.ServerCallbackPrefix .. "HasAdminPermissions", function (src)
return IR8.Utilities.HasPermission(IR8.Config.AdminPermissions, IR8.Bridge.Server.GetPlayerPermission(src))
return IR8.Utilities.HasPermission(src)
end)

-- Load all tickets
lib.callback.register(IR8.Config.ServerCallbackPrefix .. "Tickets_Load", function (src)
IR8.Utilities.DebugPrint('[EVENT] ' .. IR8.Bridge.Server.GetPlayerIdentifier(src) .. ' loaded ticket list data.')

-- Check if user has permissions and get their identifier
local hasAdminPermission = IR8.Utilities.HasPermission(IR8.Config.AdminPermissions, IR8.Bridge.Server.GetPlayerPermission(source))
local hasAdminPermission = IR8.Utilities.HasPermission(src)
local identifier = IR8.Bridge.Server.GetPlayerIdentifier(src)

-- Pull tickets based on privelage
Expand Down
144 changes: 144 additions & 0 deletions shared/bridge.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
------------------------------------------------------------
-- CORE BRIDGE DETERMINATION
------------------------------------------------------------
IR8.Bridge = {

Core = false,

Client = {
EventPlayerLoaded = false
},

-- Get the core object based on framework provided
GetCoreObject = function()
if not IR8.Bridge.Core then

-- If esx
if IR8.Config.Framework == 'esx' then
IR8.Bridge.Core = exports['es_extended']:getSharedObject()
IR8.Bridge.Client.EventPlayerLoaded = "esx:playerLoaded"

-- If qb
elseif IR8.Config.Framework == 'qb' then
IR8.Bridge.Core = exports['qb-core']:GetCoreObject()
IR8.Bridge.Client.EventPlayerLoaded = "QBCore:Client:OnPlayerLoaded"

-- If standalone
else
IR8.Bridge.Core = "none"
end
end

return IR8.Bridge.Core
end,

Server = {

GetPlayerName = function(src)

-- If esx
if IR8.Config.Framework == 'esx' and IR8.Bridge.Core then
local xPlayer = IR8.Bridge.Core.GetPlayerFromId(src)
if xPlayer == nil then
return nil
end
return xPlayer.getName()

-- If qb
elseif IR8.Config.Framework == 'qb' and IR8.Bridge.Core then
local Player = IR8.Bridge.Core.Functions.GetPlayer(src)
return Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname

-- If standalone
else
return nil
end
end,

GetPlayerIdentifier = function(src)

-- If esx
if IR8.Config.Framework == 'esx' and IR8.Bridge.Core then
local xPlayer = IR8.Bridge.Core.GetPlayerFromId(src)
if xPlayer == nil then
return nil
end
return xPlayer.getIdentifier()

-- If qb
elseif IR8.Config.Framework == 'qb' and IR8.Bridge.Core then
local Player = IR8.Bridge.Core.Functions.GetPlayer(src)
return Player.PlayerData.citizenid

-- If standalone
else
return nil
end
end,

GetPlayerPermission = function(src)
local groups = {}

-- If esx
if IR8.Config.Framework == 'esx' and IR8.Bridge.Core then
local xPlayer = IR8.Bridge.Core.GetPlayerFromId(src)
if xPlayer == nil then
return groups
end
local Group = xPlayer.getGroup()
table.insert(groups, Group)

-- If qb
elseif IR8.Config.Framework == 'qb' and IR8.Bridge.Core then
local permissions = IR8.Bridge.Core.Functions.GetPermission(src)

for g, hasPerm in pairs(permissions) do
if hasPerm == true then
table.insert(groups, g)
end
end

-- If standalone
else
-- If standalone, you need to write logic here for adding permission to group table
-- Example: ["admin"]
-- table.insert(groups, "admin")
end

return groups
end,

GetPlayerSourceIfOnlineByIdentifier = function(identifier)
local src = nil

-- Iterate through ESX online players and find the identifier that matches.
if IR8.Config.Framework == 'esx' and IR8.Bridge.Core then
local xPlayers = IR8.Bridge.Core.GetPlayers()

for i = 1, #xPlayers, 1 do
local xPlayer = IR8.Bridge.Core.GetPlayerFromId(xPlayers[i])

if xPlayer.getIdentifier() == identifier then
src = xPlayer.source
end
end

-- Find player by citizen id (only returns if online)
elseif IR8.Config.Framework == 'qb' and IR8.Bridge.Core then
local Player = IR8.Bridge.Core.Functions.GetPlayerByCitizenId(identifier)
if Player ~= nil then
src = Player.PlayerData.source
end

-- If standalone
else
-- If standalone, you need to write logic here for returning player's source id and
-- set it to src variable
end

return src
end
}
}

IR8.Bridge.Core = IR8.Config.Framework ~= 'none' and IR8.Bridge.GetCoreObject() or nil
9 changes: 3 additions & 6 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ IR8.Config = {
Framework = "qb", -- "esx" | "qb" | "none"

-- Event related vars
ServerCallbackPrefix = "ir8-tickets:Server", -- Change this if you rename the resource folder
ClientCallbackPrefix = "ir8-tickets:Client", -- Change this if you rename the resource folder
ServerCallbackPrefix = GetCurrentResourceName() .. ":Server",
ClientCallbackPrefix = GetCurrentResourceName() .. ":Client",

-- Ticket Configuration Variables
TicketConfiguration = {
Expand Down Expand Up @@ -65,10 +65,7 @@ IR8.Config = {
},

-- The following groups will have access to ticket administration
-- This uses either ESX Groups or QB Core Permissions
AdminPermissions = {
'admin'
},
AdminPermissions = { "ticket.admin" },

-- Command information
Commands = {
Expand Down
Loading

0 comments on commit 0580862

Please sign in to comment.