-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40df466
commit fc96bc5
Showing
14 changed files
with
568 additions
and
140 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
68 changes: 68 additions & 0 deletions
68
server-data/resources/[wasabi]/wasabi_fishing/bridge/esx/client.lua
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,68 @@ | ||
if GetResourceState("es_extended") ~= "started" then | ||
return | ||
end | ||
ESX = exports["es_extended"]:getSharedObject() | ||
Framework, PlayerLoaded, PlayerData = "esx", nil, {} | ||
|
||
RegisterNetEvent("esx:playerLoaded", function(xPlayer) | ||
PlayerData = xPlayer | ||
PlayerLoaded = true | ||
end) | ||
|
||
RegisterNetEvent("esx:onPlayerSpawn", function() | ||
TriggerEvent("wasabi_fishing:onPlayerSpawn") | ||
end) | ||
|
||
AddEventHandler("esx:onPlayerDeath", function(data) | ||
TriggerEvent("wasabi_fishing:onPlayerDeath") | ||
end) | ||
|
||
RegisterNetEvent("esx:onPlayerLogout", function() | ||
table.wipe(PlayerData) | ||
PlayerLoaded = false | ||
end) | ||
|
||
RegisterNetEvent("esx:setJob", function(job) | ||
PlayerData.job = job | ||
end) | ||
|
||
AddEventHandler("onResourceStart", function(resourceName) | ||
if GetCurrentResourceName() ~= resourceName or not ESX.PlayerLoaded then | ||
return | ||
end | ||
PlayerData = ESX.GetPlayerData() | ||
PlayerLoaded = true | ||
end) | ||
|
||
AddEventHandler("esx:setPlayerData", function(key, value) | ||
if GetInvokingResource() ~= "es_extended" then | ||
return | ||
end | ||
PlayerData[key] = value | ||
end) | ||
|
||
function HasGroup(filter) | ||
local type = type(filter) | ||
|
||
if type == "string" then | ||
if PlayerData.job.name == filter then | ||
return PlayerData.job.name, PlayerData.job.grade | ||
end | ||
else | ||
local tabletype = table.type(filter) | ||
|
||
if tabletype == "hash" then | ||
local grade = filter[PlayerData.job.name] | ||
|
||
if grade and grade <= PlayerData.job.grade then | ||
return PlayerData.job.name, PlayerData.job.grade | ||
end | ||
elseif tabletype == "array" then | ||
for i = 1, #filter do | ||
if PlayerData.job.name == filter[i] then | ||
return PlayerData.job.name, PlayerData.job.grade | ||
end | ||
end | ||
end | ||
end | ||
end |
91 changes: 91 additions & 0 deletions
91
server-data/resources/[wasabi]/wasabi_fishing/bridge/esx/server.lua
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,91 @@ | ||
if GetResourceState("es_extended") ~= "started" then | ||
return | ||
end | ||
ESX = exports["es_extended"]:getSharedObject() | ||
Framework = "esx" | ||
|
||
function GetPlayer(source) | ||
return ESX.GetPlayerFromId(source) | ||
end | ||
|
||
function KickPlayer(source, reason) | ||
local player = GetPlayer(source) | ||
return player.kick(reason) | ||
end | ||
|
||
function HasGroup(source, filter) | ||
local player = GetPlayer(source) | ||
local type = type(filter) | ||
|
||
if type == "string" then | ||
if player.job.name == filter then | ||
return player.job.name, player.job.grade | ||
end | ||
else | ||
local tabletype = table.type(filter) | ||
|
||
if tabletype == "hash" then | ||
local grade = filter[player.job.name] | ||
|
||
if grade and grade <= player.job.grade then | ||
return player.job.name, player.job.grade | ||
end | ||
elseif tabletype == "array" then | ||
for i = 1, #filter do | ||
if player.job.name == filter[i] then | ||
return player.job.name, player.job.grade | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
function GetIdentifier(source) | ||
local xPlayer = ESX.GetPlayerFromId(source) | ||
return xPlayer.identifier | ||
end | ||
|
||
function GetName(source) | ||
local xPlayer = ESX.GetPlayerFromId(source) | ||
return xPlayer.getName() | ||
end | ||
|
||
function RegisterUsableItem(item, cb) | ||
ESX.RegisterUsableItem(item, cb) | ||
end | ||
|
||
function HasItem(source, item) | ||
local player = GetPlayer(source) | ||
local item = player.getInventoryItem(item) | ||
if item ~= nil then | ||
return item.count | ||
else | ||
return 0 | ||
end | ||
end | ||
|
||
function AddItem(source, item, count, slot, metadata) | ||
local player = GetPlayer(source) | ||
return player.addInventoryItem(item, count, metadata, slot) | ||
end | ||
|
||
function RemoveItem(source, item, count, slot, metadata) | ||
local player = GetPlayer(source) | ||
player.removeInventoryItem(item, count, metadata, slot) | ||
end | ||
|
||
function AddMoney(source, type, amount) | ||
if type == "cash" then | ||
type = "money" | ||
end | ||
local player = GetPlayer(source) | ||
player.addAccountMoney(type, amount) | ||
end | ||
|
||
function RemoveMoney(source, type, amount) | ||
if type == "cash" then | ||
type = "money" | ||
end | ||
local player = GetPlayer(source) | ||
player.removeAccountMoney(type, amount) | ||
end |
91 changes: 91 additions & 0 deletions
91
server-data/resources/[wasabi]/wasabi_fishing/bridge/qb/client.lua
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,91 @@ | ||
if GetResourceState("qb-core") ~= "started" then | ||
return | ||
end | ||
QBCore = exports["qb-core"]:GetCoreObject() | ||
Framework, PlayerLoaded, PlayerData = "qb", nil, {} | ||
|
||
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) | ||
|
||
AddEventHandler("gameEventTriggered", function(event, data) | ||
if event ~= "CEventNetworkEntityDamage" then | ||
return | ||
end | ||
local victim, victimDied = data[1], data[4] | ||
if not IsPedAPlayer(victim) then | ||
return | ||
end | ||
local player = PlayerId() | ||
if | ||
victimDied | ||
and NetworkGetPlayerIndexFromPed(victim) == player | ||
and (IsPedDeadOrDying(victim, true) or IsPedFatallyInjured(victim)) | ||
then | ||
TriggerEvent("wasabi_fishing:onPlayerDeath") | ||
end | ||
end) | ||
|
||
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function() | ||
TriggerEvent("wasabi_fishing:onPlayerSpawn") | ||
end) | ||
|
||
RegisterNetEvent("QBCore:Player:SetPlayerData", function(newPlayerData) | ||
if source ~= "" and GetInvokingResource() ~= "qb-core" then | ||
return | ||
end | ||
PlayerData = newPlayerData | ||
end) | ||
|
||
function HasGroup(filter) | ||
local groups = { "job", "gang" } | ||
local type = type(filter) | ||
|
||
if type == "string" then | ||
for i = 1, #groups do | ||
local data = PlayerData[groups[i]] | ||
|
||
if data.name == filter then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
else | ||
local tabletype = table.type(filter) | ||
|
||
if tabletype == "hash" then | ||
for i = 1, #groups do | ||
local data = PlayerData[groups[i]] | ||
local grade = filter[data.name] | ||
|
||
if grade and grade <= data.grade.level then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
elseif tabletype == "array" then | ||
for i = 1, #filter do | ||
local group = filter[i] | ||
|
||
for j = 1, #groups do | ||
local data = PlayerData[groups[j]] | ||
|
||
if data.name == group then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
98 changes: 98 additions & 0 deletions
98
server-data/resources/[wasabi]/wasabi_fishing/bridge/qb/server.lua
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,98 @@ | ||
if GetResourceState('qb-core') ~= 'started' then return end | ||
QBCore = exports['qb-core']:GetCoreObject() | ||
Framework = 'qb' | ||
|
||
function GetPlayer(source) | ||
return QBCore.Functions.GetPlayer(source) | ||
end | ||
|
||
function KickPlayer(source, reason) | ||
QBCore.Functions.Kick(source, reason, true, true) | ||
end | ||
|
||
function HasGroup(source, filter) | ||
local groups = { 'job', 'gang' } | ||
local player = GetPlayer(source) | ||
local type = type(filter) | ||
|
||
if type == 'string' then | ||
for i = 1, #groups do | ||
local data = player.PlayerData[groups[i]] | ||
|
||
if data.name == filter then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
else | ||
local tabletype = table.type(filter) | ||
|
||
if tabletype == 'hash' then | ||
for i = 1, #groups do | ||
local data = player.PlayerData[groups[i]] | ||
local grade = filter[data.name] | ||
|
||
if grade and grade <= data.grade.level then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
elseif tabletype == 'array' then | ||
for i = 1, #filter do | ||
local group = filter[i] | ||
|
||
for j = 1, #groups do | ||
local data = player.PlayerData[groups[j]] | ||
|
||
if data.name == group then | ||
return data.name, data.grade.level | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
function GetIdentifier(source) | ||
local xPlayer = QBCore.Functions.GetPlayer(source) | ||
return xPlayer.PlayerData.citizenid | ||
end | ||
|
||
function GetName(source) | ||
local xPlayer = QBCore.Functions.GetPlayer(source) | ||
return xPlayer.PlayerData.charinfo.firstname..' '..xPlayer.PlayerData.charinfo.lastname | ||
end | ||
|
||
function RegisterUsableItem(item, cb) | ||
QBCore.Functions.CreateUseableItem(item, cb) | ||
end | ||
|
||
function HasItem(source, item) | ||
local player = GetPlayer(source) | ||
local item = player.Functions.GetItemByName(item) | ||
if GetResourceState('ox_inventory') == 'started' then | ||
return item?.count or 0 | ||
else | ||
return item?.amount or 0 | ||
end | ||
end | ||
|
||
function AddItem(source, item, count, slot, metadata) | ||
local player = GetPlayer(source) | ||
return player.Functions.AddItem(item, count, slot, metadata) | ||
end | ||
|
||
function RemoveItem(source, item, count, slot, metadata) | ||
local player = GetPlayer(source) | ||
player.Functions.RemoveItem(item, count, slot, metadata) | ||
end | ||
|
||
function AddMoney(source, type, amount) | ||
if type == 'money' then type = 'cash' end | ||
local player = GetPlayer(source) | ||
player.Functions.AddMoney(type, amount) | ||
end | ||
|
||
function RemoveMoney(source, type, amount) | ||
if type == 'money' then type = 'cash' end | ||
local player = GetPlayer(source) | ||
player.Functions.RemoveMoney(type, amount) | ||
end |
Oops, something went wrong.