From 61a582a330ed82d3a4eaf7fbb5e66577e35b2271 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Fri, 21 Feb 2025 13:45:08 +0000 Subject: [PATCH] Remove old files --- README.md | 639 ---------------------- crafting.lua | 635 ---------------------- exports.lua | 20 - functions.lua | 1168 ---------------------------------------- fxmanifest.lua | 14 - version.txt | 1 - wrapper.lua | 1395 ------------------------------------------------ 7 files changed, 3872 deletions(-) delete mode 100644 README.md delete mode 100644 crafting.lua delete mode 100644 exports.lua delete mode 100644 functions.lua delete mode 100644 fxmanifest.lua delete mode 100644 version.txt delete mode 100644 wrapper.lua diff --git a/README.md b/README.md deleted file mode 100644 index 4f85642..0000000 --- a/README.md +++ /dev/null @@ -1,639 +0,0 @@ -# Jim_Bridge - -This script is intended to be used with my all my scripts (soon) - -It was started due to wanting to bring the same features from some scripts into others with minimal work and multiple updates -- Having certain functions in one place(this script) makes it easier to update, enchance and fix things -- This brings the possibility of branching to mutliple frameworks as I've added some already: - - `"qb-core"` - - `"qbx-core"` - - `"ox_core"` - - `"es_extended"` (requires ox_lib and ox_inventory) - -All the next updates of my scripts will use this script and be added as a dependancy - ------- - -It was a tough decision to put it up on github instead of tebex and encrypted - -But I want this script to grow with help of others who know more about other cores - ---- - -The installation of this script is simple -- REMOVE `-main` from the folder name, like any other github hosted script -- it just needs to start before any script that requires it -- it can start before core scripts if you want -- for `qb-core` I personally place this script in `resources > [standalone]` - - ---- - -### Support for different exports and scripts - -In exports.lua is the list of script folder names - -This is for people who have customised/renamed scripts - -eg. for people who use `ps-inventory`, this is mainly based on qb-inventory -so you need to rename -```lua - QBInv = "qb-inventory", -``` -to -```lua - QBInv = "ps-inventory", -``` - -This will now use events from `ps-inventory` and use it through out the scripts. - -# WIP -## Documentation - -This script brings alot of features to simplify making scripts with preset functions and automations. - -It attempts to make use of configs from the scripts its loaded into. For example: - -### `Config` -This needs to be in every script that uses it, a `System` table with Debug, Menu, Notify, drawText, progressBar - -This is required to use jim_bridge with your script -```lua -Config = { - System = { - Debug = true, -- This enables Debug mode - -- Revealing debug prints and debug boxes on targets - - Menu = "qb", -- This specifies what menu script will be loaded - -- "qb" = `qb-menu` and edited versions of it - -- "ox" = `ox_lib`'s context menu system - -- "gta" = `WarMenu' a free script for a gta style menu - - Notify = "gta", -- This allows you to choose the notification system for scripts - -- "qb" = `qb-core`'s built in notifications - -- "ox" = `ox_lib`'s built in notifications - -- "esx" = `esx_notify` esx's default notifications - -- "okok" = `okok-notify` okok's notifications - -- "gta" = Native GTA style popups - - drawText = "gta", -- The style of drawText you want to use - -- "qb" = `qb-core`'s drawText system - -- "ox" = `ox_lib`'s drawTextUI system - -- "gta" = Native GTA style popups - - - progressBar = "gta" -- The style of progressBar you want to use - -- "qb" = `qb-core`'s style progressBar - -- "ox" = `ox_lib`'s default progressBar - -- "gta" = Native GTA style "spinner" - }, -} -``` - -### `openMenu(Menu, data)` - -This handles creation of menus using `OX_Lib`, `qb-menu` or `WarMenu` - -It uses mixed/new functions to bring more compatability to one another - -`Menu` is your button entries and works like qb-menu or ox_lib, for example: - -```lua -local Menu = {} -Menu[#Menu + 1] = { - isMenuHeader = true, -- This makes the current button unclickable - icon = invImg("lockpick") -- Supports fontawesome or custom images - -- This example use the custom function `invImg()` to retreive an nui:// link to the given item's image - arrow = true, -- Adds a arrow icon to the button (in qb-menu overrides the icon) - header = "Header Test", -- The header/title for the button - txt = "Text test", -- The txt/description for the button - - onSelect = function() -- This brings the onSelect function to qb-menu - TriggerEvent("lolhi", { lol = hi }), - end, - -- Enter what happens when you click the button -} -``` - -As you can see above, it mixes variables but makes it possible to switch between menus just by changing the config option - -After you have created the info above, you need to then trigger opening of this menu with: -```lua -openMenu(Menu, -- Menu here is your table name you created above -{ -- Next entry in openMenu is a table - header = "Menu Header", -- What your menu title will be shown as - headertxt = "Header info", -- Info to be displayed under the title - - onExit = function() -- Will create a "Close button" - TriggerEvent("lolhi", { lol = hi }), - end, -- When clicked it will trigger the onExit event - - onBack = function() -- Will create a "Back button" - TriggerEvent("lolhi", { lol = hi }), - end, -- When clicked it will trigger the onBack event -}) -``` - -### Support for multiple target events -These automatically detect what target script you are using - -They are also automatically removed when the script is stopped (for helping optimization) -### `createEntityTarget(entity, opts, dist)` -Create an entity based target -```lua -createEntityTarget( - entity, -- The entity ID of what you want to target - { - { -- Your target options here - icon = "icon", -- Your icon, only supports font awesome icons - label = "Test Label", -- The label of your target - item = "lockpick" -- The required it em - job = "mechanic", -- The required job - gang = "lostmc", -- The required gang - action = function() -- What happens when the target is selected - TriggerEvent("lolhi", { lol = hi }), - end, - }, - } -, dist) -- How close you ned to be to see the target -``` - -### `createBoxTarget(data, opts, dist)` -Create an entity based target -```lua -createBoxTarget( - { - "TargetName", -- The name/id of your target here - vec3(0, 0, 0), -- The coordinates of your target - 2.0, -- The width of your target box - 2.0, -- The depth of your target box - { - name = "TargetName", -- The name/id of your target here - heading = 200.0, -- The direction your target will be placed - debugPoly = true, -- Wether to show debug boxes to help place targets - minZ = 190.0, -- The bottom of your box - maxZ = 210.0, -- The top of your box - }, - }, - { - { -- Your target options here - icon = "icon", -- Your icon, only supports font awesome icons - label = "Test Label", -- The label of your target - item = "lockpick" -- The required it em - job = "mechanic", -- The required job - gang = "lostmc", -- The required gang - action = function() -- What happens when the target is selected - TriggerEvent("lolhi", { lol = hi }), - end, - }, - }, -dist) -- How close you ned to be to see the target -``` - -### `createCircleTarget(data, opts, dist)` -Create an entity based target -```lua -createCircleTarget( - { - "TargetName", -- The name/id of your target here - vec3(0, 0, 0), -- The coordinates of your target - 2.0, -- The radius of your target circle - { - name = "TargetName", -- The name/id of your target here - heading = 200.0, -- The direction your target will be placed - debugPoly = true, -- Wether to show debug boxes to help place targets - minZ = 190.0, -- The bottom of your box - maxZ = 210.0, -- The top of your box - }, - }, - { - { -- Your target options here - icon = "icon", -- Your icon, only supports font awesome icons - label = "Test Label", -- The label of your target - item = "lockpick" -- The required it em - job = "mechanic", -- The required job - gang = "lostmc", -- The required gang - action = function() -- What happens when the target is selected - TriggerEvent("lolhi", { lol = hi }), - end, - }, - }, -dist) -- How close you ned to be to see the target -``` - -### `removeEntityTarget(entity)` -Triggers removal of the target entity, by checking the entity name - -### `removeZoneTarget(target)` -Triggers removal of a zone(Box/Circle) target by calling the target's name/id - -### `triggerNotify(title, message, type, src)` -Handles notifications for the script called from either the server or client - -Supports: -- `okok` -- `qb` -- `ox` -- `gta` -- `esx` - -```lua -triggerNotify( - title = "Notification Title", -- Usually 'nil' in my scripts, supports notifications with titles - message = "Notification Message", -- The notification's message - type = "success" -- The type of notification, depends on the supporting script - src = 1, -- If in the server, this is required to send to player -) -``` - -### `drawText(image, input, style)` -This handles calling drawText functions - -Supports: -- `gta` -- `qb` -- `ox` -- `esx` - -```lua -drawText( - 187, -- Very specific for adding blip images to drawtexts, usually nil - { - "Line 1", -- Supports multiple lines, helpful for displaying button prompts - "Line 2", - }, - "g" -- Sets colour of text after a ":" when using GTA drawtext -) -``` - -### `hideText()` -Simply used to hide drawText prompts when not needed anymore - -### `createCallback(callbackName, funct)` -This is my attempt at making multiframework server callbacks by using their provided events - -(Only works server side) - -```lua -createCallback( - "jimsCallback", -- Callback event name, needs to be something that isn't already set - function() - - end) -end -``` - -### `triggerCallback(callBackName, value)` -This is an attempt at a mutliframework callback - -### `onPlayerLoaded(func)` -This is a multiframework event that is triggered when a player has fully loaded their character in - -```lua -onPlayerLoaded( - function() - print("Player Loaded In!") - end -) -``` - -### `createInput(title, opts)` - -### `searchCar(vehicle)` - -This function was made for `jim-mechanic` but can be used in other instances - -I searches the model name of a currently spawned vehicle and retrieves info about it - -It is smart, in terms of, if you use this multiple times it reteives the previously found info instead of searching again - -It retrieves data from your vehicles.lua/database: -- `name` for example: "Zentorno Pegassi" -- `price` for example: 100000 -- `class` this converts the class number to a String, for example: if the class is 10 it converts this to "Off-road" - -### `getVehicleProperties(vehicle)` -Gets the current properties of the vehicle in a table -- if using qb-core it will default to its version -- if not it will attempt to use ox_libs version - -### `setVehicleProperties(vehicle, props)` -Set's the vehicles properites using the `props` table provided -- if using qb-core it will default to its version -- if not it will attempt to use ox_libs version - -### `checkDifferences(vehicle, newProps)` -This function is used by `setVehicleProperties` - -It determine's what differences there are between the current vehicle and the new set of properites - -If there are differences, return `true` - -### `RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc)` -This event is made to REMOVE money from a player - -It can be called from client with `TriggerServerEvent` - -Also can be called from server with `TriggerEvent` and a source id in `newsrc` - -The name of the event uses `GetCurrentResourceName()` so it doesn't double up results with other scripts -```lua -cost = 100 -- The amount of money to be removed -type = "cash" or "card" -- The type of money that should be removed -newsrc = 1 -- The source of the player, must be nil if calling from client -``` -Examples of use: -```lua --- Client -TriggerEvent(GetCurrentResourceName()..":server:ChargePlayer", function(1000, "cash") - --- Server -TriggerServerEvent(GetCurrentResourceName()..":server:ChargePlayer", function(1000, "bank", 1) -``` - -## `RegisterNetEvent(GetCurrentResourceName()..":server:FundPlayer", function(cost, type, newsrc)` -This event is made to ADD money from a player - -It can be called from client with `TriggerServerEvent` - -Also can be called from server with `TriggerEvent` and a source id in `newsrc` - -The name of the event uses `GetCurrentResourceName()` so it doesn't double up results with other scripts -```lua -fund = 100 -- The amount of money to be added -type = "cash" or "card" -- The type of money that should be added -newsrc = 1 -- The source of the player, must be `nil` if calling from client -``` -Examples of use: -```lua --- Client -TriggerEvent(GetCurrentResourceName()..":server:FundPlayer", function(1000, "cash") - --- Server -TriggerServerEvent(GetCurrentResourceName()..":server:FundPlayer", function(1000, "bank", newsrc) -``` - -### `createUseableItem(item, funct)` -This is a server side event to make an item usable - -Note: If using ox_inv and the items.lua info has event or a `status` section, this will be ignored - -```lua -createUseableItem( - "lockpick", -- The item you want to make usable - function(source, item) - TriggerClientEvent("lolhi", source, { lol = item.name }), - end -) -``` - -### `hasJob(job, source, grade)` -This is an event that makes checking if the player has the requested job simple - -It works both client side and server side - -returns `true` or `false` and if they are on duty or not -```lua -local hasjob, duty = - hasJob( - "mechanic", -- the job role - 1, -- the source id of the player, set to nil if on client - 3, -- the required grade of the player, can be nil to check job - ) -``` - -### `getPlayer(source)` -This retrieves basic info of the player - -works client side and server side -Retrieves: -- Players Name -- Players Current Cash -- Players Current Bank Balance - -```lua -local PlayerInfo = - getPlayer( - 1 -- The - ) -print(json.encode(PlayerInfo, { indent = true }) -``` - -### `registerCommand(command, options)` -This is a server side event that uses -- `ox_lib`'s - `lib.addCommand` -- `qb-core`'s - `QBCore.Commands.Add` - -Example: -```lua -registerCommand( - "hello", -- /hello the command to be used - "Print 'hello world'", -- text to show in chat - { name = "lol", help = "hi" }, -- Help text for the command - false, - function() -- Function to be ran when the command is triggered - print("Hello World") - end, - "admin", -- the restriction, can be nil -) -``` - -### `invImg(item)` -This is used mainly for menu's to retrieve the item images - -It detects what inventory you are using and automatically generates an `nui://` link - -```lua -local imgLink = invImg("lockpick") -print(imgLink) -``` - -### `registerStash(name, label, slots, weight)` -This is a serverside function used to register a new stash in `ox_inventory` and `qs-inventory` - -```lua -registerStash( - "newStash", -- The stash name/ID, this is used to open it later - "New created Stash", -- The name of the stash that shows in inventories - 50, -- The amount of slots in the inventory - 4000000, -- The max weight in the inventory -) -``` - -### `loadModel(model)` -This loads the requested model into the memory cache to help spawning of props -- Checks if the model exists in the server -- Attempts to load the model with a timeout, if not loaded, sends warning - -### `unloadModel(model)` -This unloads a model to help clear the memory cache and help optimization -- Recommended to run after spawning a prop - -### `loadAnimDict(animDict)` -This loads the requested animDict into the memory cache to help loading anims -- Checks if the dict exists in the server - -### `unloadAnimDict(animDict)` -This unloads the animDict to help clear the memory cache and help optimization -- Recommended to run after running an animation - -### `loadPtfxDict(ptFxName)` -This loads the requested ptFx dict into the memory cache to help loading particle effects -- Skips if the effect is alredy loaded - -### `unloadPtfxDict(dict)` -This unloads a particle effect to help clear the memory cache and help optimization -- Recommended to run after running an ptfx - -### `loadTextureDict(dict)` -This loads the requested texture dictionary into memory - -### `countTable(table)` -This is a simple function to count how many entires are in a table, for if your table keys aren't numbered - -Example: -```lua -local table = { - ["tableentry"] = true, - ["anotherentry"] = true, -} -print("countTable", countTable(table)) -``` - -### `pairsByKeys(t)` -Searches through a table alphabetically instead of randomly - -This is an optional function made to replace: -```lua -for k, v in pairs(table) do end -``` -with: -```lua -for k, v in pairsByKeys(table) do end -``` - -### `playAnim(animDict, animName, duration, flag, ped)` -A simplified version of `TaskPlayAnim()` - -Has some settings already set and basic ones ready to change - -Loads the animDict automatically with `loadAnimDict()` -```lua -playAnim( - animDict, -- The animation dictionary - animName, -- The animation's name - duration, -- How far into the animation it should stop - flag, -- The animation flag - ped, -- Optional, for if you want any one other than the player to do the animation -) -``` - -### `stopAnim(animDict, animName, ped)` -Similar to `StopAnimTask()` - -Made to stop the given animation with being able to choose which ped -```lua -stopAnim( - animDict, -- The animation dictionary - animName, -- The animation's name - ped, -- Optional, for if you want any one other than the player to do the animation -) -``` -### `makeVeh(model, coords)` -Spawns a vehicle for the player to use -- Server Synced -- Easy creation -- Returns entity id for further control through the script -- Loads model before spawning -- Unloads model from memory cache after spawn - -Example of use: -```lua -local vehicle = makeVeh( - `zentorno`, - vec4(-596.74, 2090.99, 131.41, 16.6) -) -print(vehicle, GetEntityCoords(vehicle)) -``` - -### `makePed(model, coords, freeze, collision, scenario, anim, synced)` -Spawns a controllable ped -- Loads the model before spawning -- Unloads model from memory cache after spawn -- Several options for creation -- Can spawn with scenario name or anims -- Spawns invincible - -Example of use: -```lua -local ped = makePed( - `MP_M_Freemode_011, - vec4(-596.74, 2090.99, 131.41, 16.6), - true, - false, - nil, - { "amb@prop_human_parking_meter@male@idle_a", "idle_a" }, - false -) -print(ped, GetEntityCoords(ped)) -``` - -### `makeProp(data, freeze, synced)` -This function is made to easily load a prop in the world -- Has a simplified process -- Lodas model before spawning prop -- Unloads model from memory cache when done -- Returns entity id for control through the script - -Example of use: -```lua -local entityid = makeProp( - { - prop = "v_serv_plas_boxgt2", -- Prop model, can be a string or hash key - coords = vec4(-596.74, 2090.99, 131.41, 16.6), -- needs to be vector4 or vec4, 4th variable is heading - }, - true, -- Decide if the entiy is frozen in place - false -- Does this prop spawn for everyone or just the client -) -print(entityid, GetEntityCoords(entityid)) -``` - -### `instantLookEnt(ent, ent2)` -This function forcibly changes `ent`'s heading to face `ent2` - -Helpful for animations in a specific direction - -### `lookEnt(entity)` -This function attempts to slowly turn the player to the given entity/coords - -Accepts either a `entity ID` or `vector3` - -### `destroyProp(entity)` -Attempts to remove a spawned prop - -If its attached to a player it attempts to to detatch it first - -### `pushVehicle(entity)` -This attempts to make the current entity(vehicle) network controlled - -This helps with syncing it with other players (used in jim-mechanic often) - -### `ensureNetToVeh(vehNetId)` -This was created to get around fivem's warnings of failing to get network objects - -Although these warnings mean't nothing, it is annoying - -This is made to replace the native `NetToVeh()` but checking first if it exists - -### `makeBlip(data)` - - ---- - - - - - - - - diff --git a/crafting.lua b/crafting.lua deleted file mode 100644 index 43eed56..0000000 --- a/crafting.lua +++ /dev/null @@ -1,635 +0,0 @@ -if IsDuplicityVersion() then - if GetResourceState(OXLibExport):find("start") then - createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, stashName) local stash = getStash(stashName) return stash end) - else - createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, cb, stashName) local stash = getStash(stashName) cb(stash) end) - end -end - -local timeout, timing, stashItems = 0, false, {} -function GetStashTimeout(stashName, stop) - if stop then stashItems, timing, timeout = {}, false, 0 return end - if #stashItems > 0 then return true end - if timeout <= 0 then - stashItems = triggerCallback(GetCurrentResourceName()..':server:GetStashItems', stashName) - timeout = 10000 - if not timing then - CreateThread(function() - timing = true - while timeout > 0 do timeout -= 1000 Wait(1000) end - timing, stashItems, timeout = false, {}, 0 - end) - end - end - return false -end - -local CraftLock = false -function craftingMenu(data) - if CraftLock then return end - if data.stashName and not GetStashTimeout(data.stashName) then - --triggerNotify(nil, "Chacking", "success") - end - if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end - local Menu, hasjob = {}, false - local Recipes = data.craftable.Recipes - local tempCarryTable = {} - for i = 1, #Recipes do - for k in pairs(Recipes[i]) do - if k ~= "amount" and k ~= "job" and k ~= "gang" then - tempCarryTable[k] = Recipes[i].amount or 1 - end - end - end - local canCarryTable = triggerCallback(GetCurrentResourceName()..':server:canCarry', tempCarryTable) - for i = 1, #Recipes do - if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end - for k, v in pairs(Recipes[i]) do - if k ~= "amount" and k ~= "job" and k ~= "gang" then - if Recipes[i].job then - for l, b in pairs(Recipes[i].job) do - hasjob = hasJob(l, nil, b) - if hasjob == true then break end - end - else hasjob = true end - local setheader, settext, disable = "", "", false - if hasjob then - local itemTable = {} - for l, b in pairs(Recipes[i][tostring(k)]) do - settext = settext..(settext ~= "" and br or "")..(Items[l] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "") - itemTable[l] = b - Wait(0) - end - while not canCarryTable do Wait(0) 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) - else disable = not hasItem(itemTable) end - setheader = (Items[tostring(k)] and Items[tostring(k)].label or "error - " .. tostring(k)) .. (Recipes[i]["amount"] > 1 and " x" .. Recipes[i]["amount"] or "") - if not disable then - if not canCarryTable[k] then setheader = setheader .. " 📦" - else setheader = setheader .. " ✔️" end - elseif not canCarryTable[k] then setheader = setheader .. " 📦" end - Menu[#Menu + 1] = { - isMenuHeader = disable or not canCarryTable[k], - icon = invImg(tostring(k)), - 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, } - if Config.Crafting.MultiCraft then multiCraft(transdata) else makeItem(transdata) end - end, - } - end - end - Wait(0) - end - end - openMenu(Menu, { header = data.craftable.Header, onBack = data.onBack or nil, canClose = true, onExit = function() end, }) - lookEnt(data.coords) -end - -function multiCraft(data) local Menu = {} - local success = Config.Crafting.MultiCraftAmounts - if data.stashName and not GetStashTimeout(data.stashName) then - --triggerNotify(nil, "Refreshing stashinfo", "success") - end - Menu[#Menu+1] = { - isMenuHeader = true, - icon = invImg(data.item), - header = Items[data.item].label, - } - for k in pairsByKeys(success) do - local settext = "" - local itemTable = {} - for l, b in pairs(data.craft[data.item]) do - itemTable[l] = (b * k) - settext = settext..(settext ~= "" and br or "")..Items[l].label..(b*k > 1 and "- x"..b*k or "") - Wait(0) - end - local disable = false - if Config.System.Debug then print("^6Bridge^7: ^2Checking "..(data.stashName and "^7'^6"..data.stashName.."^7'" or "inventory").."^7x^5"..k.." ^2ingredients^7 - ^6"..data.item.."^7") end - if data.stashName then disable = not stashhasItem(stashItems, itemTable) - else disable = not hasItem(itemTable) end - - Menu[#Menu + 1] = { - isMenuHeader = disable, - arrow = not disable, - header = "Craft - x"..k * data.craft.amount, - txt = settext, - onSelect = function () - makeItem({item = data.item, craft = data.craft, craftable = data.craftable, amount = k, coords = data.coords, stashName = data.stashName, onBack = data.onBack }) - end, - } - end - openMenu(Menu, { header = data.craftable.Header, onBack = function() craftingMenu(data) end, }) -end - -function makeItem(data) - if CraftLock then return end - CraftLock = true - - 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 and Loc[Config.Lan].progressbar["progress_make"]) or "Making 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 and data.craftable.Anims.anim or "idle_a" - local amount = data.amount and (data.amount ~= 1) and data.amount or 1 - - 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 - if type(v) == "table" then - for l, b in pairs(v) do - if crafting and progressBar({ - label = "Using "..b.." "..Items[l].label, - time = 1000, - cancel = true, - dict = 'pickup_object', - anim = "putdown_low", - flag = 48, - icon = l, - }) then - --TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item - else - crafted, crafting = false, false - break - end - Wait(200) - end - if crafted then - if crafting and progressBar({ - label = bartext..Items[data.item].label, - time = bartime, - cancel = true, - dict = animDict, - anim = anim, - flag = 8, - icon = data.item, - }) then - TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName) - else - crafting = false - break - end - end - end - end - end - Wait(500) - end - stopTempCam() - CraftLock = false - lockInv(false) - craftingMenu(data) - ClearPedTasks(PlayerPedId()) -end - -RegisterNetEvent(GetCurrentResourceName()..":Crafting:GetItem", function(ItemMake, craftable, stashName) - local src, amount, stashItems = source, craftable and craftable.amount or 1, stashName and getStash(stashName) - if stashName then - local itemRemove = {} - for k, v in pairs(craftable[ItemMake] or {}) do - for _, b in pairs(stashItems or {}) do - if k == b.name then itemRemove[k] = v end - end - end - stashRemoveItem(stashItems, stashName, itemRemove) - else - if craftable then - for k, v in pairs(craftable[ItemMake] or {}) do - TriggerEvent(GetCurrentResourceName()..":server:toggleItem", false, tostring(k), v, src) - end - end - end - TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, ItemMake, amount, src) - if GetResourceState("core_skills"):find("start") then exports["core_skills"]:AddExperience(src, 2) end -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 - exports[OXInv]:openInventory('shop', { type = data.shop }) - else - TriggerServerEvent(Config.General.JimShops and "jim-shops:ShopOpen" or "inventory:server:OpenInventory", "shop", data.items.label, data.items) - end - lookEnt(data.coords) -end - --- Client & Server side -function hasItem(items, amount, src) local amount = amount and amount or 1 - local grabInv = nil - local foundInv = "" - if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end - if GetResourceState(OXInv):find("start") then - foundInv = OXInv - if src then grabInv = exports[OXInv]:GetInventoryItems(src) - else grabInv = exports[OXInv]:GetPlayerItems() end - - elseif GetResourceState(QSInv):find("start") then - foundInv = QSInv - if src then grabInv = exports[QSInv]:GetInventory(src) - else grabInv = exports[QSInv]:getUserInventory() end - - elseif GetResourceState(OrigenInv):find("start") then - foundInv = OrigenInv - if src then grabInv = exports[OrigenInv]:GetInventory(src) - else grabInv = exports[OrigenInv]:getPlayerInventory() end - - elseif GetResourceState(CoreInv):find("start") then - foundInv = CoreInv - if src then - if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - grabInv = Core.Functions.GetPlayer(src).PlayerData.items - elseif GetResourceState(ESXExport):find("start") then - local Player = ESX.GetPlayerFromId(src) - grabInv = Player.getInventory(false) - end - else - local p = promise.new() - Core.Functions.TriggerCallback('core_inventory:server:getInventory', function(cb) p:resolve(cb) end) - local result = Citizen.Await(p) - if type(result) == "string" then result = json.decode(result) end - grabInv = result - end - - elseif GetResourceState(CodeMInv):find("start") then - foundInv = CodeMInv - if src then grabInv = exports[CodeMInv]:GetUserInventory(src) - else grabInv = exports[CodeMInv]:GetClientPlayerInventory() end - - elseif GetResourceState(QBInv):find("start") then - foundInv = QBInv - if src then grabInv = Core.Functions.GetPlayer(src).PlayerData.items - else grabInv = Core.Functions.GetPlayerData().items end - - else - print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") - end - - if grabInv then - local hasTable = {} - for item, amount in pairs(items) do - if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end - local count = 0 - for _, itemData in pairs(grabInv) do - if itemData and (itemData.name == item) then count += (itemData.count or itemData.amount or 1) end - end - foundInv = foundInv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6") - local foundMessage = "^6Bridge^7: ^3hasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount - if count >= amount then foundMessage = foundMessage.." ^5FOUND^7" else foundMessage = foundMessage .." ^1NOT FOUND^7" end - if Config.System.Debug then print(foundMessage) end - hasTable[item] = { hasItem = count >= amount, count = count } - end - for k, v in pairs(hasTable) do if not v.hasItem then return false, hasTable end end - return true, hasTable - end -end - --- Stash Items -function openStash(data) - if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end - if GetResourceState(OXInv):find("start") then - exports[OXInv]:openInventory('stash', data.stash) - elseif GetResourceState(CodeMInv):find("start") then - exports[CodeMInv]:OpenStash(data.stash, 400000, 100) - else - TriggerEvent("inventory:client:SetCurrentStash", data.stash) - TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions) - end - lookEnt(data.coords) -end - -function getStash(stashName) local stashResource = "" - local stashItems, items = {}, {} - if GetResourceState(OXInv):find("start") then stashResource = OXInv - stashItems = exports[OXInv]:Inventory(stashName).items - - elseif GetResourceState(QSInv):find("start") then stashResource = QSInv - stashItems = exports[QSInv]:GetStashItems(stashName) - - elseif GetResourceState(CoreInv):find("start") then stashResource = CoreInv - stashItems = exports[CoreInv]:getInventory(stashName) - - elseif GetResourceState(CodeMInv):find("start") then stashResource = CodeMInv - stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName) - - elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv - stashItems = exports[OrigenInv]:GetStashItems(stashName) - - elseif GetResourceState(QBInv):find("start") then stashResource = QBInv - local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName }) - if result then stashItems = json.decode(result) end - end - - if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource) end - if stashItems then - for _, item in pairs(stashItems) do - local itemInfo = Items[item.name:lower()] - if itemInfo then - local indexNum = #items+1 -- Added to help recreate missing slot numbers - items[(item.slot and item.slot) or indexNum] = { - name = itemInfo.name or nil, - amount = tonumber(item.amount) or tonumber(item.count), - info = item.info or "", - label = itemInfo.label or nil, - description = itemInfo.description or "", - weight = itemInfo.weight or nil, - type = itemInfo.type or nil, - unique = itemInfo.unique or nil, - useable = itemInfo.useable or nil, - image = itemInfo.image or nil, - slot = (item.slot and item.slot) or indexNum, - } - end - end - if Config.System.Debug then print("^6Bridge^7: ^3GetStashItems^7: ^2Stash information for ^7'^6"..stashName.."^7' ^2retrieved^7") end - end - return items -end - -function stashRemoveItem(stashItems, stashName, items) local amount = amount and amount or 1 - if GetResourceState(OXInv):find("start") then - for k, v in pairs(items) do - exports[OXInv]:RemoveItem(stashName, k, v) - if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OXInv, k, v) end - end - - elseif GetResourceState(QSInv):find("start") then - for k, v in pairs(items) do - for l in pairs(stashItems) do - if stashItems[l].name == k then - if (stashItems[l].amount - v) <= 0 then - if Config.System.Debug then - print("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v) - end - stashItems[l] = nil - else - if Config.System.Debug then - print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v) - end - exports[QSInv]:RemoveItemIntoStash(stashName, k, v, l) - end - end - end - end - - elseif GetResourceState(CoreInv):find("start") then - for k, v in pairs(items) do - exports[CoreInv]:removeItemExact(stashName, k, v) - if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v) end - end - - elseif GetResourceState(CodeMInv):find("start") then - for k, v in pairs(items) do - for l in pairs(stashItems) do - if stashItems[l].name == k then - if (stashItems[l].amount - v) <= 0 then - if Config.System.Debug then - print("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v) - end - stashItems[l] = nil - else - if Config.System.Debug then - print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CodeMInv, k, v) - end - stashItems[l].amount -= v - end - end - end - end - if Config.System.Debug then - print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'") - end - - elseif GetResourceState(OrigenInv):find("start") then - for k, v in pairs(items) do - exports[OrigenInv]:RemoveFromStash(stashName, k, v) - if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end - end - - elseif GetResourceState(QBInv):find("start") then - for k, v in pairs(items) do - for l in pairs(stashItems) do - if stashItems[l].name == k then - if (stashItems[l].amount - v) <= 0 then - if Config.System.Debug then - print("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v) - end - stashItems[l] = nil - else - if Config.System.Debug then - print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v) - end - stashItems[l].amount -= v - end - end - end - end - if Config.System.Debug then - print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'") - end - MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', { ['stash'] = stashName, ['items'] = json.encode(stashItems) }) - else - print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") - end -end -RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem) - -function stashhasItem(stashItems, items, amount) - local invs = {OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, QBInv} - local foundInv = "" - for _, inv in ipairs(invs) do - if GetResourceState(inv):find("start") then - foundInv = inv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6") - break - end - end - - if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end - local hasTable = {} - for item, amount in pairs(items) do - local count = 0 - for _, itemData in pairs(stashItems) do - if itemData and (itemData.name == item) then - count += (itemData.amount or 1) - end - end - - local debugMsg = string.format("^6Bridge^7: ^3stashHasItem^7[^6%s^7]: %s '%s' ^3%d^7/^3%d^7", foundInv, (count >= amount and "^5FOUND^7" or "^1NOT FOUND^7"), item, count, amount) - if Config.System.Debug then print(debugMsg) end - - hasTable[item] = { hasItem = (count >= amount), count = count } - end - for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end - return true, hasTable -end - -if IsDuplicityVersion() then - if GetResourceState(OXLibExport):find("start") then - createCallback(GetCurrentResourceName()..':server:canCarry', function(source, itemTable) local result = canCarry(itemTable, source) return result end) - else - createCallback(GetCurrentResourceName()..':server:canCarry', function(source, cb, itemTable) local result = canCarry(itemTable, source) cb(result) end) - end -end - -function canCarry(itemTable, src) - local resultTable = {} - if src then - if GetResourceState(OXInv):find("start") then - for k, v in pairs(itemTable) do - resultTable[k] = exports[OXInv]:CanCarryItem(src, k, v) - end - - elseif GetResourceState(QSInv):find("start") then - for k, v in pairs(itemTable) do - resultTable[k] = exports[OXInv]:CanCarryItem(src, k, v) - end - - elseif GetResourceState(CoreInv):find("start") then - --?? - - elseif GetResourceState(CodeMInv):find("start") then - for k, v in pairs(itemTable) do - local weight = Items[k].weight - resultTable[k] = exports[CodeMInv]:CanCarryItem(src, weight, v) - end - - elseif GetResourceState(OrigenInv):find("start") then - for k, v in pairs(itemTable) do - resultTable[k] = exports[OrigenInv]:canCarryItem(src, k, v) - end - - elseif GetResourceState(QBInv):find("start") then - local Player = Core.Functions.GetPlayer(src) - local items = Player.PlayerData.items - local weight, totalWeight = 0, 0 - if not items then return false end - for _, item in pairs(items) do weight += item.weight * item.amount end - totalWeight = tonumber(weight) - - for k, v in pairs(itemTable) do - local itemInfo = Items[k] - if not itemInfo and not Player.Offline then - triggerNotify(nil, 'Item does not exist', 'error', src) - resultTable[k] = true - else - resultTable[k] = (totalWeight + (Items[k]['weight'] * v)) <= 120000 - end - end - end - end - 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 \ No newline at end of file diff --git a/exports.lua b/exports.lua deleted file mode 100644 index bab1fa0..0000000 --- a/exports.lua +++ /dev/null @@ -1,20 +0,0 @@ -Exports = { - QBExport = "qb-core", - QBXExport = "qbx_core", - ESXExport = "es_extended", - OXCoreExport = "ox_core", - - OXInv = "ox_inventory", - QBInv = "qb-inventory", - QSInv = "qs-inventory", - CoreInv = "core_inventory", - CodeMInv = "codem-inventory", - OrigenInv = "origen_inventory", - - OXLibExport = "ox_lib", - - QBMenuExport = "qb-menu", - - QBTargetExport = "qb-target", - OXTargetExport = "ox_target" -} \ No newline at end of file diff --git a/functions.lua b/functions.lua deleted file mode 100644 index 44c8147..0000000 --- a/functions.lua +++ /dev/null @@ -1,1168 +0,0 @@ -onDuty = false -function jobCheck(job) - canDo = true - if not hasJob(job) or not onDuty then - triggerNotify(nil, Loc[Config.Lan].error["not_clockedin"]) - canDo = false - end - return canDo -end - -local time = 500 -function loadModel(model) - if not IsModelValid(model) then print("^6Bridge^7: ^1ERROR^7: ^2Model^7 - '^6"..model.."^7' ^2does not exist in server") return - else - 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 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 - -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 - else - if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..animDict.."^7'") end - while not HasAnimDictLoaded(animDict) do RequestAnimDict(animDict) Wait(5) 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 loadPtfxDict(ptFxName) - if not HasNamedPtfxAssetLoaded(ptFxName) then - if Config.System.Debug then - print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..ptFxName.."^7'") - end - while not HasNamedPtfxAssetLoaded(ptFxName) do RequestNamedPtfxAsset(ptFxName) Wait(5) 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 loadTextureDict(dict) - if not HasStreamedTextureDictLoaded(dict) then - if Config.System.Debug then - print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") - end - while not HasStreamedTextureDictLoaded(dict) do RequestStreamedTextureDict(dict) Wait(5) end - end -end - -function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end - -function pairsByKeys(t) local a = {} for n in pairs(t) do a[#a+1] = n end table.sort(a) local i = 0 local iter = function() i += 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end - -function playAnim(animDict, animName, duration, flag, ped) - loadAnimDict(animDict) - TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.0, duration or 30000, flag or 50, 1, false, false, false) -end - -function stopAnim(animDict, animName, ped) - StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5) - StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5) - unloadAnimDict(animDict) -end - -function makeVeh(model, coords) - loadModel(model) - local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, false) - SetVehicleHasBeenOwnedByPlayer(veh, true) - SetNetworkIdCanMigrate(NetworkGetNetworkIdFromEntity(veh), true) - Wait(100) - SetVehicleNeedsToBeHotwired(veh, false) - SetVehRadioStation(veh, 'OFF') - SetVehicleFuelLevel(veh, 100.0) - SetVehicleModKit(veh, 0) - SetVehicleOnGroundProperly(veh) - if Config.System.Debug then - local coords = { string.format("%.2f", coords.x), string.format("%.2f", coords.y), string.format("%.2f", coords.z), (string.format("%.2f", coords.w or 0.0)) } - print("^6Bridge^7: ^1Veh ^2Created^7: '^6"..veh.."^7' | ^2Hash^7: ^7'^6"..(model).."^7' | ^2Coord^7: ^5vec4^7(^6"..(coords[1]).."^7, ^6"..(coords[2]).."^7, ^6"..(coords[3]).."^7, ^6"..(coords[4]).."^7)") - end - unloadModel(model) - return veh -end - -local Peds = {} -local Props = {} -function makePed(model, coords, freeze, collision, scenario, anim, synced) - loadModel(model) - local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, synced and synced or false, false) - SetEntityInvincible(ped, true) - SetBlockingOfNonTemporaryEvents(ped, true) - FreezeEntityPosition(ped, freeze and freeze or true) - - if collision then SetEntityNoCollisionEntity(ped, PlayerPedId(), false) end - if scenario then TaskStartScenarioInPlace(ped, scenario, 0, true) end - if anim then - loadAnimDict(anim[1]) - TaskPlayAnim(ped, anim[1], anim[2], 0.5, 1.0, -1, 1, 0.2, 0, 0, 0) - end - if Config.System.Debug then - local coords = { string.format("%.2f", coords.x), string.format("%.2f", coords.y), string.format("%.2f", coords.z), (string.format("%.2f", coords.w or 0.0)) } - print("^6Bridge^7: ^1Ped ^2Created^7: '^6"..ped.."^7' | ^2Hash^7: ^7'^6"..(model).."^7' | ^2Coord^7: ^5vec4^7(^6"..(coords[1]).."^7, ^6"..(coords[2]).."^7, ^6"..(coords[3]).."^7, ^6"..(coords[4]).."^7)") - end - unloadModel(model) - Peds[#Peds+1] = ped - return ped -end - -function makeProp(data, freeze, synced) - loadModel(data.prop) - local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced and synced or false, synced and synced or false, false) - SetEntityHeading(prop, data.coords.w + 180.0) - FreezeEntityPosition(prop, freeze and freeze or 0) - if Config.System.Debug then - local coords = { string.format("%.2f", data.coords.x), string.format("%.2f", data.coords.y), string.format("%.2f", data.coords.z), (string.format("%.2f", data.coords.w or 0.0)) } - print("^6Bridge^7: ^1Prop ^2Created^7: '^6"..prop.."^7' | ^2Hash^7: ^7'^6"..(data.prop).."^7' | ^2Coord^7: ^5vec4^7(^6"..(coords[1]).."^7, ^6"..(coords[2]).."^7, ^6"..(coords[3]).."^7, ^6"..(coords[4]).."^7)") - end - unloadModel(data.prop) - Props[#Props+1] = prop - return prop -end - -function cv(amount) - local formatted = amount or "0" - while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end - return formatted -end - -function DrawText3D(x, y, z, text) - SetTextScale(0.35, 0.35) - SetTextFont(4) - SetTextProportional(true) - SetTextColour(255, 255, 255, 215) - BeginTextCommandDisplayText("STRING") - SetTextCentre(true) - AddTextComponentSubstringPlayerName(text) - SetDrawOrigin(x,y,z, 0) - EndTextCommandDisplayText(0.0, 0.0) - local factor = string.len(text) / 370 - DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75) - ClearDrawOrigin() -end - -function instantLookEnt(ent, ent2) - local p1 = GetEntityCoords(ent, true) - local p2 = GetEntityCoords(ent2, true) - - local dx = p2.x - p1.x - local dy = p2.y - p1.y - - local heading = GetHeadingFromVector_2d(dx, dy) - SetEntityHeading( ent, heading ) -end - -function lookEnt(entity) local ped = PlayerPedId() - if entity then - if type(entity) == "vector3" or type(entity) == "vector4" then - if not IsPedHeadingTowardsPosition(ped, entity.xyz, 30.0) then - TaskTurnPedToFaceCoord(ped, entity.xyz, 1500) - if Config.System.Debug then print("^6Bridge^7: ^2Turning Player to^7: '^6"..json.encode(entity).."^7'") end - Wait(1500) - end - else - if DoesEntityExist(entity) then - if not IsPedHeadingTowardsPosition(ped, GetEntityCoords(entity), 30.0) then - TaskTurnPedToFaceCoord(ped, GetEntityCoords(entity), 1500) - if Config.System.Debug then print("^6Bridge^7: ^2Turning Player to^7: '^6"..entity.."^7'") end - Wait(1500) - end - end - end - end -end - -function destroyProp(entity) - if entity then - if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end - if IsEntityAttachedToEntity(entity, PlayerPedId()) then - SetEntityAsMissionEntity(entity) - DetachEntity(entity, true, true) - end - DeleteObject(entity) - end -end - -function pushVehicle(entity) - SetVehicleModKit(entity, 0) - if entity ~= 0 and DoesEntityExist(entity) then - if not NetworkHasControlOfEntity(entity) then - if Config.System.Debug then print("^6Bridge^7: ^3pushVehicle^7: ^2Requesting network control of vehicle^7.") end - NetworkRequestControlOfEntity(entity) - local timeout = 2000 - while timeout > 0 and not NetworkHasControlOfEntity(entity) do - Wait(100) - timeout = timeout - 100 - end - if NetworkHasControlOfEntity(entity) and Config.System.Debug then print("^6Bridge^7: ^3pushVehicle^7: ^2Network has control of entity^7.") end - end - if not IsEntityAMissionEntity(entity) then - if Config.System.Debug then print("^6Bridge^7: ^3pushVehicle^7: ^2Setting vehicle as a ^7'^2mission^7' &2entity^7.") end - SetEntityAsMissionEntity(entity, true, true) - local timeout = 2000 - while timeout > 0 and not IsEntityAMissionEntity(entity) do - Wait(100) - timeout = timeout - 100 - end - if IsEntityAMissionEntity(entity) and Config.System.Debug then print("^6Bridge^7: ^3pushVehicle^7: ^2Vehicle is a ^7'^2mission^7'^2 entity^7.") end - end - end -end - -function ensureNetToVeh(vehNetID) - if Config.System.Debug then print("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)") end - local timeout = 100 - while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do timeout -= 1 Wait(10) end - if not NetworkDoesNetworkIdExist(vehNetID) then return 0 end - timeout = 100 - local vehicle = NetToVeh(vehNetID) - while not DoesEntityExist(vehicle) and vehicle ~= 0 and timeout > 0 do timeout -= 1 Wait(10) end - if not DoesEntityExist(vehicle) then return 0 end - return vehicle -end - -local scriptTxd = not IsDuplicityVersion() and CreateRuntimeTxd(GetCurrentResourceName()..'scriptTxd') or nil - -local customDUIList = {} -function makeBlip(data) - 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) - SetBlipScale(blip, data.scale or 0.7) - SetBlipDisplay(blip, (data.disp or 6)) - if data.category then SetBlipCategory(blip, data.category) end - 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(data.name..'preview'..string.gsub(data.coords.z, "%.", "")) - if data.preview:find("http") then - createDui(txname, data.preview, vec2(512, 256), scriptTxd) - else - CreateRuntimeTextureFromImage(scriptTxd, txname, data.preview) - end - exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'scriptTxd', 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 -end - -function makeEntityBlip(data) - AddBlipForEntity(data.entity) - local blip = GetBlipFromEntity(data.entity) - SetBlipAsShortRange(blip, true) - SetBlipSprite(blip, data.sprite or 106) - SetBlipColour(blip, data.col or 5) - SetBlipScale(blip, data.scale or 0.7) - SetBlipDisplay(blip, (data.disp or 6)) - if data.category then SetBlipCategory(blip, data.category) end - 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 = data.name..'preview' - if data.preview:find("http") then - createDui(txname, data.preview, vec2(512, 256), scriptTxd) - else - CreateRuntimeTextureFromImage(scriptTxd, 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 - --- DUI STUFF - WIP -- - --- DUI CLIENT -function createDui(name, http, size, txd) - if not customDUIList[name] then - local newTxt = CreateDui(http, math.floor(size.x), math.floor(size.y)) - while not GetDuiHandle(newTxt) do Wait(0) end - CreateRuntimeTextureFromDuiHandle(txd, name, GetDuiHandle(newTxt)) - customDUIList[name] = newTxt - SetDuiUrl(customDUIList[name], http) - else - SetDuiUrl(customDUIList[name], http) - end -end - -function DuiSelect(data) - local image = "" - for k, v in pairs(duiList[data.name]) do - if v.tex.texn == data.texn then - if duiList[data.name][k] then - image = "
- Current Image -
".. - "
".. - "Size: ["..math.floor(data.size.x)..", "..math.floor(data.size.y).."]

" - end - end - end - local dialog = exports['qb-input']:ShowInput({ - header = image..Loc[Config.Lan].menu["dui_new"], - submitText = Loc[Config.Lan].menu["dui_change"], - inputs = { { type = 'text', isRequired = true, name = 'url', text = Loc[Config.Lan].menu["dui_url"] } } }) - if dialog then - if not dialog.url then return end - data.url = dialog.url - --Scan the link to see if it has an image extention otherwise, stop here. - local searchList = { "png", "jpg", "jpeg", "gif", "webp", "bmp" } - --Scan the link for certain terms that will flag it and refuse to show it - local banList = { "porn" } -- I dunno, let me know what links people manage to find - local searchFound = false - for k, v in pairs(searchList) do - if string.find(tostring(data.url), tostring(v))then - searchFound = true - end - end - for k, v in pairs(banList) do - if string.find(tostring(data.url), tostring(v)) then - searchFound = false print("BANNED WORD: "..v) - end - end - if searchFound then - TriggerServerEvent(GetCurrentResourceName()..":Server:ChangeDUI", data) - end - end -end - -RegisterNetEvent(GetCurrentResourceName()..":Client:ChangeDUI", function(data) - if Config.System.Debug then print("^6Bridge^7: ^2Recieving new DUI ^7- ^6"..data.url.."^7") end - if tostring(data.url) ~= "-" then - createDui(data.texn, tostring(data.url), data.size, scriptTxd) - AddReplaceTexture(tostring(data.texd), tostring(data.texn), GetCurrentResourceName()..'scriptTxd', tostring(data.texn)) - end -end) - -RegisterNetEvent(GetCurrentResourceName()..":Client:ClearDUI", function(data) - if customDUIList[tostring(data.texn)] then - RemoveReplaceTexture(tostring(data.texd), tostring(data.texn)) - if IsDuiAvailable(customDUIList[tostring(data.texn)]) then - SetDuiUrl(customDUIList[data.name], nil) - end - end -end) - --- DUI SERVER -RegisterNetEvent(GetCurrentResourceName()..":Server:ChangeDUI", function(data) - -- if no url given, "reset" it back to preset - if not data.url then - for k, v in pairs(duiList[data.name]) do - if v.tex.texn == data.texn then - if Config.System.Debug then print("^6Bridge^7: ^2Preset^7: ^6"..tostring(duiList[data.name][k].preset).."^7") end - data.url = duiList[data.name][k].preset - end - end - end - -- if it has a url, update server DUI list and send to players - for k, v in pairs(duiList[data.name]) do - if v.tex.texn == data.texn then - duiList[data.name][k].url = data.url - end - end - if Config.System.Debug then print("^6Bridge^7: ^3DUI^2 Sending new DUI to all players^7 - ^6"..data.url.."^7") end - TriggerClientEvent(GetCurrentResourceName()..":Client:ChangeDUI", -1, data) -end) - -RegisterNetEvent(GetCurrentResourceName()..":Server:ClearDUI", function(data) - if data.url == "-" then - for k, v in pairs(duiList[data.name]) do - if v.tex.texn == data.texn then - duiList[data.name][k].url = "-" - end - end - end - -- Clear the DUI from loading - TriggerClientEvent(GetCurrentResourceName()..":Client:ClearDUI", -1, data) - --duiList[tostring(data.tex)].url = "" -end) - -AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end - for k, v in pairs(duiList or {}) do - for i = 1, #v do - RemoveReplaceTexture(tostring(v[i].tex.texd), tostring(v[i].tex.texn)) - end - end -end) - -function lockInv(toggle) - FreezeEntityPosition(PlayerPedId(), toggle) - LocalPlayer.state:set("inv_busy", toggle, true) - TriggerEvent('inventory:client:busy:status', toggle) - TriggerEvent('canUseInventoryAndHotbar:toggle', not toggle) -end - -function createTempCam(ent, coords) - local cam = nil - if Config.Crafting.craftCam then - if Config.System.Debug then - triggerNotify(nil, "ModCam Created", "success") - end - local camCoords = nil - if type(ent) ~= "vector3" then - camCoords = GetOffsetFromEntityInWorldCoords(ent, 1.2, -0.3, 0.8) - else - camCoords = ent - end - --local pedCoords = GetEntityCoords(PlayerPedId()) - cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", camCoords.x, camCoords.y, camCoords.z+0.5, 1.0, 0.0, 0.0, 60.00, false, 0) - PointCamAtCoord(cam, coords) - end - return cam -end - -function keyGen() - local charset = { - "q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m", - "Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M", - "1","2","3","4","5","6","7","8","9","0" - } - local GeneratedID = "" - for i = 1, 3 do GeneratedID = GeneratedID..charset[math.random(1, #charset)] end - return GeneratedID -end - -function startTempCam(cam) - if Config.Crafting.craftCam then - SetCamActive(cam, true) - RenderScriptCams(true, true, 1000, true, true) - end -end -function stopTempCam() - if Config.Crafting.craftCam then - CreateThread(function() - Wait(1000) - RenderScriptCams(false, true, 500, true, true) - DestroyAllCams() - end) - end -end - -local inProgress = false -function progressBar(data) - local result = nil - if data.cam then - startTempCam(data.cam) - end - if Config.System.ProgressBar == "ox" then - if exports[OXLibExport]:progressBar({ - duration = Config.System.Debug and 1000 or data.time, - label = data.label, - useWhileDead = data.dead and data.dead or false, - canCancel = data.cancel and data.cancel or true, - anim = { - dict = data.dict, - clip = data.anim, - flag = (data.flag == 8 and 32 or data.flag) or nil, - scenario = data.task - }, - disable = { - combat = true - }, - }) then - result = true - lockInv(false) - if data.cam then stopTempCam(data.cam) end - else - result = false - lockInv(false) - if data.cam then stopTempCam(data.cam) end - end - - elseif Config.System.ProgressBar == "qb" then - Core.Functions.Progressbar("mechbar", - data.label, - Config.System.Debug and 1000 or data.time, - data.dead and data.dead or false, - data.cancel or true, - { disableMovement = true, disableCarMovement = true, disableMouse = false, disableCombat = true, }, - { animDict = data.dict, anim = data.anim, flags = data.flag and data.flag or 32, task = data.task }, {}, {}, - function() - result = true - lockInv(false) - if data.cam then - stopTempCam(data.cam) - end - end, function() - result = false - lockInv(false) - if data.cam then - stopTempCam(data.cam) - end - end, data.icon) - - elseif Config.System.ProgressBar == "esx" then - ESX.Progressbar(data.label, Config.System.Debug and 1000 or data.time, { - FreezePlayer = true, - animation ={ - type =data.anim, - dict = data.dict, - scenario = data.task, - }, - onFinish = function() - result = true - FreezeEntityPosition(PlayerPedId(), false) - lockInv(false) - if data.cam then - stopTempCam(data.cam) - end - end, onCancel = function() - result = false - FreezeEntityPosition(PlayerPedId(), false) - lockInv(false) - if data.cam then - stopTempCam(data.cam) - end - end - }) - - elseif Config.System.ProgressBar == "gta" then - local wait, inProgress = (Config.System.Debug and 1000 or data.time), true - --local wait = data.time - inProgress = true - if not (data.dead and data.dead or false) then - lockInv(true) - displaySpinner(data.label) - local ped = PlayerPedId() - if data.dict then - playAnim(data.dict, data.anim, -1, (data.flag == 8 and 32 or data.flag) or nil) - end - if data.task then - TaskStartScenarioInPlace(ped, data.task, -1, true) - end - while inProgress and wait > 0 do wait -= 15 - local waitTimer = 0 - DisablePlayerFiring(ped, true) - DisableControlAction(0, 25, true) - DisableControlAction(0, 21, true) - DisableControlAction(0, 30, true) - DisableControlAction(0, 31, true) - DisableControlAction(0, 36, true) - if data.cam ~= nil then - DisableControlAction(0, 1, true) - DisableControlAction(0, 2, true) - DisableControlAction(0, 106, true) - end - if data.cancel then - if IsControlJustReleased(0, 202) or IsControlJustReleased(0, 77) then - inProgress = false - waitTimer = 1500 - displaySpinner(Loc[Config.Lan].error["cancel"]) - end - end - Wait(waitTimer) - end - inProgress = false - if data.cam then stopTempCam(data.cam) end - if data.dict then stopAnim(data.dict, data.anim, ped) end - ClearPedTasks(ped) - end - lockInv(false) - stopSpinner() - result = (wait <= 0) - end - while result == nil do Wait(10) end - return result -end - -function displaySpinner(text) - BeginTextCommandBusyspinnerOn('STRING') - AddTextComponentSubstringPlayerName(text) - EndTextCommandBusyspinnerOn(4) -end - -function stopSpinner() if not IsDuplicityVersion() then BusyspinnerOff() end end - -function stopPropgressBar() - if Config.System.ProgressBar == "ox" then - exports[OXLibExport]:cancelProgress() - elseif Config.System.ProgressBar == "qb" then - TriggerEvent("progressbar:client:cancel") - elseif Config.System.ProgressBar == "gta" then - inProgress = false - BusyspinnerOff() - end -end - --- [[ OTHER ]] -- -function washHands(data) - lookEnt(data.coords) - local cam = createTempCam(PlayerPedId(), data.coords) - if progressBar({ - label = Loc[Config.Lan].progressbar["progress_washing"], - time = 5000, - cancel = true, - dict = "mp_arresting", - anim = "a_uncuff", - flag = 32, - icon = "fas fa-hand-holding-droplet", - cam = cam - }) then - triggerNotify(nil, Loc[Config.Lan].success["washed_hands"], "success") - else - triggerNotify(nil, Loc[Config.Lan].error["cancel"], 'error') - end - ClearPedTasks(PlayerPedId()) -end - -function useToilet(data) - if data.urinal then - if progressBar({ - label = "Using Urinal", - time = 5000, - cancel = true, - dict = "misscarsteal2peeing", - anim = "peeing_loop", - flag = 32 - }) then - TriggerServerEvent(GetCurrentResourceName().."server:Urinal")else - lockInv(false) - triggerNotify(nil, Loc[Config.Lan].error["cancelled"], 'error') - end - else - TaskStartScenarioAtPosition(PlayerPedId(), "PROP_HUMAN_SEAT_CHAIR_MP_PLAYER", data.sitcoords.x, data.sitcoords.y, data.sitcoords.z, data.sitcoords[4], 0, 1, true) - if progressBar({ - label = "Using Toilet", - time = 10000, - cancel = true - }) then - TriggerServerEvent(GetCurrentResourceName().."server:Urinal") - ClearPedTasks(PlayerPedId()) - else - lockInv(false) - triggerNotify(nil, Loc[Config.Lan].error["cancelled"], 'error') - end - end -end - -RegisterNetEvent(GetCurrentResourceName()..":server:Urinal", function() - local src = source - local Player = getPlayer(src) - local thirstamt = math.random(10,30) - local thirst = Player.thirst - thirstamt - setThirst(src, getPlayer(src).thirst - thirst) -end) - -RegisterNetEvent(GetCurrentResourceName()..":server:setNeed", function(type, amount) local src = source - if type == "thirst" then - setThirst(src, amount) - elseif type == "hunger" then - setHunger(src, amount) - end -end) - -function setThirst(src, thirst) - if GetResourceState(ESXExport):find("start") then - TriggerClientEvent('esx_status:add', src, 'thirst', thirst) - elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - local Player = Core.Functions.GetPlayer(src) - Player.Functions.SetMetaData('thirst', thirst) - TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst) - end -end - -function setHunger(src, hunger) - if GetResourceState(ESXExport):find("start") then - TriggerClientEvent('esx_status:add', src, 'hunger', hunger) - elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - local Player = Core.Functions.GetPlayer(src) - Player.Functions.SetMetaData('hunger', hunger) - TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger) - end -end - -function useDoor(data) - DoScreenFadeOut(500) - while not IsScreenFadedOut() do Wait(10) end - SetEntityCoords(PlayerPedId(), data.telecoords.xyz, 0, 0, 0, false) - SetEntityHeading(PlayerPedId(), data.telecoords.w) - DoScreenFadeIn(1000) - Wait(100) -end - --- [[CONSUME]] -- -function ConsumeSuccess(itemName, type) - ExecuteCommand("e c") - removeItem(itemName, 1) - if GetResourceState(ESXExport):find("start") then - if Items[itemName].hunger then - TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Items[itemName].hunger * 10000) - end - if Items[itemName].thirst then - TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "thirst", Items[itemName].thirst * 10000) - end - else - if Items[itemName].hunger then - TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Core.Functions.GetPlayerData().metadata["hunger"] + Items[itemName].hunger) - end - if Items[itemName].thirst then - TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "thirst", Core.Functions.GetPlayerData().metadata["thirst"] + Items[itemName].thirst) - end - end - 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 - end - getRandomReward(itemName) -- check if a reward item should be given -end - -function addItem(item, amount, info) - TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", true, item, amount, nil, info) -end - -function removeItem(item, amount) - TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", false, item, amount, nil, info) -end - -RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc) - local src = newsrc or source - local addremove = (tostring(give) == "true" and "addItem" or "removeItem") - if Config.System.Debug then - print("^6Bridge^7: ^3toggleItem ^2triggered^7: ^6"..addremove.."^7 - '"..tostring(item).."' x"..(tostring(amount) or "1")) - end - local remamount = (amount and amount or 1) - if item == nil then return end - if give == 0 or give == false then - if hasItem(item, amount and amount or 1, src) then -- check if you still have the item - if GetResourceState(OXInv):find("start") then - local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(QSInv):find("start") then - local success = exports[QSInv]:RemoveItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(CoreInv):find("start") then - if GetResourceState(QBExport):find("start") then - Core.Functions.GetPlayer(src).Functions.RemoveItem(item, amount, nil) - elseif GetResourceState(ESXExport):find("start") then - ESX.GetPlayerFromId(src).removeInventoryItem(item, count) - end - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(OrigenInv):find("start") then - local success = exports[OrigenInv]:RemoveItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(CodeMInv):find("start") then - local success = exports[CodeMInv]:RemoveItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(QBInv):find("start") then - while remamount > 0 do - if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end - remamount -= 1 - end - if Config.Crafting.showItemBox then - TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1)) - end - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..QBInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - else - print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") - end - else - dupeWarn(src, item, amount) -- if not boot the player - end - else - local amount = amount and amount or 1 - if GetResourceState(OXInv):find("start") then - local success = exports[OXInv]:AddItem(src, item, amount or 1, nil) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(QSInv):find("start") then - local success = exports[QSInv]:AddItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(CoreInv):find("start") then - if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - Core.Functions.GetPlayer(src).Functions.AddItem(item, amount, nil, nil) - elseif GetResourceState(ESXExport):find("start") then - ESX.GetPlayerFromId(src).addInventoryItem(item, amount) - end - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(CodeMInv):find("start") then - local success = exports[CodeMInv]:AddItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(OrigenInv):find("start") then - local success = exports[OrigenInv]:AddItem(src, item, amount) - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - elseif GetResourceState(QBInv):find("start") then - if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then - --if Config.Crafting.showItemBox then - TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1) - --end - end - if Config.System.Debug then - print("^6Bridge^7: ^3"..addremove.."^7[^6"..QBInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7") - end - - else - print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7") - end - end -end) - ---Item Exploit protection -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") - if Config.System.Debug == false then - DropPlayer(src, src.." ^1Kicked for suspected duplicating items:"..item) - end - print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^7") -end - -function breakTool(data) --wip - local durability, slot = getDurability(item) - durability -= data.damage - if not durability then durability = 100 end - if durability <= 0 then - removeItem(data.item, 1) - local breakId = GetSoundId() - PlaySoundFromEntity(breakId, "Drill_Pin_Break", PlayerPedId(), "DLC_HEIST_FLEECA_SOUNDSET", 1, 0) - else - TriggerServerEvent(GetCurrentResourceName()..":server:setMetaData", { item = data.item, slot = slot, metadata = { durability = durability }}) - end -end - -function getDurability(item) - local lowestSlot = 100 -- anything above your players max slots - local durability = nil - if GetResourceState(QBInv):find("start") then - local itemcheck = Core.Functions.GetPlayerData().items - for k, v in pairs(itemcheck) do - if v.name == item then - if v.slot <= lowestSlot then - lowestSlot = v.slot - durability = itemcheck[k].info.durability - end - end - end - end - - if GetResourceState(OXInv):find("start") then - local itemcheck = exports[OXInv]:Search('slots', item) - for k, v in pairs(itemcheck) do - if v.slot <= lowestSlot then - lowestSlot = v.slot - durability = itemcheck[k].metadata.durability - end - end - end - - if GetResourceState(QSInv):find("start") then - local itemcheck = exports[QSInv]:getUserInventory() - for k, v in pairs(itemcheck) do - if v.name == item and v.slot <= lowestSlot then - lowestSlot = v.slot - durability = itemcheck[k].metadata.durability - end - end - end - - if GetResourceState(OrigenInv):find("start") then - local itemcheck = exports[OrigenInv]:getPlayerInventory() - for k, v in pairs(itemcheck) do - if v.name == item and v.slot <= lowestSlot then - lowestSlot = v.slot - durability = itemcheck[k].metadata.durability - end - end - end - return durability, lowestSlot -end - -RegisterNetEvent(GetCurrentResourceName()..":server:setMetaData", function(data) - local src = source - if GetResourceState(QBInv):find("start") then - local Player = Core.Functions.GetPlayer(src) - Player.PlayerData.items[data.slot].info = data.metadata - Player.PlayerData.items[data.slot].description = "HP : "..data.metadata.durability - Player.Functions.SetInventory(Player.PlayerData.items) - end - - if GetResourceState(OXInv):find("start") then - exports[OXInv]:SetMetadata(source, data.slot, data.metadata) - end - - if GetResourceState(QSInv):find("start") then - exports[QSInv]:SetItemMetadata(source, data.slot, data.metadata) - end - - if GetResourceState(OrigenInv):find("start") then - local item = exports[OrigenInv]:GetItemBySlot(source, data.slot) - if item then - exports[OrigenInv]:SetItemData(source, item.name, "durability", data.metadata.durability) - end - end -end) - -function toggleDuty() - if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - TriggerServerEvent("QBCore:ToggleDuty") - else - onDuty = not onDuty - if onDuty then - triggerNotify(nil, "Now on duty", "success") - else - triggerNotify(nil, "Now off duty", "success") - end - end -end - -local function CheckVersion() - if IsDuplicityVersion() then - local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7" - PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..GetCurrentResourceName()..'.txt', function(err, newestVersion, headers) - if not newestVersion then - PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers) - if not freeVersion then print("^1Currently unable to run a version check for ^7'^3"..GetCurrentResourceName().."^7' ("..currentVersion.."^7)") return end - local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7" - freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7" - print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..freeVersion) - print(freeVersion == currentVersion and "^7'^3"..GetCurrentResourceName().."^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3"..GetCurrentResourceName().."^7' - ^1You are currently running an outdated version^7, ^1please update^7!") - end) - else - newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7" - print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion) - print(newestVersion == currentVersion and '^6You are running the latest version.^7 ('..currentVersion..')' or "^1You are currently running an outdated version^7, ^1please update^7!") - end - end) - end -end -CheckVersion() - ---Screen Effects -local alienEffect = false -function AlienEffect() - if alienEffect then return else alienEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end - AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0) - Wait(math.random(5000, 8000)) - local Ped = PlayerPedId() - local animDict = "MOVE_M@DRUNK@VERYDRUNK" - loadAnimDict(animDict) - SetPedCanRagdoll(Ped, true) - ShakeGameplayCam('DRUNK_SHAKE', 2.80) - SetTimecycleModifier("Drunk") - SetPedMovementClipset(Ped, animDict, 1) - SetPedMotionBlur(Ped, true) - SetPedIsDrunk(Ped, true) - Wait(1500) - SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0) - Wait(13500) - SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0) - Wait(120500) - ClearTimecycleModifier() - ResetScenarioTypesEnabled() - ResetPedMovementClipset(Ped, 0) - SetPedIsDrunk(Ped, false) - SetPedMotionBlur(Ped, false) - AnimpostfxStopAll() - ShakeGameplayCam('DRUNK_SHAKE', 0.0) - AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0) - Wait(math.random(45000, 60000)) - AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0) - AnimpostfxStop("DrugsMichaelAliensFightIn") - AnimpostfxStop("DrugsMichaelAliensFight") - AnimpostfxStop("DrugsMichaelAliensFightOut") - alienEffect = false - if Config.System.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2stopped") end -end -local weedEffect = false -function WeedEffect() - if weedEffect then return else weedEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end - AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0) - Wait(math.random(3000, 20000)) - AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0) - Wait(math.random(15000, 20000)) - AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0) - AnimpostfxStop("DrugsMichaelAliensFightIn") - AnimpostfxStop("DrugsMichaelAliensFight") - AnimpostfxStop("DrugsMichaelAliensFightOut") - weedEffect = false - if Config.System.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2stopped") end -end -local trevorEffect = false -function TrevorEffect() - if trevorEffect then return else trevorEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end - AnimpostfxPlay("DrugsTrevorClownsFightIn", 3.0, 0) - Wait(3000) - AnimpostfxPlay("DrugsTrevorClownsFight", 3.0, 0) - Wait(30000) - AnimpostfxPlay("DrugsTrevorClownsFightOut", 3.0, 0) - AnimpostfxStop("DrugsTrevorClownsFight") - AnimpostfxStop("DrugsTrevorClownsFightIn") - AnimpostfxStop("DrugsTrevorClownsFightOut") - trevorEffect = false - if Config.System.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2stopped") end -end -local turboEffect = false -function TurboEffect() - if turboEffect then return else turboEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end - AnimpostfxPlay('RaceTurbo', 0, true) - SetTimecycleModifier('rply_motionblur') - ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25) - Wait(30000) - StopGameplayCamShaking(true) - SetTransitionTimecycleModifier('default', 0.35) - Wait(1000) - ClearTimecycleModifier() - AnimpostfxStop('RaceTurbo') - turboEffect = false - if Config.System.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2stopped") end -end -local rampageEffect = false -function RampageEffect() - if rampageEffect then return else rampageEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end - AnimpostfxPlay('Rampage', 0, true) - SetTimecycleModifier('rply_motionblur') - ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25) - Wait(30000) - StopGameplayCamShaking(true) - SetTransitionTimecycleModifier('default', 0.35) - Wait(1000) - ClearTimecycleModifier() - AnimpostfxStop('Rampage') - rampageEffect = false - if Config.System.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2stopped") end -end -local focusEffect = false -function FocusEffect() - if focusEffect then return else focusEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end - Wait(1000) - AnimpostfxPlay('FocusIn', 0, true) - Wait(30000) - AnimpostfxStop('FocusIn') - focusEffect = false - if Config.System.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2stopped") end -end -local nightVisionEffect = false -function NightVisionEffect() - if NightVisionEffect then return else nightVisionEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2activated") end - SetNightvision(true) - Wait(math.random(3000, 4000)) -- FEEL FREE TO CHANGE THIS - SetNightvision(false) - SetSeethrough(false) - nightVisionEffect = false - if Config.System.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2stopped") end -end -local thermalEffect = false -function ThermalEffect() - if thermalEffect then return else thermalEffect = true end - if Config.System.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2activated") end - SetNightvision(true) - SetSeethrough(true) - Wait(math.random(2000, 3000)) -- FEEL FREE TO CHANGE THIS - SetNightvision(false) - SetSeethrough(false) - thermalEffect = false - if Config.System.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2stopped") end -end - ---Built-in Buff effects -local healEffect = false -function HealEffect(data) - if healEffect then return end - if Config.System.Debug then print("^5Debug^7: ^3HealEffect^7() ^2activated") end - healEffect = true - local count = (data[1] / 1000) - while count > 0 do - Wait(1000) - count -= 1 - SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2]) - end - healEffect = false - if Config.System.Debug then print("^5Debug^7: ^3HealEffect^7() ^2stopped") end -end - -local staminaEffect = false -function StaminaEffect(data) - if staminaEffect then return end - if Config.System.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2activated") end - staminaEffect = true - local startStamina = (data[1] / 1000) - SetRunSprintMultiplierForPlayer(PlayerId(), 1.49) - while startStamina > 0 do - Wait(1000) - if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end - startStamina -= 1 - if math.random(5, 100) < 51 then end - end - startStamina = 0 - SetRunSprintMultiplierForPlayer(PlayerId(), 1.0) - staminaEffect = false - if Config.System.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2stopped") end -end - -function StopEffects() -- Used to clear up any effects stuck on screen - if Config.System.Debug then print("^5Debug^7: ^2All screen effects stopped") end - ShakeGameplayCam('DRUNK_SHAKE', 0.0) - SetPedToRagdoll(PlayerPedId(), 5000, 1000, 1, 0, 0, 0) - ClearTimecycleModifier() - ResetScenarioTypesEnabled() - ResetPedMovementClipset(PlayerPedId(), 0) - SetPedIsDrunk(PlayerPedId(), false) - SetPedMotionBlur(PlayerPedId(), false) - SetNightvision(false) - SetSeethrough(false) - AnimpostfxStop("DrugsMichaelAliensFightIn") - AnimpostfxStop("DrugsMichaelAliensFight") - AnimpostfxStop("DrugsMichaelAliensFightOut") - AnimpostfxStop("DrugsTrevorClownsFight") - AnimpostfxStop("DrugsTrevorClownsFightIn") - AnimpostfxStop("DrugsTrevorClownsFightOut") - AnimpostfxStop('RaceTurbo') - AnimpostfxStop('FocusIn') - AnimpostfxStop('Rampage') -end - -AddEventHandler('onResourceStop', function(r) - if r ~= GetCurrentResourceName() then return end - stopSpinner() - for i = 1, #Peds do DeletePed(Peds[i]) end - for i = 1, #Props do destroyProp(Props[i]) end -end) \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua deleted file mode 100644 index db3dbad..0000000 --- a/fxmanifest.lua +++ /dev/null @@ -1,14 +0,0 @@ -name "Jim_Bridge" -author "Jimathy" -version "1.0.14" -description "Framework Bridge By Jimathy" -fx_version "cerulean" -game "gta5" -lua54 'yes' - -files { - 'exports.lua', - 'functions.lua', - 'wrapper.lua', - 'crafting.lua', -} diff --git a/version.txt b/version.txt deleted file mode 100644 index bba5b3d..0000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -1.0.14 diff --git a/wrapper.lua b/wrapper.lua deleted file mode 100644 index df269f3..0000000 --- a/wrapper.lua +++ /dev/null @@ -1,1395 +0,0 @@ -Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil - -Exports.QBInv = GetResourceState("ps-inventory"):find("start") and "ps-inventory" or GetResourceState("lj-inventory"):find("start") and "lj-inventory" or Exports.QBInv - -OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport = Exports.OXLibExport or "", Exports.QBXExport or "", Exports.QBExport or "", Exports.ESXExport or "", Exports.OXCoreExport or "" - -OXInv, QBInv, QSInv, CoreInv, CodeMInv, OrigenInv = Exports.OXInv or "", Exports.QBInv or "", Exports.QSInv or "", Exports.CoreInv or "", Exports.CodeMInv or "", Exports.OrigenInv or "" - -QBMenuExport = Exports.QBMenuExport or "" - -QBTargetExport, OXTargetExport = Exports.QBTargetExport or "", Exports.OXTargetExport or "" - -function CheckBridgeVersion() - if IsDuplicityVersion() then - local currentVersion = "^3"..GetResourceMetadata("jim_bridge", 'version'):gsub("%.", "^7.^3").."^7" - PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersion, headers) - if not newestVersion then print("^1Currently unable to run a version check for ^7'^3jim_bridge^7' ("..currentVersion.."^7)") return end - newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7" - print(newestVersion == currentVersion and "^7'^3jim_bridge^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3jim_bridge^7' - ^1You are currently running an outdated version^7, ^1please update^7!") - end) - end -end -CheckBridgeVersion() - -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, jobResource = "", "" - --- Load item lists -if GetResourceState(OXInv):find("start") then itemResource = OXInv - Items = exports[OXInv]:Items() - for k, v in pairs(Items) do - if v.client and v.client.image then - Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "") - else - Items[k].image = k..".png" - end - Items[k].hunger = v.client and v.client.hunger or nil - Items[k].thirst = v.client and v.client.thirst or nil - end - -elseif GetResourceState(QBExport):find("start") then itemResource = QBExport - Core = Core or exports[QBExport]:GetCoreObject() - Items = Core and Core.Shared.Items or nil - -elseif GetResourceState(ESXExport):find("start") then itemResource = ESXExport - ESX = exports[ESXExport]:getSharedObject() - Items = ESX and ESX.Items or nil -end -if not Items then - print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7") -else - print("^6Bridge^7: ^2Loading ^6"..countTable(Items).." ^3Items^2 from ^7" .. itemResource) -end - --- Load Vehicles -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() - Core = Core or exports[QBExport]:GetCoreObject() - end) - end - Vehicles = Core and Core.Shared.Vehicles - print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..QBExport) -elseif GetResourceState(OXCoreExport):find("start") then - Vehicles = {} - for k, v in pairs(Ox.GetVehicleData()) do - Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make } - end - print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..OXCoreExport) -elseif GetResourceState(ESXExport):find("start") then - print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..ESXExport) - --print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport) - CreateThread(function() - if IsDuplicityVersion() then - createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source) - Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles') - print("^6Bridge^7: ^3Found ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport) - return Vehicles - end) - end - if not IsDuplicityVersion() then - local TempVehicles = triggerCallback(GetCurrentResourceName()..":getVehiclesPrices") - for _, v in pairs(TempVehicles) do - Vehicles = Vehicles or {} - Vehicles[v.model] = { model = v.model, price = v.price, name = v.name, brand = GetMakeNameFromVehicleModel(v.model):lower():gsub("^%l", string.upper) } - end - end - end) -else - print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7") -end - --- Load Jobs -local jobResource = "" -if GetResourceState(QBXExport):find("start") then jobResource = QBXExport - Core = Core or exports[QBExport]:GetCoreObject() - Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs() - -elseif GetResourceState(OXCoreExport):find("start") then jobResource = OXExport - CreateThread(function() - if IsDuplicityVersion() then - createCallback(GetCurrentResourceName()..":getOxGroups", function(source) - Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs - end) - else - local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups") - Jobs = TempJobs and {} - for k, v in pairs(TempJobs) do - local grades = {} - for i = 1, #v.grades do grades[i] = { name = v.grades[i], isboss = (i == #v.grades)} end - Jobs[v.name] = { label = v.label, grades = grades } - end - Gangs = Jobs - end - end) - -elseif GetResourceState(QBExport):find("start") then jobResource = QBExport - Core = Core or Core or exports[QBExport]:GetCoreObject() - RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end) - Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs - -elseif GetResourceState(ESXExport):find("start") then - print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..ESXExport) - ESX = exports[ESXExport]:getSharedObject() - if IsDuplicityVersion() then - Jobs = ESX.GetJobs() - for k, v in pairs(Jobs) do - local count = countTable(Jobs[k].grades)-1 - Jobs[k].grades[tostring(count)].isBoss = true - end - Gangs = Jobs - end - CreateThread(function() - while not ESX do Wait(0) end - if IsDuplicityVersion() then - createCallback(GetCurrentResourceName()..":getJobs", function(source) - return Jobs - end) - end - if not IsDuplicityVersion() then - Jobs = triggerCallback(GetCurrentResourceName()..":getJobs") - Gangs = Jobs - end - end) -end -if not GetResourceState(ESXExport):find("start") and Jobs then - print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource, "^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource) -end - -function makeBossRoles(role) - local boss = {} - local data = Jobs and Jobs[role] or Gangs and Gangs[role] - if data then - for grade, info in pairs(data.grades) do - if info.isboss then - boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade) - end - end - end - return boss -end - -function createPoly(data) local Location = nil - if GetResourceState(OXLibExport):find("start") then -- if it finds ox_lib, use it instead of PolyZone - if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7 "..OXLibExport.." "..data.name) end - for i = 1, #data.points do - data.points[i] = vec3(data.points[i].x, data.points[i].y, 12.0) - end - data.thickness = 1000 - Location = lib.zones.poly(data) - elseif GetResourceState("PolyZone"):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7PolyZone "..data.name) end - Location = PolyZone:Create(data.points, { name = data.name, debugPoly = data.debug }) - Location:onPlayerInOut(function(isPointInside) - if isPointInside then data.onEnter() else data.onExit() end - end) - else - print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7") - end -end - -function createCirclePoly(data) local Location = nil - if GetResourceState(OXLibExport):find("start") then -- if it finds ox_lib, use it instead of PolyZone - if Config.System.Debug then print("^6Bridge^7: ^2Creating new ^3Cricle^2 poly with ^7"..OXLibExport.." "..data.name) end - Location = lib.zones.sphere(data) - elseif GetResourceState("PolyZone"):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Creating new ^3Cricle^2 poly with ^7PolyZone ".. data.name) end - Location = CircleZone:Create(data.coords, data.radius, { name = data.name, debugPoly = Config.System.Debug}) - Location:onPlayerInOut(function(isPointInside) - if isPointInside then - data.onEnter() - else - data.onExit() - end - end) - else - print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7") - end -end - -function openMenu(Menu, data) - if Config.System.Menu == "ox" then - local index = nil - if data.onBack and not data.onSelected then - table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left", - title = "Return", - onSelect = data.onBack, - label = "Return" - }) - end - for k in pairs(Menu) do - if data.onSelected and Menu[k].arrow then - Menu[k].icon = "fas fa-angle-right" - end - if not Menu[k].title then - if Menu[k].header ~= nil and Menu[k].header ~= "" then - Menu[k].title = Menu[k].header - Menu[k].label = Menu[k].header - if Menu[k].txt then Menu[k].description = Menu[k].txt else Menu[k].description = "" end - else - Menu[k].title = Menu[k].txt - Menu[k].label = Menu[k].txt - end - end - if Menu[k].params then - Menu[k].event = Menu[k].params.event - Menu[k].args = Menu[k].params.args or {} - end - if Menu[k].isMenuHeader then - Menu[k].disabled = true - end - end - local menuID = 'Menu' - (data.onSelected and lib.registerMenu or lib.registerContext)({ - id = menuID, - title = data.header..br..br..(data.headertxt and data.headertxt or ""), - position = 'top-right', - options = Menu, - canClose = data.canClose and data.canClose or nil, - onClose = (data.onBack and data.onBack) or (data.onExit and data.onExit) or nil, - onExit = data.onExit and data.onExit or nil, - onSelected = data.onSelected and (function(selected) index = selected end) or nil, - }, (data.onSelected and (function(x, y, args) - if Menu[x].refresh then - if Menu[x].onSelect then - Menu[x].onSelect() - end - lib.showMenu(menuID, index) - else - if Menu[x].onSelect then - Menu[x].onSelect() - else - lib.showMenu(menuID, index) - end - end - end) or nil)) - if data.onSelected then - lib.showMenu(menuID, 1) - else - lib.showContext(menuID) - end - elseif Config.System.Menu == "qb" then - if data.onBack then - table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left", - header = " ", txt = "Return", - params = { - isAction = true, - event = data.onBack, - } - }) - elseif data.canClose then - table.insert(Menu, 1, { icon = "fas fa-circle-xmark", - header = " ", txt = "Close", - params = { - isAction = true, - event = data.onExit and data.onExit or (function() exports[QBMenuExport]:closeMenu() end), - } - }) - end - if data.header ~= nil then - local tempMenu = {} - for k, v in pairs(Menu) do tempMenu[k+1] = v end - tempMenu[1] = { header = data.header, txt = data.headertxt and data.headertxt or "", isMenuHeader = true } - Menu = tempMenu - end - for k in pairs(Menu) do - if Menu[k].onSelect then - Menu[k].params = { - isAction = true, - event = Menu[k].onSelect, - } - end - if not Menu[k].header then Menu[k].header = " " end - if Menu[k].arrow then Menu[k].icon = "fas fa-angle-right" end - end - exports[QBMenuExport]:openMenu(Menu) - elseif Config.System.Menu == "gta" then - WarMenu.CreateMenu(tostring(Menu), - data.header, - data.headertxt or " ", - { titleColor = { 222, 255, 255 }, - maxOptionCountOnScreen = 15, - width = 0.25, - x = 0.7, - }) - if WarMenu.IsAnyMenuOpened() then return end - WarMenu.OpenMenu(tostring(Menu)) - CreateThread(function() - local close = true - while true do - if WarMenu.Begin(tostring(Menu)) then - if data.onBack then - if WarMenu.SpriteButton("Return", 'commonmenu', "arrowleft", 127, 127, 127) then - WarMenu.CloseMenu() - Wait(10) - data.onBack() - end - end - for k in pairs(Menu) do - local pressed = WarMenu.Button(Menu[k].header) - if not Menu[k].header then - Menu[k].header = Menu[k].txt - Menu[k].txt = nil - end - if Menu[k].txt and Menu[k].txt ~= "" and WarMenu.IsItemHovered() then - if Menu[k].disabled or Menu[k].isMenuHeader then - WarMenu.ToolTip("~r~"..Menu[k].txt, 0.18, true) - else - WarMenu.ToolTip( - (Menu[k].blip and "~BLIP_".."8".."~ " or "").. - Menu[k].txt:gsub("%:", ":~g~"):gsub("%\n", "\n~s~"), 0.18, - true) - end - end - if pressed and not Menu[k].isMenuHeader then - WarMenu.CloseMenu() - close = false - Menu[k].onSelect() - end - end - WarMenu.End() - else - return - end - if not WarMenu.IsAnyMenuOpened() and close then - stopTempCam(cam) - if data.onExit then data.onExit() end - end - Wait(0) - end - end) - elseif Config.System.Menu == "esx" then -- can't display more than one line - BIG problem for crafting menus mainly - for k in pairs(Menu) do - Menu[k].label = Menu[k].header - Menu[k].name = "button"..k - end - if data.canClose then - table.insert(Menu, 1, { - icon = "fas fa-circle-xmark", - label = "Close", - name = "close", - onSelect = data.onExit - }) - end - if data.onBack then - table.insert(Menu, 1, { - icon = "fas fa-circle-arrow-left", - label = "Return", - name = "return", - onSelect = data.onback - }) - end - - ESX.UI.Menu.Open("default", GetCurrentResourceName(), "Example_Menu", { - title = data.header, - align = 'top-right', - elements = Menu - }, - function(menuData, menu) -- OnSelect Function - for k in pairs(Menu) do - if menuData.current.name == Menu[k].name then - menu.close() - Wait(10) - Menu[k].onSelect() - end - end - end, - function(data, menu) - menu.close() -- close menu - end) - end -end - -br = (Config.System.Menu == "ox" or Config.System.Menu == "gta") and "\n" or "
" - -function isOx() return (Config.System.Menu == "ox" or Config.System.Menu == "gta") end - -function isWarMenuOpen() if Config.System.Menu == "gta" then return WarMenu.IsAnyMenuOpened() else return false end end - -local TextTargets = {} -local Keys = { - [322] = "ESC", [288] = "F1", [289] = "F2", [170] = "F3", [166] = "F5", - [167] = "F6", [168] = "F7", [169] = "F8", [56] = "F9", [57] = "F10", - [243] = "~", [157] = "1", [158] = "2", [160] = "3", [164] = "4", [165] = "5", [159] = "6", [161] = "7", [162] = "8", [163] = "9", [84] = "-", [83] = "=", [177] = "BACKSPACE", [37] = "TAB", - [44] = "Q", [32] = "W", [38] = "E", [45] = "R", [245] = "T", [246] = "Y", [303] = "U", [199] = "P", - [39] = "[", [40] = "]", [18] = "ENTER", [137] = "CAPS", - [34] = "A", [8] = "S", [9] = "D", [23] = "F", [47] = "G", - [74] = "H", [311] = "K", [182] = "L", [21] = "LEFTSHIFT", - [20] = "Z", [73] = "X", [26] = "C", [0] = "V", [29] = "B", [249] = "N", - [244] = "M", [82] = ",", [81] = "." -} --- Targets -- -local targetEntities = {} -function createEntityTarget(entity, opts, dist) - targetEntities[#targetEntities+1] = entity - if GetResourceState(OXTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Entity^2 target with ^6"..OXTargetExport.." ^7"..entity) - end - local options = {} - for i = 1, #opts do - options[i] = { - icon = opts[i].icon, - label = opts[i].label, - item = opts[i].item or nil, - groups = opts[i].job or opts[i].gang, - onSelect = opts[i].action, - canInteract = function(_, distance) - return distance < dist and true or false - end - } - end - exports[OXTargetExport]:addLocalEntity(entity, options) - elseif GetResourceState(QBTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Entity^2 target with ^6"..QBTargetExport.." ^7"..entity) - end - local options = { options = opts, distance = dist } - exports[QBTargetExport]:AddTargetEntity(entity, options) - else - local tempText = "" - local keyTable = { 38, 29, 303, } - for i = 1, #opts do - opts[i].key = keyTable[i] - tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." " - end - TextTargets[entity] = { coords = GetEntityCoords(entity), buttontext = tempText, options = opts, dist = dist } - end -end - -local boxTargets = {} -function createBoxTarget(data, opts, dist) - if GetResourceState(OXTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Box^2 target with ^6"..OXTargetExport.." ^7"..data[1]) - end - local options = {} - for i = 1, #opts do - options[i] = { - icon = opts[i].icon, - label = opts[i].label, - item = opts[i].item or nil, - groups = opts[i].job or opts[i].gang, - onSelect = opts[i].onSelect or opts[i].action, - canInteract = function(_, distance) - return distance < dist and true or false - end - } - end - if not data[5].useZ then - local z = data[2].z + math.abs(data[5].maxZ - data[5].minZ) / 2 - data[2] = vec3(data[2].x, data[2].y, z) - end - local target = exports[OXTargetExport]:addBoxZone({ - coords = data[2], - size = vec3(data[4], data[3], (data[5].useZ or not data[5].maxZ) and data[2].z or math.abs(data[5].maxZ - data[5].minZ)), - rotation = data[5].heading, - debug = data[5].debugPoly, - options = options - }) - boxTargets[#boxTargets+1] = target - return target - elseif GetResourceState(QBTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Box^2 target with ^6"..QBTargetExport.." ^7"..data[1]) - end - local options = { options = opts, distance = dist } - local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options) - boxTargets[#boxTargets+1] = target - return data[1] - else - local tempText = "" - local keyTable = { 38, 29, 303, } - for i = 1, #opts do - opts[i].key = keyTable[i] - tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." " - end - TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist } - return data[1] - end -end - -local circleTargets = {} -function createCircleTarget(data, opts, dist) - if GetResourceState(OXTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Sphere^2 target with ^6"..OXTargetExport.." ^7"..data[1]) - end - local options = {} - for i = 1, #opts do - options[i] = { - icon = opts[i].icon, - label = opts[i].label, - item = opts[i].item or nil, - groups = opts[i].job or opts[i].gang, - onSelect = opts[i].onSelect or opts[i].action, - canInteract = function(_, distance) - return distance < dist and true or false - end - } - end - local target = exports[OXTargetExport]:addSphereZone({ - coords = data[2], - radius = data[3], - debug = data[4].debugPoly, - options = options - }) - circleTargets[#circleTargets+1] = target - return target - elseif GetResourceState(QBTargetExport):find("start") then - if Config.System.Debug then - print("^6Bridge^7: ^2Creating new ^3Circle^2 target with ^6"..QBTargetExport.." ^7"..data[1]) - end - local options = { options = opts, distance = dist } - - local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options) - - circleTargets[#circleTargets+1] = target - return data[1] - else - local tempText = "" - local keyTable = { 38, 29, 303, } - for i = 1, #opts do - opts[i].key = keyTable[i] - tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." " - end - TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist } - return data[1] - end -end - -function removeEntityTarget(entity) - if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end - if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(entity, nil) end - if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then - TextTargets[entity] = nil - end -end - -function removeZoneTarget(target) - if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end - if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(target, true) end - if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then - TextTargets[target] = nil - end -end - -if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") and not IsDuplicityVersion() then - CreateThread(function() - while true do - local pedCoords = GetEntityCoords(PlayerPedId()) - for k, v in pairs (TextTargets) do - if #(pedCoords - v.coords) <= v.dist then - DrawText3D(v.coords.x, v.coords.y, v.coords.z + 1.0, v.buttontext) - for i = 1, #v.options do - if IsControlJustPressed(0, v.options[i].key) then - if v.options[i].onSelect then v.options[i].onSelect() end - if v.options[i].action then v.options[i].action() end - end - end - end - end - Wait(0) - end - end) -end - -AddEventHandler('onResourceStop', function(r) - if r ~= GetCurrentResourceName() then return end - for i = 1, #targetEntities do - if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(targetEntities[i], nil) - elseif GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(targetEntities[i]) end - end - for i = 1, #boxTargets do - if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(boxTargets[i], true) - elseif GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(boxTargets[i].name) end - end - for i = 1, #circleTargets do - if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(circleTargets[i], true) - elseif GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(circleTargets[i].name) end - end -end) - --- NOTIFICATIONS -- -function triggerNotify(title, message, type, src) - if Config.System.Notify == "okok" then - if not src then TriggerEvent('okokNotify:Alert', title, message, 6000, type) - else TriggerClientEvent('okokNotify:Alert', src, title, message, 6000, type) end - elseif Config.System.Notify == "qb" then - if not src then TriggerEvent("QBCore:Notify", message, type) - else TriggerClientEvent("QBCore:Notify", src, message, type) end - elseif Config.System.Notify == "ox" then - if not src then TriggerEvent('ox_lib:notify', {title = title, description = message, type = type or "success"}) - else TriggerClientEvent('ox_lib:notify', src, { type = type or "success", title = title, description = message }) end - elseif Config.System.Notify == "gta" then - if not src then TriggerEvent(GetCurrentResourceName()..":DisplayGTANotify", title, message) - else TriggerClientEvent(GetCurrentResourceName()..":DisplayGTANotify", src, title, message) end - elseif Config.System.Notify == "esx" then - if not src then exports["esx_notify"]:Notify(type, 4000, message) - else TriggerClientEvent(GetCurrentResourceName()..":DisplayESXNotify", src, type, title, message) end - end -end - -RegisterNetEvent(GetCurrentResourceName()..":DisplayESXNotify", function(type, title, text) - exports["esx_notify"]:Notify(type, 4000, message) -end) - -RegisterNetEvent(GetCurrentResourceName()..":DisplayGTANotify", function(title, text) local iconTable = {} - if GetCurrentResourceName() == "jim-npcservice" then - iconTable = { - [Loc[Config.Lan].notify["taxiname"]] = "CHAR_TAXI", - [Loc[Config.Lan].notify["limoname"]] = "CHAR_CASINO", - [Loc[Config.Lan].notify["ambiname"]] = "CHAR_CALL911", - [Loc[Config.Lan].notify["pilotname"]] = "CHAR_DEFAULT", - [Loc[Config.Lan].notify["planename"]] = "CHAR_BOATSITE2", - [Loc[Config.Lan].notify["heliname"]] = "CHAR_BOATSITE2", - } - end - BeginTextCommandThefeedPost("STRING") - AddTextComponentSubstringKeyboardDisplay(text) - EndTextCommandThefeedPostMessagetext(iconTable[title] or "CHAR_DEFAULT", iconTable[title] or "CHAR_DEFAULT", true, 1, title, nil, text); - EndTextCommandThefeedPostTicker(true, false) -end) - ---DrawText -function drawText(image, input, style) local text = "" - if Config.System.drawText == "qb" then - for i = 1, #input do - text = text..input[i]..""..(input[i+1] ~= nil and "
" or "") end - local text = text:gsub("%:", ":") - if image then - text = ''..text - end - exports[CoreExport]:DrawText(text, 'left') - - elseif Config.System.drawText == "ox" then - for k, v in pairs(input) do - input[k] = v.." \n" - end - lib.showTextUI(table.concat(input), { icon = radarTable[image], position = 'left-center' }) - - elseif Config.System.drawText == "gta" then - for i = 1, #input do if input[i] ~= "" then text = text..input[i].."\n~s~" end end - if image then text = "~BLIP_"..image.."~ "..text end - - DisplayHelpMsg(text:gsub("%:", ":~"..style.."~")) - elseif Config.System.drawText == "esx" then - for i = 1, #input do - text = text..input[i]..""..(input[i+1] ~= nil and "
" or "") end - local text = text:gsub("%:", ":") - if image then - text = ''..text - end - ESX.TextUI(text, nil) - end -end - -function hideText() - if Config.System.drawText == "qb" then - exports[CoreExport]:HideText() - elseif Config.System.drawText == "ox" then - lib.hideTextUI() - elseif Config.System.drawText == "gta" then - ClearAllHelpMessages() - elseif Config.System.drawText == "esx" then - ESX.HideUI() - end -end - -function DisplayHelpMsg(text) - BeginTextCommandDisplayHelp("STRING") - AddTextComponentScaleform(text) - EndTextCommandDisplayHelp(0, true, false, -1) -end - --- Callbacks -function createCallback(callbackName, funct) - if GetResourceState(OXLibExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..OXLibExport, callbackName) end - lib.callback.register(callbackName, funct) - elseif GetResourceState(QBExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..QBExport, callbackName) end - Core = Core or exports[QBExport]:GetCoreObject() - Core.Functions.CreateCallback(callbackName, funct) - elseif GetResourceState(ESXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..ESXExport, callbackName) end - ESX.RegisterServerCallback(callbackName, funct) - else - print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to register callback with", callbackName) - end -end - -function triggerCallback(callBackName, value) local result = nil - if GetResourceState(OXLibExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..OXLibExport, callBackName) end - result = lib.callback.await(callBackName, false, value) - elseif GetResourceState(QBExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..QBExport, callBackName) end - local p = promise.new() - Core.Functions.TriggerCallback(callBackName, function(cb) p:resolve(cb) end, value) - result = Citizen.Await(p) - elseif GetResourceState(ESXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..ESXExport, callBackName) end - local p = promise.new() - ESX.TriggerServerCallback(callBackName, function(cb) p:resolve(cb) end, value) - result = Citizen.Await(p) - else - print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to trigger callback with", callBackName) - end - return result -end - --- onPlayerLoaded events -function onPlayerLoaded(func) - if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..QBExport) end - AddEventHandler('QBCore:Client:OnPlayerLoaded', func) - elseif GetResourceState(ESXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..ESXExport) end - AddEventHandler('esx:playerLoaded', func) - elseif GetResourceState(OXCoreExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end - AddEventHandler('ox:playerLoaded', func) - else - print("^4ERROR^7: ^2No Core detected for onPlayerLoaded ^7- ^2Check ^3exports^1.^2lua^7") - end -end - --- INPUT -- -function createInput(title, opts) - local dialog = nil - local options = {} - if Config.System.Menu == "ox" then - for i = 1, #opts do - if opts[i].type == "radio" then - for k in pairs(opts[i].options) do - opts[i].options[k].label = opts[i].options[k].text - end - options[i] = { - type = "select", - isRequired = opts[i].isRequired, - label = opts[i].label or opts[i].text, - name = opts[i].name, - default = opts[i].default or opts[i].options[1].value, - options = opts[i].options, - } - end - if opts[i].type == "number" then - options[i] = { - type = "number", - label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""), - isRequired = opts[i].isRequired, - name = opts[i].name, - options = opts[i].options, - } - end - if opts[i].type == "text" then - options[i] = { - type = "input", - label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""), - default = opts[i].default, - isRequired = opts[i].isRequired, - } - end - if opts[i].type == "select" then - options[i] = { - type = "select", - label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""), - isRequired = opts[i].isRequired, - name = opts[i].name, - options = opts[i].options, - min = opts[i].min, - max = opts[i].max, - default = opts[i].default, - } - end - end - dialog = exports[OXLibExport]:inputDialog(title, options) - return dialog - end - if Config.System.Menu == "qb" then - dialog = exports['qb-input']:ShowInput({ header = title, submitText = "Accept", inputs = opts }) - return dialog - end - if Config.System.Menu == "gta" then - WarMenu.CreateMenu(tostring(opts), - title, - " ", - { titleColor = { 222, 255, 255 }, - maxOptionCountOnScreen = 15, - width = 0.25, - x = 0.7, - }) - if WarMenu.IsAnyMenuOpened() then return end - WarMenu.OpenMenu(tostring(opts)) - local close = true - local _comboBoxItems = { } - local _comboBoxIndex = { 1, 1 } - while true do - if WarMenu.Begin(tostring(opts)) then - for i = 1, #opts do - if opts[i].type == "radio" then - for k in pairs(opts[i].options) do - if not _comboBoxItems[i] then _comboBoxItems[i] = {} end - _comboBoxItems[i][k] = opts[i].options[k].text - end - local _, comboBoxIndex = WarMenu.ComboBox(opts[i].label, _comboBoxItems[i], _comboBoxIndex[i]) - if _comboBoxIndex[i] ~= comboBoxIndex then - _comboBoxIndex[i] = comboBoxIndex - end - end - if opts[i].type == "number" then - for b = 1, opts[i].max do - if not _comboBoxItems[i] then _comboBoxItems[i] = {} end - _comboBoxItems[i][b] = b - end - local _, comboBoxIndex = WarMenu.ComboBox(opts[i].text, _comboBoxItems[i], _comboBoxIndex[i]) - if _comboBoxIndex[i] ~= comboBoxIndex then - _comboBoxIndex[i] = comboBoxIndex - end - end - end - local pressed = WarMenu.Button("Pay") - if pressed then - WarMenu.CloseMenu() - close = false - local result = {} - for i = 1, #_comboBoxIndex do - result[i] = _comboBoxItems[i][_comboBoxIndex[i]] - end - return result - end - WarMenu.End() - else - return - end - if not WarMenu.IsAnyMenuOpened() and close then - if data.onExit then data.onExit() end - end - Wait(0) - end - end -end - --- Get Vehile Info -- -local lastCar = nil -local carInfo = {} -function searchCar(vehicle) - if lastCar ~= vehicle then -- If same car, use previous info - lastCar = vehicle - carInfo = {} - local model = GetEntityModel(vehicle) - local classlist = { - "Compacts", --1 - "Sedans", --2 - "SUVs", --3 - "Coupes", --4 - "Muscle", --5 - "Sports Classics", --6 - "Sports", --7 - "Super", --8 - "Motorcycles", --9 - "Off-road", --10 - "Industrial", --11 - "Utility", --12 - "Vans", --13 - "Cycles", --14 - "Boats", --15 - "Helicopters", --16 - "Planes", --17 - "Service", --18 - "Emergency", --19 - "Military", --20 - "Commercial", --21 - "Trains", --22 - } - if Vehicles then - for k, v in pairs(Vehicles) do - if tonumber(v.hash) == model or GetHashKey(v.hash) == model or GetHashKey(v.model) == model then - if Config.System.Debug then - print("^6Bridge^7: ^2Vehicle info found in^7 ^4Vehicles^7 ^2table^7: ^6"..(v.hash and v.hash or v.model).. " ^7(^6"..Vehicles[k].name.."^7)") - end - carInfo.name = Vehicles[k].name.." "..Vehicles[k].brand - carInfo.price = Vehicles[k].price - carInfo.class = classlist[GetVehicleClass(vehicle) + 1], GetVehicleClass(vehicle) - break - end - end - - if not carInfo.name then - if Config.System.Debug then - print("^6Bridge^7: ^2Vehicle ^1not ^2found in ^4vehicles^7 ^2table^7: ^6"..model.." ^7(^6"..GetDisplayNameFromVehicleModel(model):lower().."^7)") - end - carInfo.name = string.upper(GetMakeNameFromVehicleModel(model).." "..GetDisplayNameFromVehicleModel(model)) - carInfo.price = 0 - carInfo.class = classlist[GetVehicleClass(vehicle) + 1], GetVehicleClass(vehicle) - end - return carInfo - else - if not carInfo.name then - if Config.System.Debug then - print("^6Bridge^7: ^2Vehicle ^1not ^2found in ^4vehicles^7 ^2table^7: ^6"..model.." ^7(^6"..GetDisplayNameFromVehicleModel(model):lower().."^7)") - end - carInfo.name = string.upper(GetMakeNameFromVehicleModel(model).." "..GetDisplayNameFromVehicleModel(model)) - carInfo.price = 0 - carInfo.class = classlist[GetVehicleClass(vehicle) + 1], GetVehicleClass(vehicle) - end - end - else - return carInfo - end -end - --- Vehicle Properties -- -function getVehicleProperties(vehicle) - local properties = {} - if vehicle == nil then return nil end - if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - properties = Core.Functions.GetVehicleProperties(vehicle) - if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end - elseif GetResourceState(OXLibExport):find("start") then - properties = lib.getVehicleProperties(vehicle) - if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..OXLibExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end - end - return properties -end - -function setVehicleProperties(vehicle, props) - local oldProps = getVehicleProperties(vehicle) - if checkDifferences(vehicle, props) then - --if Config.System.Debug then debugDifferences(vehicle, props) end - if not DoesEntityExist(vehicle) then - print(("Unable to set vehicle properties for '%s' (entity does not exist)"): - format(vehicle)) - end - if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - Core.Functions.SetVehicleProperties(vehicle, props) - if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end - else - TriggerServerEvent(GetCurrentResourceName()..":ox:setVehicleProperties", VehToNet(vehicle), props) - end - else - if Config.System.Debug then print("^6Bridge^7: ^2No Changes Found ^7 [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end - end -end - -function checkDifferences(vehicle, newProps) - local oldProps = getVehicleProperties(vehicle) - if Config.System.Debug then print("^6Bridge^7: ^2Finding differences in ^3Vehicle Properties^7") end - local allow = false - for k in pairs(oldProps) do - if json.encode(oldProps[k]) ~= json.encode(newProps[k]) then - allow = true - if Config.System.Debug then - print("^6Bridge^7: ^5Old ^7[^3"..k.."^7] - "..json.encode(oldProps[k], { indent = true })) - print("^6Bridge^7: ^5New ^7[^3"..k.."^7] - "..json.encode(newProps[k], { indent = true })) - end - end - end - return allow -end - -RegisterNetEvent(GetCurrentResourceName()..":ox:setVehicleProperties", function(netId, props) - local vehicle = NetworkGetEntityFromNetworkId(netId) - local value = props - Entity(vehicle).state[GetCurrentResourceName()..':setVehicleProperties'] = value -end) - -AddStateBagChangeHandler(GetCurrentResourceName()..':setVehicleProperties', '', function(bagName, _, value) - if not value or not GetEntityFromStateBagName then return end - local entity = GetEntityFromStateBagName(bagName) - local networked = not bagName:find('localEntity') - if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..OXLibExport.."^7] - [^3"..entity.."^7] - [^3"..GetEntityModel(entity).."^7] - [^3"..value.plate.."^7]") end - - if networked and NetworkGetEntityOwner(entity) ~= cache.playerId then return end - - if lib.setVehicleProperties(entity, value) then - Entity(entity).state:set('setVehicleProperties', nil, true) - end -end) - -RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc) - local src = newsrc or source - local fundResource = "" - if type == "cash" then - if GetResourceState(OXInv):find("start") then fundResource = OXInv - exports[OXInv]:RemoveItem(src, "money", cost) - elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost) - elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport - local Player = ESX.GetPlayerFromId(src) - Player.removeMoney(cost, "") - end - end - if type == "bank" then - if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport - Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost) - elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport - local Player = ESX.GetPlayerFromId(src) - Player.removeMoney(cost, "") - 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) - -function createUseableItem(item, funct) - if GetResourceState(ESXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering item as ^3Useable^2 with ^7es_extended", item) end - while not ESX do Wait(0) end - ESX.RegisterUsableItem(item, funct) - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering item as ^3Useable^2 with ^7qb-core", item) end - Core.Functions.CreateUseableItem(item, funct) - elseif GetResourceState(QBXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering item as ^3Useable^2 with ^7qbx_core", item) end - exports[QBXExport]:CreateUseableItem(item, funct) - end -end - -function hasJob(job, source, grade) local hasJob, duty = false, true - if source then - local src = tonumber(source) - if GetResourceState(ESXExport):find("start") then - local info = ESX.GetPlayerFromId(src).job - while not info do - info = ESX.GetPlayerData(src).job - Wait(100) - end - if info.name == job then hasJob = true end - - elseif GetResourceState(OXCoreExport):find("start") then - local chunk = assert(load(LoadResourceFile('ox_core', ('imports/%s.lua'):format('server')), ('@@ox_core/%s'):format(file))) - chunk() - local player = Ox.GetPlayer(tonumber(src)) - for k, v in pairs(player.getGroups()) do - if k == job then hasJob = true end - end - - elseif GetResourceState(QBXExport):find("start") then - local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job - if jobinfo.name == job then hasJob = true - duty = exports[QBXExport]:GetPlayer(src).PlayerData.job.onduty - if grade and not (grade <= jobinfo.grade.level) then hasJob = false end - end - local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang - if ganginfo.name == job then hasJob = true - if grade and not (grade <= ganginfo.grade.level) then hasJob = false end - end - - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - if Core.Functions.GetPlayer then -- support older qb-core functions - local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job - if jobinfo.name == job then hasJob = true - duty = Core.Functions.GetPlayer(src).PlayerData.job.onduty - if grade and not (grade <= jobinfo.grade.level) then hasJob = false end - end - local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang - if ganginfo.name == job then hasJob = true - if grade and not (grade <= ganginfo.grade.level) then hasJob = false end - end - else -- support newer qb-core exports - local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job - if jobinfo.name == job then hasJob = true - duty = exports[QBExport]:GetPlayer(src).PlayerData.job.onduty - if grade and not (grade <= jobinfo.grade.level) then hasJob = false end - end - local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang - if ganginfo.name == job then hasJob = true - if grade and not (grade <= ganginfo.grade.level) then hasJob = false end - end - end - else - print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7") - end - else - if GetResourceState(ESXExport):find("start") then - while not ESX do Wait(10) end - local info = ESX.GetPlayerData().job - while not info do - info = ESX.GetPlayerData().job - Wait(100) - end - if info.name == job then hasJob = true end - - elseif GetResourceState(OXCoreExport):find("start") then - for k, v in pairs(exports[OXCoreExport]:GetPlayerData().groups) do - if k == job then hasJob = true end break - end - - elseif GetResourceState(QBXExport):find("start") then - local jobinfo = QBX.PlayerData.job - if jobinfo.name == job then hasJob = true - duty = QBX.PlayerData.job.onduty - if grade and not (grade <= jobinfo.grade.level) then hasJob = false end - end - local ganginfo = QBX.PlayerData.gang - if ganginfo.name == job then hasJob = true - if grade and not (grade <= ganginfo.grade.level) then hasJob = false end - end - - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - local info = nil - Core.Functions.GetPlayerData(function(PlayerData) - info = PlayerData - end) - local jobinfo = info.job - if jobinfo.name == job then hasJob = true - duty = jobinfo.onduty - if grade and not (grade <= jobinfo.grade.level) then hasJob = false end - end - local ganginfo = info.gang - if ganginfo.name == job then - hasJob = true - if grade and not (grade <= ganginfo.grade.level) then hasJob = false end - end - - else - print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7") - end - end - return hasJob, duty -end - -function getPlayer(source) local Player = {} - if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end - if source then -- If called from server - local src = tonumber(source) - if GetResourceState(ESXExport):find("start") then - local info = ESX.GetPlayerFromId(src) - Player = { - name = info.getName(), - cash = info.getMoney(), - bank = info.getAccount("bank").money, - } - - elseif GetResourceState(OXCoreExport):find("start") then - local file = ('imports/%s.lua'):format('server') - local import = LoadResourceFile('ox_core', file) - local chunk = assert(load(import, ('@@ox_core/%s'):format(file))) - chunk() - local player = Ox.GetPlayer(tonumber(src)) - Player = { - name = ('%s %s'):format(player.firstName, player.lastName), - cash = exports[OXInv]:Search(src, 'count', "money"), - bank = 0, - } - - elseif GetResourceState(QBXExport):find("start") then - local info = exports[QBXExport]:GetPlayer(src) - Player = { - name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname, - cash = exports[OXInv]:Search(src, 'count', "money"), - bank = info.Functions.GetMoney("bank"), - } - - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions - local info = Core.Functions.GetPlayer(src).PlayerData - Player = { - name = info.charinfo.firstname.." "..info.charinfo.lastname, - cash = info.money["cash"], - bank = info.money["bank"], - } - else - local info = exports[QBExport]:GetPlayer(src).PlayerData - Player = { - name = info.charinfo.firstname.." "..info.charinfo.lastname, - cash = info.money["cash"], - bank = info.money["bank"], - } - end - - else - print("^4ERROR^7: ^2No Core detected for getPlayer() ^7- ^2Check ^3exports^1.^2lua^7") - end - else - if GetResourceState(ESXExport):find("start") and ESX ~= nil then - local info = ESX.GetPlayerData() - local cash, bank = 0, 0 - for k, v in pairs(ESX.GetPlayerData().accounts) do - if v.name == "money" then cash = v.money end - if v.name == "bank" then bank = v.money end - end - Player = { - name = ('%s %s'):format(info.firstName, info.lastName), - cash = cash, - bank = bank, - } - elseif GetResourceState(OXCoreExport):find("start") then - local info = exports[OXCoreExport]:GetPlayerData() - Player = { - name = info.firstName.." "..info.lastName, - cash = exports[OXInv]:Search('count', "money"), - bank = 0, - } - elseif GetResourceState(QBXExport):find("start") then - local info = exports[QBXExport]:GetPlayerData() - Player = { - name = info.charinfo.firstname.." "..info.charinfo.lastname, - cash = info.money["cash"], - bank = info.money["bank"], - } - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - local info = nil - Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end) - Player = { - name = info.charinfo.firstname.." "..info.charinfo.lastname, - cash = info.money["cash"], - bank = info.money["bank"], - } - else - print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7") - end - end - return Player -end - -function sendPhoneMail(data) local phoneResource = "" - if GetResourceState("gksphone"):find("start") then phoneResource = "gksphone" - exports["gksphone"]:SendNewMail(data) - - elseif GetResourceState("yflip-phone"):find("start") then phoneResource = "yflip-phone" - TriggerServerEvent(GetCurrentResourceName()..":yflip:SendMail", data) - - elseif GetResourceState("qs-smartphone"):find("start") then phoneResource = "qs-smartphone" - TriggerServerEvent('qs-smartphone:server:sendNewMail', data) - - elseif GetResourceState("qs-smartphone-pro"):find("start") then phoneResource = "qs-smartphone-pro" - TriggerServerEvent('phone:sendNewMail', data) - - elseif GetResourceState("roadphone"):find("start") then phoneResource = "roadphone" - data.message = data.message:gsub("%
", "\n") - exports['roadphone']:sendMail(data) - - elseif GetResourceState("lb-phone"):find("start") then phoneResource = "lb-phone" - TriggerServerEvent(GetCurrentResourceName()..":lbphone:SendMail", data) - - elseif GetResourceState("qb-phone"):find("start") then phoneResource = "qb-phone" - TriggerServerEvent('qb-phone:server:sendNewMail', data) - - elseif GetResourceState("jpr-phonesystem"):find("start") then phoneResource = "jpr-phonesystem" - TriggerServerEvent(GetCurrentResourceName()..":jpr:SendMail", data) - end - - if phoneResource ~= "" then if Config.System.Debug then print("^6Bridge^7[^3"..phoneResource.."^7]: ^2Sending mail to player") end - else print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7 - ^2No supported phone found") end -end - -RegisterNetEvent(GetCurrentResourceName()..":lbphone:SendMail", function(data) - local src = source - local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber(src) - local emailAddress = exports["lb-phone"]:GetEmailAddress(phoneNumber) - exports["lb-phone"]:SendMail({ - to = emailAddress, - subject = data.subject, - message = data.message, - --[[attachments = { - "https://cdn.discordapp.com/attachments/1035667053115363349/1042500877426110474/upload.png", - },]] - actions = data.buttons, - }) -end) - -RegisterNetEvent(GetCurrentResourceName()..":yflip:SendMail", function(data) - local src = source - exports["yflip-phone"]:SendMail({ - title = data.subject, - sender = data.sender, - senderDisplayName = data.sender, - content = data.message, - actions = data.buttons, - }, 'source', src) -end) - -RegisterNetEvent(GetCurrentResourceName()..":jpr:SendMail", function(data) - local QBCore = exports['qb-core']:GetCoreObject() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - TriggerEvent('jpr-phonesystem:server:sendEmail', { - Assunto = data.subject, -- Subject - Conteudo = data.message, -- Content - Enviado = data.sender, -- Submitted by - Destinatario = Player.PlayerData.citizenid, -- Target - Event = {}, - }) -end) - -function registerCommand(command, options) - if GetResourceState(OXLibExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..OXLibExport, command) end - lib.addCommand(command, { help = options[1], restricted = options[5] and "group."..options[5] or nil }, options[4]) - elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then - if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Command^2 with ^7qb-core"..QBExport, command) end - Core.Commands.Add(command, options[1], options[2], options[3], options[4], options[5] and options[5] or nil) - end -end - -function invImg(item) - local imgLink = "" - if item ~= "" and Items[item] then - if GetResourceState(OXInv):find("start") then - imgLink = "nui://"..OXInv.."/web/images/"..(Items[item].image or "") - elseif GetResourceState(QSInv):find("start") then - imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "") - elseif GetResourceState(CoreInv):find("start") then - imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "") - elseif GetResourceState(OrigenInv):find("start") then - imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "") - elseif GetResourceState(QBInv):find("start") then - imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "") - else - print("^4ERROR^7: ^2No Inventory detected for invImg ^7- ^2Check ^3exports^1.^2lua^7") - end - end - return imgLink -end - -function registerStash(name, label, slots, weight) - if GetResourceState(OXInv):find("start") then - --print("Registering OX Stash:", name, label) - exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000) - elseif GetResourceState(QSInv):find("start") then - --print("Registering QS Stash:", name, label) - exports[QSInv]:RegisterStash(name, slots or 50, weight or 4000000) - end -end - --- duiList callback here because it wouldnt load in functions.lua - -if IsDuplicityVersion() then - createCallback(GetCurrentResourceName()..":Server:duiList", function(source, cb) - if GetResourceState(OXLibExport):find("start") then - return duiList - else - cb(duiList) - end - end) -end - - --- IN NO WAY PERFECT --