Compare commits

...

8 Commits

Author SHA1 Message Date
Jim Shield
46e3f18edc Merge pull request #20 from jimathy/1.0.12
1.0.12
2024-02-08 18:58:37 +00:00
Jim Shield
0886d8a4b6 Version Bump 2024-02-08 18:39:30 +00:00
Jim Shield
6a23e4ac91 Move loadModel time reset 2024-02-08 18:39:02 +00:00
Jim Shield
f7b7718679 remove unused variable 2024-02-08 18:38:22 +00:00
Jim Shield
9ae034da77 remove unused variable 2024-02-08 18:38:11 +00:00
Jim Shield
4d1b2abd3d blip_info support preview imgs 2024-02-08 18:37:14 +00:00
Jim Shield
f8e3f64907 Origen Inv Fixes 2024-02-08 18:35:54 +00:00
Jim Shield
3702835958 Added sellMenu() 2024-02-08 18:34:17 +00:00
5 changed files with 118 additions and 12 deletions

View File

@@ -75,7 +75,7 @@ function craftingMenu(data)
header = setheader,
txt = settext,
onSelect = function()
local transdata = { item = k, craft = data.craftable.Recipes[i], craftable = data.craftable, coords = data.coords, stashName = data.stashName, onBack = data.onBack }
local transdata = { item = k, craft = data.craftable.Recipes[i], craftable = data.craftable, coords = data.coords, stashName = data.stashName, onBack = data.onBack, }
if Config.Crafting.MultiCraft then multiCraft(transdata) else makeItem(transdata) end
end,
}
@@ -137,7 +137,6 @@ function makeItem(data)
local crafted, crafting = true, true
local cam = createTempCam(PlayerPedId(), data.coords)
startTempCam(cam)
for i = 1, amount do
for k, v in pairs(data.craft) do
if k ~= "amount" and k ~= "job" then
@@ -209,6 +208,80 @@ RegisterNetEvent(GetCurrentResourceName()..":Crafting:GetItem", function(ItemMak
end)
--[[SHOPS]]--
function sellMenu(data)
local origData = data
local Menu = {}
if data.sellTable.Items then
local itemList = {}
for k, v in pairs(data.sellTable.Items) do itemList[k] = 1 end
local hasitems, hasTable = hasItem(itemList)
for k, v in pairsByKeys(data.sellTable.Items) do
Menu[#Menu +1] = {
isMenuHeader = not hasTable[k].hasItem,
icon = invImg(k),
header = Items[k].label.. (hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""),
txt = Loc[Config.Lan].info["sell_all"].." "..v.." "..Loc[Config.Lan].info["sell_each"],
onSelect = function()
sellAnim({ item = k, price = v, ped = data.ped, onBack = function() sellMenu(data) end })
end,
}
end
else
for k, v in pairsByKeys(data.sellTable) do
if type(v) == "table" then
Menu[#Menu +1] = {
arrow = true,
header = k,
txt = "Amount of items: "..countTable(v.Items),
onSelect = function()
v.onBack = function() sellMenu(origData) end
v.sellTable = data.sellTable[k]
sellMenu(v)
end,
}
end
end
end
openMenu(Menu, { header = data.sellTable.Header or "Amount of items: "..countTable(data.sellTable.Items), canClose = true, onBack = data.onBack })
end
function sellAnim(data)
if not hasItem(data.item, 1) then
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error")
return
end
for k, v in pairs(GetGamePool('CObject')) do
for _, model in pairs({`p_cs_clipboard`}) do
if GetEntityModel(v) == model then
if IsEntityAttachedToEntity(data.ped, v) then
DeleteObject(v) DetachEntity(v, 0, 0) SetEntityAsMissionEntity(v, true, true)
Wait(100) DeleteEntity(v)
end
end
end
end
TriggerServerEvent(GetCurrentResourceName().."Sellitems", data) -- Had to slip in the sell command during the animation command
lookEnt(data.ped)
local dict = "mp_common"
playAnim(dict, "givetake2_a", 0.3, 2)
playAnim(dict, "givetake2_b", 0.3, 2, data.ped)
Wait(2000)
StopAnimTask(PlayerPedId(), dict, "givetake2_a", 0.5)
StopAnimTask(data.ped, dict, "givetake2_b", 0.5)
if data.onBack then data.onBack() end
end
RegisterNetEvent(GetCurrentResourceName().."Sellitems", function(data)
local src = source
local hasItems, hasTable = hasItem(data.item, 1, src)
if hasItems then
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", false, data.item, hasTable[data.item].count, src)
TriggerEvent(GetCurrentResourceName()..":server:FundPlayer", (hasTable[data.item].count * data.price), "cash", src)
else
triggerNotify(nil,Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error", src)
end
end)
function openShop(data)
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
if GetResourceState(OXInv):find("start") then
@@ -236,7 +309,7 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
elseif GetResourceState(OrigenInv):find("start") then
foundInv = OrigenInv
if src then grabInv = exports[OrigenInv]:getPlayerInventory(src)
if src then grabInv = exports[OrigenInv]:GetInventory(src)
else grabInv = exports[OrigenInv]:getPlayerInventory() end
elseif GetResourceState(CoreInv):find("start") then
@@ -405,7 +478,7 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
elseif GetResourceState(OrigenInv):find("start") then
for k, v in pairs(items) do
exports[OrigenInv]:RemoveItem(stashName, k, v)
exports[OrigenInv]:RemoveFromStash(stashName, nil, k, v)
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end
end

View File

@@ -15,8 +15,9 @@ function loadModel(model)
if not HasModelLoaded(model) then
if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) and time > 0 do time -= 1 RequestModel(model) Wait(0) end
if not HasModelLoaded(model) then time = 500 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
if not HasModelLoaded(model) then print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
end
time = 500
end
end
function unloadModel(model) if Config.System.Debug then print("^6Bridge^7: ^2Removing Model from memory cache^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
@@ -58,7 +59,8 @@ function playAnim(animDict, animName, duration, flag, ped)
end
function stopAnim(animDict, animName, ped)
StopAnimTask(ped and ped or PlayerPedId(), animName, animDict)
StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5)
StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5)
unloadAnimDict(animDict)
end
@@ -227,8 +229,9 @@ function ensureNetToVeh(vehNetID)
return vehicle
end
local previewTxd = CreateRuntimeTxd(GetCurrentResourceName()..'previewTxd')
function makeBlip(data)
local blip = AddBlipForCoord(data.coords)
local blip = AddBlipForCoord(vec3(data.coords.x, data.coords.y, data.coords.z))
SetBlipAsShortRange(blip, true)
SetBlipSprite(blip, data.sprite or 106)
SetBlipColour(blip, data.col or 5)
@@ -238,8 +241,23 @@ function makeBlip(data)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip)
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
if data.preview then
local txname = tostring('preview'..keyGen()..keyGen())
if data.preview:find("http") then
local newTxt = CreateDui(data.preview, 512, 256)
local duihandle = GetDuiHandle(newTxt)
while not GetDuiHandle(newTxt) do Wait(0) end
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
else
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
end
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
end
end
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end
return blip
return blip
end
function makeEntityBlip(data)
@@ -254,6 +272,21 @@ function makeEntityBlip(data)
BeginTextCommandSetBlipName('STRING')
AddTextComponentString(tostring(data.name))
EndTextCommandSetBlipName(blip)
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
if data.preview then
local txname = tostring('preview'..keyGen()..keyGen())
if data.preview:find("http") then
local newTxt = CreateDui(data.preview, 512, 256)
local duihandle = GetDuiHandle(newTxt)
while not GetDuiHandle(newTxt) do Wait(0) end
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
else
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
end
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
end
end
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for Entity^7: '^6"..data.name.."^7'") end
return blip
end

View File

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

View File

@@ -1 +1 @@
1.0.11
1.0.12

View File

@@ -26,7 +26,7 @@ for k, v in pairs(Exports) do
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
end
local itemResource, vehResource, jobResource = "", "", ""
local itemResource, jobResource = "", ""
-- Load item lists
if GetResourceState(OXInv):find("start") then itemResource = OXInv
@@ -56,7 +56,7 @@ else
end
-- Load Vehicles
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then vehResource = QBExport
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then
Core = Core or exports[QBExport]:GetCoreObject()
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
RegisterNetEvent('QBCore:Client:UpdateObject', function()