Compare commits

...

14 Commits

Author SHA1 Message Date
Jim Shield
23c2e1472e Merge pull request #19 from jimathy/1.0.11
1.0.11
2024-01-30 19:21:33 +00:00
Jim Shield
6367c9ed3b remove loadmodel debug timeout print 2024-01-30 18:47:23 +00:00
Jim Shield
2d299a6a4a chargePlayer & fundPlayer server events/fixes 2024-01-30 18:40:26 +00:00
Jim Shield
ced629d4dc dupewarn info addition 2024-01-30 18:39:51 +00:00
Jim Shield
714121d272 crafting menu workarounds for missing info 2024-01-30 18:38:57 +00:00
Jim Shield
14c140cf85 load model and prop fixes 2024-01-29 22:23:23 +00:00
Jim Shield
881aec7c04 remove ox_lib model check as it was erroring out 2024-01-29 13:27:00 +00:00
Jim Shield
85b31e7e1d getRandomReward added for reward item support 2024-01-29 13:23:02 +00:00
Jim Shield
66c9287202 v1.0.11 - Version Bump 2024-01-28 19:24:19 +00:00
Jim Shield
f0f59b8568 remove debug print 2024-01-28 19:19:58 +00:00
Jim Shield
e03efa6687 update stopAnim to choose ped 2024-01-28 19:19:24 +00:00
Jim Shield
5a22651961 fix ConsumeSuccess and other typos 2024-01-28 19:18:55 +00:00
Jim Shield
236689452e custom stash slot sizes at "register" 2024-01-28 19:17:57 +00:00
Jim Shield
b686f267e1 Remove debug print 2024-01-28 01:44:53 +00:00
5 changed files with 116 additions and 55 deletions

View File

@@ -61,7 +61,6 @@ function craftingMenu(data)
Wait(0) Wait(0)
end end
while not canCarryTable do Wait(0) end while not canCarryTable do Wait(0) end
print(json.encode(canCarryTable, {indent = true}))
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
if data.stashName then disable = not stashhasItem(stashItems, itemTable) if data.stashName then disable = not stashhasItem(stashItems, itemTable)
else disable = not hasItem(itemTable) end else disable = not hasItem(itemTable) end
@@ -130,9 +129,9 @@ function makeItem(data)
CraftLock = true CraftLock = true
local bartime = data.craftable.progressBar and data.craftable.progressBar.time or 5000 local bartime = data.craftable.progressBar and data.craftable.progressBar.time or 5000
local bartext = data.craftable.progressBar and data.craftable.progressBar.label or Loc[Config.Lan].progressbar["progress_make"] local bartext = (data.craftable.progressBar and data.craftable.progressBar.label) or (Loc[Config.Lan].progressbar and Loc[Config.Lan].progressbar["progress_make"]) or "Making a"
local animDict = data.craftable.Anims.animDict or "amb@prop_human_parking_meter@male@idle_a" local animDict = data.craftable.Anims and data.craftable.Anims.animDict or "amb@prop_human_parking_meter@male@idle_a"
local anim = data.craftable.Anims.anim or "idle_a" local anim = data.craftable.Anims and data.craftable.Anims.anim or "idle_a"
local amount = data.amount and (data.amount ~= 1) and data.amount or 1 local amount = data.amount and (data.amount ~= 1) and data.amount or 1
local crafted, crafting = true, true local crafted, crafting = true, true
@@ -227,15 +226,18 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
if GetResourceState(OXInv):find("start") then if GetResourceState(OXInv):find("start") then
foundInv = OXInv foundInv = OXInv
grabInv = src and exports.ox_inventory:GetInventoryItems(src) or exports[OXInv]:GetPlayerItems() if src then grabInv = exports[OXInv]:GetInventoryItems(src)
else grabInv = exports[OXInv]:GetPlayerItems() end
elseif GetResourceState(QSInv):find("start") then elseif GetResourceState(QSInv):find("start") then
foundInv = QSInv foundInv = QSInv
grabInv = src and exports[QSInv]:GetInventory(src) or exports[QSInv]:getUserInventory() if src then grabInv = exports[QSInv]:GetInventory(src)
else grabInv = exports[QSInv]:getUserInventory() end
elseif GetResourceState(OrigenInv):find("start") then elseif GetResourceState(OrigenInv):find("start") then
foundInv = OrigenInv foundInv = OrigenInv
grabInv = src and exports[OrigenInv]:getPlayerInventory(src) or exports[OrigenInv]:getPlayerInventory() if src then grabInv = exports[OrigenInv]:getPlayerInventory(src)
else grabInv = exports[OrigenInv]:getPlayerInventory() end
elseif GetResourceState(CoreInv):find("start") then elseif GetResourceState(CoreInv):find("start") then
foundInv = CoreInv foundInv = CoreInv
@@ -473,7 +475,6 @@ if IsDuplicityVersion() then
end end
function canCarry(itemTable, src) function canCarry(itemTable, src)
print("checking if player can carry")
local resultTable = {} local resultTable = {}
if src then if src then
if GetResourceState(OXInv):find("start") then if GetResourceState(OXInv):find("start") then
@@ -520,4 +521,40 @@ function canCarry(itemTable, src)
end end
end end
return resultTable return resultTable
end
function getRandomReward(itemName) -- intended for job scripts
if Config.Rewards.RewardPool then
local reward = false
if type(Config.Rewards.RewardItem) == "string" then Config.Rewards.RewardItem = { Config.Rewards.RewardItem } end
for k, v in pairs(Config.Rewards.RewardItem) do
if v == itemName then reward = true break end
end
if reward then
removeItem(itemName, 1)
local totalRarity = 0
for i=1, #Config.Rewards.RewardPool do
totalRarity += Config.Rewards.RewardPool[i].rarity
end
if Config.System.Debug then
print("^6Bridge^7: ^3getRandomReward^7: ^2Total Rarity ^7'^6"..totalRarity.."^7'")
end
local randomNum = math.random(1, totalRarity)
if Config.System.Debug then
print("^6Bridge^7: ^3getRandomReward^7: ^2Random Number ^7'^6"..randomNum.."^7'")
end
local currentRarity = 0
for i=1, #Config.Rewards.RewardPool do
currentRarity += Config.Rewards.RewardPool[i].rarity
if randomNum <= currentRarity then
if Config.System.Debug then
print("^6Bridge^7: ^3getRandomReward^7: ^2Selected toy ^7'^6"..Config.Rewards.RewardPool[i].item.."^7'")
end
addItem(Config.Rewards.RewardPool[i].item, 1)
return
end
end
end
end
end end

View File

@@ -8,17 +8,14 @@ function jobCheck(job)
return canDo return canDo
end end
local time = 100 local time = 500
function loadModel(model) function loadModel(model)
if not IsModelValid(model) then print("^6Bridge^7: ^1ERROR^7: ^2Model^7 - '^6"..model.."^7' ^2does not exist in server") return if not IsModelValid(model) then print("^6Bridge^7: ^1ERROR^7: ^2Model^7 - '^6"..model.."^7' ^2does not exist in server") return
else else
if not HasModelLoaded(model) then if not HasModelLoaded(model) then
if Config.System.Debug then if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") while not HasModelLoaded(model) and time > 0 do time -= 1 RequestModel(model) Wait(0) end
end if not HasModelLoaded(model) then time = 500 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
if lib then lib.requestModel(model, time)
else while not HasModelLoaded(model) and time > 0 do time -= 1 end end
if not HasModelLoaded(model) then time = 100 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
end end
end end
end end
@@ -28,8 +25,7 @@ function loadAnimDict(animDict)
if not DoesAnimDictExist(animDict) then print("^6Bridge^7: ^1ERROR^7: ^2Anim Dictionary^7 - '^6"..animDict.."^7' ^2does not exist in server") return if not DoesAnimDictExist(animDict) then print("^6Bridge^7: ^1ERROR^7: ^2Anim Dictionary^7 - '^6"..animDict.."^7' ^2does not exist in server") return
else else
if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..animDict.."^7'") end if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..animDict.."^7'") end
if lib then lib.requestAnimDict(animDict, 100) while not HasAnimDictLoaded(animDict) do RequestAnimDict(animDict) Wait(5) end
else while not HasAnimDictLoaded(animDict) do RequestAnimDict(animDict) Wait(5) end end
end end
end end
function unloadAnimDict(animDict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary from memory cache^7: '^6"..animDict.."^7'") end RemoveAnimDict(animDict) end function unloadAnimDict(animDict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary from memory cache^7: '^6"..animDict.."^7'") end RemoveAnimDict(animDict) end
@@ -37,12 +33,9 @@ function unloadAnimDict(animDict) if Config.System.Debug then print("^6Bridge^7:
function loadPtfxDict(ptFxName) function loadPtfxDict(ptFxName)
if not HasNamedPtfxAssetLoaded(ptFxName) then if not HasNamedPtfxAssetLoaded(ptFxName) then
if Config.System.Debug then if Config.System.Debug then
if not HasNamedPtfxAssetLoaded(ptFxName) then print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..ptFxName.."^7'")
print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..ptFxName.."^7'")
end
end end
if lib then lib.requestNamedPtfxAsset(ptFxName, 100) while not HasNamedPtfxAssetLoaded(ptFxName) do RequestNamedPtfxAsset(ptFxName) Wait(5) end
else while not HasNamedPtfxAssetLoaded(ptFxName) do RequestNamedPtfxAsset(ptFxName) Wait(5) end end
end end
end end
function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end
@@ -51,8 +44,7 @@ function loadTextureDict(dict)
if Config.System.Debug then if Config.System.Debug then
print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'")
end end
if lib then lib.requestStreamedTextureDict(textureDict, timeout) while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end
else while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end
end end
end end
@@ -65,8 +57,8 @@ function playAnim(animDict, animName, duration, flag, ped)
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.0, duration or 30000, flag or 50, 1, false, false, false) TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.0, duration or 30000, flag or 50, 1, false, false, false)
end end
function stopAnim(animDict, animName) function stopAnim(animDict, animName, ped)
StopAnimTask(PlayerPedId(), animName, animDict) StopAnimTask(ped and ped or PlayerPedId(), animName, animDict)
unloadAnimDict(animDict) unloadAnimDict(animDict)
end end
@@ -93,7 +85,7 @@ local Peds = {}
local Props = {} local Props = {}
function makePed(model, coords, freeze, collision, scenario, anim, synced) function makePed(model, coords, freeze, collision, scenario, anim, synced)
loadModel(model) loadModel(model)
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, synced and synced or true, false) local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, synced or true, false)
SetEntityInvincible(ped, true) SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true) SetBlockingOfNonTemporaryEvents(ped, true)
FreezeEntityPosition(ped, freeze and freeze or true) FreezeEntityPosition(ped, freeze and freeze or true)
@@ -115,7 +107,7 @@ end
function makeProp(data, freeze, synced) function makeProp(data, freeze, synced)
loadModel(data.prop) loadModel(data.prop)
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced or false, synced or false, false) local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, freeze or false, synced or false, false)
SetEntityHeading(prop, data.coords.w + 180.0) SetEntityHeading(prop, data.coords.w + 180.0)
FreezeEntityPosition(prop, freeze and freeze or 0) FreezeEntityPosition(prop, freeze and freeze or 0)
if Config.System.Debug then if Config.System.Debug then
@@ -527,7 +519,7 @@ end)
RegisterNetEvent(GetCurrentResourceName()..":server:setNeed", function(type, amount) local src = source RegisterNetEvent(GetCurrentResourceName()..":server:setNeed", function(type, amount) local src = source
if type == "thirst" then if type == "thirst" then
setThirst(src, amount) setThirst(src, amount)
elseif type == "thirst" then elseif type == "hunger" then
setHunger(src, amount) setHunger(src, amount)
end end
end) end)
@@ -564,8 +556,8 @@ end
-- [[CONSUME]] -- -- [[CONSUME]] --
function ConsumeSuccess(itemName, type) function ConsumeSuccess(itemName, type)
ExecuteCommand("e c") ExecuteCommand("e c")
toggleItem(false, itemName, 1) removeItem(itemName, 1)
if GetResourceState(ESXEport):find("start") then if GetResourceState(ESXExport):find("start") then
if Items[itemName].hunger then if Items[itemName].hunger then
TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Items[itemName].hunger * 10000) TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Items[itemName].hunger * 10000)
end end
@@ -581,17 +573,22 @@ function ConsumeSuccess(itemName, type)
end end
end end
if type == "alcohol" then alcoholCount += 1 if type == "alcohol" then alcoholCount += 1
if alcoholCount > 1 and alcoholCount < 4 then TriggerEvent("evidence:client:SetStatus", "alcohol", 200) elseif alcoholCount >= 4 then TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200) AlienEffect() end if alcoholCount > 1 and alcoholCount < 4 then
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
elseif alcoholCount >= 4 then
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
AlienEffect()
end
end end
if Config.RewardItem == itemName then toggleItem(true, Config.RewardPool[math.random(1, #Config.RewardPool)], 1) end getRandomReward(itemName) -- check if a reward item should be given
end end
function addItem(item, amount, info) function addItem(item, amount, info)
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", true, item, amount) TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", true, item, amount, nil, info)
end end
function removeItem(item, amount) function removeItem(item, amount)
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", false, item, amount) TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", false, item, amount, nil, info)
end end
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc) RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
@@ -653,7 +650,7 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end end
else else
dupeWarn(src, item) -- if not boot the player dupeWarn(src, item, amount) -- if not boot the player
end end
else else
local amount = amount and amount or 1 local amount = amount and amount or 1
@@ -708,10 +705,10 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
end) end)
--Item Exploit protection --Item Exploit protection
function dupeWarn(src, item) function dupeWarn(src, item, amount)
print("^5DupeWarn^7: (^1"..tostring(src).."^7) ^2Tried to remove item ^7('^3"..item.."^7')^2 but it wasn't there^7") print("^5DupeWarn^7: (^1"..tostring(src).."^7) ^2Tried to remove item ^7('^3"..item.."^7')^2 but it wasn't there^7")
if Config.System.Debug == false then if Config.System.Debug == false then
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items") DropPlayer(src, src.." ^1Kicked for suspected duplicating items:"..item)
end end
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^7") print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^7")
end end

View File

@@ -1,6 +1,6 @@
name "Jim_Bridge" name "Jim_Bridge"
author "Jimathy" author "Jimathy"
version "1.0.10" version "1.0.11"
description "Framework Bridge By Jimathy" description "Framework Bridge By Jimathy"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"

View File

@@ -1 +1 @@
1.0.10 1.0.11

View File

@@ -1003,31 +1003,58 @@ AddStateBagChangeHandler(GetCurrentResourceName()..':setVehicleProperties', '',
end end
end) end)
RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type) local src = source RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type) end local src = newsrc or source
local fundResource = ""
if type == "cash" then if type == "cash" then
if GetResourceState(OXInv):find("start") then if GetResourceState(OXInv):find("start") then fundResource = OXInv
exports[OXInv]:RemoveItem(src, "money", cost) exports[OXInv]:RemoveItem(src, "money", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, OXInv) end elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
elseif GetResourceState(QBExport):find("start") then
Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src) local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "") Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end end
end end
if type == "bank" then if type == "bank" then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src) local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "") Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end end
end end
if fundResource == "" then print("error - check exports.lua")
else
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player^7: '^6"..cost.."^7'", type, fundResource) end
end
end)
RegisterNetEvent(GetCurrentResourceName()..":server:FundPlayer", function(fund, type, newsrc)
local src = newsrc or source
local fundResource = ""
if type == "cash" then
if GetResourceState(OXInv):find("start") then fundResource = OXInv
exports[OXInv]:AddItem(src, "money", fund)
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund)
elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
local Player = ESX.GetPlayerFromId(src)
Player.addMoney(fund, "")
end
end
if type == "bank" then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund)
elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
local Player = ESX.GetPlayerFromId(src)
Player.addMoney(fund, "")
end
end
if fundResource == "" then print("error - check exports.lua")
else
if Config.System.Debug then print("^6Bridge^7: ^2Funding ^2Player^7: '^2"..fund.."^7'", type, fundResource) end
end
end) end)
function createUseableItem(item, funct) function createUseableItem(item, funct)
@@ -1326,13 +1353,13 @@ function invImg(item)
return imgLink return imgLink
end end
function registerStash(name, label) function registerStash(name, label, slots, weight)
if GetResourceState(OXInv):find("start") then if GetResourceState(OXInv):find("start") then
--print("Registering OX Stash:", name, label) --print("Registering OX Stash:", name, label)
exports[OXInv]:RegisterStash(name, label, 50, 4000000) exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
elseif GetResourceState(QSInv):find("start") then elseif GetResourceState(QSInv):find("start") then
--print("Registering QS Stash:", name, label) --print("Registering QS Stash:", name, label)
exports[QSInv]:RegisterStash(name, 50, 4000000) exports[QSInv]:RegisterStash(name, slots or 50, weight or 4000000)
end end
end end
-- IN NO WAY PERFECT -- -- IN NO WAY PERFECT --