├── .prettierrc ├── .editorconfig ├── fxmanifest.lua ├── html ├── index.html ├── css │ └── style.css └── js │ └── app.js ├── README.md ├── data ├── debug.lua └── bones.lua ├── init.lua ├── client.lua └── LICENSE.md /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "singleQuote": true, 4 | "useTabs": false, 5 | "tabWidth": 2, 6 | "semi": true, 7 | "bracketSpacing": true, 8 | "trailingComma": "es5" 9 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = false 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | indent_size = 2 12 | indent_style = space 13 | 14 | [*.lua] 15 | indent_size = 4 16 | indent_style = tab 17 | 18 | [*.md] 19 | indent_size = 4 20 | indent_style = tab -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | --[[ FX Information ]]-- 2 | fx_version 'cerulean' 3 | use_experimental_fxv2_oal 'yes' 4 | lua54 'yes' 5 | game 'gta5' 6 | 7 | --[[ Resource Information ]]-- 8 | name 'qtarget' 9 | author 'Linden, Noms' 10 | version '2.2.2' 11 | repository 'https://github.com/overextended/qtarget' 12 | description 'An optimised targetting solution, based on bt-target' 13 | 14 | --[[ Manifest ]]-- 15 | dependency 'PolyZone' 16 | 17 | ui_page 'html/index.html' 18 | 19 | client_scripts { 20 | '@PolyZone/client.lua', 21 | '@PolyZone/BoxZone.lua', 22 | '@PolyZone/EntityZone.lua', 23 | '@PolyZone/CircleZone.lua', 24 | '@PolyZone/ComboZone.lua', 25 | 'init.lua', 26 | 'client.lua', 27 | } 28 | 29 | files { 30 | 'data/*.lua', 31 | 'html/index.html', 32 | 'html/css/*.css', 33 | 'html/js/*.js' 34 | } 35 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 |
11 |
12 | 15 |
16 |
17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unsupported - Use [ox_target](https://github.com/overextended/ox_target) instead 2 | 3 | qtarget has been largely unmaintained, receiving some occasional fixes and tweaks. 4 | There are issues with the ways many features were implemented, some from trying maintain compatibility with bt-target, but mostly janky patches on top of underlying flaws. 5 | 6 | Development on a replacement is ongoing at [ox_target](https://github.com/overextended/ox_target), which will try to implement _some_ compatibility; however it cannot cover everything and will not attempt to patch poor-design decisions. 7 | 8 | Some issues will be patched in qtarget if necessary, but it is dead (and should have been long ago). 9 | 10 | ## Credits 11 | - Primary development by [@thelindat](https://github.com/thelindat) and [@OfficialNoms](https://github.com/OfficialNoms) 12 | - Inspired by, and based on, including using javascript from: [bt-target](https://github.com/brentN5/bt-target) by [@brentN5](https://github.com/brentN5) 13 | -------------------------------------------------------------------------------- /html/css/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400&display=swap'); 2 | 3 | 4 | .target-eye { 5 | position: absolute; 6 | top: 50%; 7 | left: 50%; 8 | transform: translateY(-50%) translateX(-50%); 9 | font-size: 3vh; 10 | } 11 | 12 | .target-label-wrapper { 13 | position: absolute; 14 | top: 50%; 15 | left: 50%; 16 | margin-left: 3vh; 17 | margin-top: -1.35vh; 18 | } 19 | 20 | .target-label { 21 | list-style: none; 22 | font-size: 1.3vh; 23 | font-family: 'Ubuntu'; 24 | color: white; 25 | text-transform: uppercase; 26 | user-select: none; 27 | white-space: nowrap; 28 | line-height: 1.3vh; 29 | padding-left: 0.2vh; 30 | } 31 | 32 | .target-icon { 33 | color: #355c83; 34 | } 35 | 36 | .target-eye-active { 37 | color: #355c83; 38 | } 39 | 40 | .target-eye-default { 41 | color: #000; 42 | } 43 | 44 | .target-item { 45 | background: linear-gradient(90deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.6) 66%, rgba(0,0,0,0) 100%); 46 | border: 0px; 47 | border-left: 0.2vh solid #355c83; 48 | border-radius: 0.2vh; 49 | width: 25vh; 50 | margin-bottom: 0.50vh; 51 | display: flex; 52 | align-items: center; 53 | padding-left: 1vh; 54 | height: 2.16vh; 55 | transition: all 0.15s ease-in-out; 56 | } 57 | 58 | .target-item:hover { 59 | background: linear-gradient(90deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.6) 66%, rgba(0,0,0,0) 100%); 60 | border-left: 0.2vh solid #3a658f; 61 | transform: scale(1.05); 62 | } -------------------------------------------------------------------------------- /data/debug.lua: -------------------------------------------------------------------------------- 1 | local currentResourceName = GetCurrentResourceName() 2 | local targeting = exports[currentResourceName] 3 | 4 | AddEventHandler(currentResourceName..':debug', function(data) 5 | print('Entity: '..data.entity, 'Model: '..GetEntityModel(data.entity), 'Type: '..GetEntityType(data.entity)) 6 | if data.remove then 7 | targeting:RemoveTargetEntity(data.entity, 'HelloWorld') 8 | else 9 | targeting:AddTargetEntity(data.entity, { 10 | options = { 11 | { 12 | event = currentResourceName..':debug', 13 | icon = 'fas fa-box-circle-check', 14 | label = 'HelloWorld', 15 | remove = true 16 | }, 17 | }, 18 | distance = 3.0 19 | }) 20 | end 21 | 22 | end) 23 | 24 | targeting:Ped({ 25 | options = { 26 | { 27 | event = currentResourceName..':debug', 28 | icon = 'fas fa-male', 29 | label = '(Debug) Ped', 30 | }, 31 | }, 32 | distance = Config.MaxDistance 33 | }) 34 | 35 | targeting:Vehicle({ 36 | options = { 37 | { 38 | event = currentResourceName..':debug', 39 | icon = 'fas fa-car', 40 | label = '(Debug) Vehicle', 41 | }, 42 | }, 43 | distance = Config.MaxDistance 44 | }) 45 | 46 | targeting:Object({ 47 | options = { 48 | { 49 | event = currentResourceName..':debug', 50 | icon = 'fas fa-cube', 51 | label = '(Debug) Object', 52 | }, 53 | }, 54 | distance = Config.MaxDistance 55 | }) 56 | 57 | targeting:Player({ 58 | options = { 59 | { 60 | event = currentResourceName..':debug', 61 | icon = 'fas fa-cube', 62 | label = '(Debug) Player', 63 | }, 64 | }, 65 | distance = Config.MaxDistance 66 | }) -------------------------------------------------------------------------------- /html/js/app.js: -------------------------------------------------------------------------------- 1 | function main(){ 2 | return { 3 | display: false, 4 | eyeActive: false, 5 | target: [], 6 | executeTarget(id){ 7 | if(this.target[id]){ 8 | postData(`selectTarget`, id + 1).then(data => { 9 | if (data.status == 'success') { 10 | this.display = false; 11 | } 12 | }) 13 | } 14 | }, 15 | 16 | listen(){ 17 | window.addEventListener('message', (event) => { 18 | const item = event.data 19 | switch (item.response) { 20 | case 'validTarget': 21 | this.target.splice(0, this.target.length); 22 | for (let [index, itemData] of Object.entries(item.data)) { 23 | if (itemData !== null) { 24 | this.target.push(itemData) 25 | } 26 | } 27 | this.eyeActive = true; 28 | break; 29 | case 'openTarget': 30 | this.display = true; 31 | break; 32 | case 'closeTarget': 33 | this.display = false; 34 | this.eyeActive = false; 35 | this.target.splice(0, this.target.length); 36 | break; 37 | case 'leftTarget': 38 | this.eyeActive = false; 39 | this.target.splice(0, this.target.length); 40 | break 41 | } 42 | }) 43 | } 44 | } 45 | } 46 | 47 | async function postData(event = '', data = {}) { 48 | const response = await fetch(`https://${GetParentResourceName()}/${event}`, { 49 | method: 'POST', // *GET, POST, PUT, DELETE, etc. 50 | mode: 'cors', // no-cors, *cors, same-origin 51 | cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached 52 | credentials: 'same-origin', // include, *same-origin, omit 53 | headers: { 54 | 'Content-Type': 'application/json' 55 | }, 56 | redirect: 'follow', 57 | referrerPolicy: 'no-referrer', 58 | body: JSON.stringify(data) 59 | }); 60 | return response.json(); 61 | } 62 | -------------------------------------------------------------------------------- /data/bones.lua: -------------------------------------------------------------------------------- 1 | local Bones = {Options = {}, Vehicle = {'chassis', 'windscreen', 'seat_pside_r', 'seat_dside_r', 'bodyshell', 'suspension_lm', 'suspension_lr', 'platelight', 'attach_female', 'attach_male', 'bonnet', 'boot', 'chassis_dummy', 'chassis_Control', 'door_dside_f', 'door_dside_r', 'door_pside_f', 'door_pside_r', 'Gun_GripR', 'windscreen_f', 'platelight', 'VFX_Emitter', 'window_lf', 'window_lr', 'window_rf', 'window_rr', 'engine', 'gun_ammo', 'ROPE_ATTATCH', 'wheel_lf', 'wheel_lr', 'wheel_rf', 'wheel_rr', 'exhaust', 'overheat', 'seat_dside_f', 'seat_pside_f', 'Gun_Nuzzle', 'seat_r'}} 2 | 3 | if Config.EnableDefaultOptions then 4 | local BackEngineVehicles = { 5 | [`ninef`] = true, 6 | [`adder`] = true, 7 | [`vagner`] = true, 8 | [`t20`] = true, 9 | [`infernus`] = true, 10 | [`zentorno`] = true, 11 | [`reaper`] = true, 12 | [`comet2`] = true, 13 | [`comet3`] = true, 14 | [`jester`] = true, 15 | [`jester2`] = true, 16 | [`cheetah`] = true, 17 | [`cheetah2`] = true, 18 | [`prototipo`] = true, 19 | [`turismor`] = true, 20 | [`pfister811`] = true, 21 | [`ardent`] = true, 22 | [`nero`] = true, 23 | [`nero2`] = true, 24 | [`tempesta`] = true, 25 | [`vacca`] = true, 26 | [`bullet`] = true, 27 | [`osiris`] = true, 28 | [`entityxf`] = true, 29 | [`turismo2`] = true, 30 | [`fmj`] = true, 31 | [`re7b`] = true, 32 | [`tyrus`] = true, 33 | [`italigtb`] = true, 34 | [`penetrator`] = true, 35 | [`monroe`] = true, 36 | [`ninef2`] = true, 37 | [`stingergt`] = true, 38 | [`surfer`] = true, 39 | [`surfer2`] = true, 40 | [`gp1`] = true, 41 | [`autarch`] = true, 42 | [`tyrant`] = true 43 | } 44 | 45 | local function ToggleDoor(vehicle, door) 46 | if GetVehicleDoorLockStatus(vehicle) ~= 2 then 47 | if GetVehicleDoorAngleRatio(vehicle, door) > 0.0 then 48 | SetVehicleDoorShut(vehicle, door, false) 49 | else 50 | SetVehicleDoorOpen(vehicle, door, false) 51 | end 52 | end 53 | end 54 | 55 | Bones.Options['seat_dside_f'] = { 56 | ["Toggle Front Door"] = { 57 | icon = "fas fa-door-open", 58 | label = "Toggle Front Door", 59 | canInteract = function(entity) 60 | return GetEntityBoneIndexByName(entity, 'door_dside_f') ~= -1 61 | end, 62 | action = function(entity) 63 | ToggleDoor(entity, 0) 64 | end, 65 | distance = 1.2 66 | } 67 | } 68 | 69 | Bones.Options['seat_pside_f'] = { 70 | ["Toggle Front Door"] = { 71 | icon = "fas fa-door-open", 72 | label = "Toggle Front Door", 73 | canInteract = function(entity) 74 | return GetEntityBoneIndexByName(entity, 'door_pside_f') ~= -1 75 | end, 76 | action = function(entity) 77 | ToggleDoor(entity, 1) 78 | end, 79 | distance = 1.2 80 | } 81 | } 82 | 83 | Bones.Options['seat_dside_r'] = { 84 | ["Toggle Rear Door"] = { 85 | icon = "fas fa-door-open", 86 | label = "Toggle Rear Door", 87 | canInteract = function(entity) 88 | return GetEntityBoneIndexByName(entity, 'door_dside_r') ~= -1 89 | end, 90 | action = function(entity) 91 | ToggleDoor(entity, 2) 92 | end, 93 | distance = 1.2 94 | } 95 | } 96 | 97 | Bones.Options['seat_pside_r'] = { 98 | ["Toggle Rear Door"] = { 99 | icon = "fas fa-door-open", 100 | label = "Toggle Rear Door", 101 | canInteract = function(entity) 102 | return GetEntityBoneIndexByName(entity, 'door_pside_r') ~= -1 103 | end, 104 | action = function(entity) 105 | ToggleDoor(entity, 3) 106 | end, 107 | distance = 1.2 108 | } 109 | } 110 | 111 | Bones.Options['bonnet'] = { 112 | ["Toggle Hood"] = { 113 | icon = "fa-duotone fa-engine", 114 | label = "Toggle Hood", 115 | action = function(entity) 116 | ToggleDoor(entity, BackEngineVehicles[GetEntityModel(entity)] and 5 or 4) 117 | end, 118 | distance = 0.9 119 | } 120 | } 121 | 122 | Bones.Options['boot'] = { 123 | ["Toggle Trunk"] = { 124 | icon = "fas fa-truck-ramp-box", 125 | label = "Toggle Trunk", 126 | action = function(entity) 127 | ToggleDoor(entity, BackEngineVehicles[GetEntityModel(entity)] and 4 or 5) 128 | end, 129 | distance = 0.9 130 | } 131 | } 132 | end 133 | 134 | return Bones -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | function Load(name) 2 | local resourceName = GetCurrentResourceName() 3 | local chunk = LoadResourceFile(resourceName, ('data/%s.lua'):format(name)) 4 | if chunk then 5 | local err 6 | chunk, err = load(chunk, ('@@%s/data/%s.lua'):format(resourceName, name), 't') 7 | if err then 8 | error(('\n^1 %s'):format(err), 0) 9 | end 10 | return chunk() 11 | end 12 | end 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Settings 16 | ------------------------------------------------------------------------------- 17 | 18 | Config = {} 19 | 20 | -- It's possible to interact with entities through walls so this should be low 21 | Config.MaxDistance = 7.0 22 | 23 | -- Enable debug options 24 | Config.Debug = false 25 | 26 | -- Enable default options (Toggling vehicle doors) 27 | Config.EnableDefaultOptions = true 28 | 29 | -- Whether to have the target as a toggle or not 30 | Config.Toggle = false 31 | 32 | -- Draw a Sprite on the center of a PolyZone to hint where it's located 33 | Config.DrawSprite = false 34 | 35 | -- The default distance to draw the Sprite 36 | Config.DrawDistance = 10.0 37 | 38 | -- The color of the sprite in rgb, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/ 39 | Config.DrawColor = {255, 255, 255, 255} 40 | 41 | -- The color of the sprite in rgb when the PolyZone is targeted, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/ 42 | Config.SuccessDrawColor = {98, 135, 236, 255} 43 | 44 | -- Enable outlines around the entity you're looking at 45 | Config.EnableOutline = false 46 | 47 | -- The color of the outline in rgb, the first value is red, the second value is green, the third value is blue and the last value is alpha (opacity). Here is a link to a color picker to get these values: https://htmlcolorcodes.com/color-picker/ 48 | Config.OutlineColor = {255, 255, 255, 255} 49 | 50 | -- Control for key press detection on the context menu, it's the Left Mouse Button by default, controls are found here https://docs.fivem.net/docs/game-references/controls/ 51 | Config.MenuControlKey = 237 52 | 53 | -- Key to open the target eye, here you can find all the names: https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard/ 54 | Config.OpenKey = 'LMENU' -- Left Alt 55 | 56 | -- Supported values: 'ESX', 'QB', false 57 | Config.Framework = false 58 | 59 | ------------------------------------------------------------------------------- 60 | -- Functions 61 | ------------------------------------------------------------------------------- 62 | 63 | local function JobCheck() return true end 64 | local function GangCheck() return true end 65 | local function ItemCheck() return true end 66 | local function CitizenCheck() return true end 67 | 68 | CreateThread(function() 69 | if not Config.Framework then 70 | local framework = 'es_extended' 71 | local state = GetResourceState(framework) 72 | 73 | if state == 'missing' then 74 | framework = 'qb-core' 75 | state = GetResourceState(framework) 76 | end 77 | 78 | if state ~= 'missing' then 79 | if state ~= 'started' then 80 | local timeout = 0 81 | repeat 82 | timeout += 1 83 | Wait(0) 84 | until GetResourceState(framework) == 'started' or timeout > 100 85 | end 86 | Config.Framework = framework == 'es_extended' and 'ESX' or 'QB' 87 | end 88 | end 89 | 90 | if Config.Framework == 'ESX' then 91 | local ESX = exports['es_extended']:getSharedObject() 92 | 93 | local resState = GetResourceState('ox_inventory') 94 | if resState ~= 'missing' and resState ~= 'unknown' then 95 | ItemCheck = function(items) 96 | if type(items) == 'table' then 97 | local finalcount = 0 98 | local count = 0 99 | local itemArray = {} 100 | local isArray = table.type(items) == 'array' 101 | for _ in pairs(items) do finalcount += 1 end 102 | if isArray then 103 | itemArray = items 104 | else 105 | for k in pairs(items) do 106 | itemArray[#itemArray + 1] = k 107 | end 108 | end 109 | 110 | local returnedItems = exports.ox_inventory:Search('count', itemArray) 111 | 112 | if returnedItems then 113 | for name, itemCount in pairs(returnedItems) do 114 | if isArray then -- Table expected in this format {'itemName1', 'itemName2', 'etc'} 115 | if itemCount >= 1 then 116 | count += 1 117 | end 118 | else -- Table expected in this format {['itemName'] = amount} 119 | if itemCount >= items[name] then 120 | count += 1 121 | end 122 | end 123 | if count == finalcount then -- This is to make sure it checks all items in the table instead of only one of the items 124 | return true 125 | end 126 | end 127 | end 128 | return false 129 | else 130 | return exports.ox_inventory:Search('count', items) >= 1 131 | end 132 | end 133 | else 134 | ItemCheck = function(items) 135 | local isTable = type(items) == 'table' 136 | local isArray = isTable and table.type(items) == 'array' or false 137 | local totalItems = #items 138 | local count = 0 139 | local kvIndex = 2 140 | if isTable and not isArray then 141 | totalItems = 0 142 | for _ in pairs(items) do totalItems += 1 end 143 | kvIndex = 1 144 | end 145 | for _, itemData in pairs(ESX.GetPlayerData().inventory) do 146 | if isTable then 147 | for k, v in pairs(items) do 148 | local itemKV = {k, v} 149 | if itemData.name == itemKV[kvIndex] and ((not isArray and itemData.count >= v) or (isArray and itemData.count > 0)) then 150 | count += 1 151 | end 152 | end 153 | if count == totalItems then 154 | return true 155 | end 156 | else -- Single item as string 157 | if itemData.name == items and itemData.count > 0 then 158 | return true 159 | end 160 | end 161 | end 162 | return false 163 | end 164 | end 165 | 166 | JobCheck = function(job) 167 | if type(job) == 'table' then 168 | job = job[ESX.PlayerData.job.name] 169 | if job and ESX.PlayerData.job.grade >= job then 170 | return true 171 | end 172 | elseif job == 'all' or job == ESX.PlayerData.job.name then 173 | return true 174 | end 175 | return false 176 | end 177 | 178 | RegisterNetEvent('esx:playerLoaded', function(xPlayer) 179 | ESX.PlayerData = xPlayer 180 | end) 181 | 182 | RegisterNetEvent('esx:setJob', function(job) 183 | ESX.PlayerData.job = job 184 | end) 185 | 186 | RegisterNetEvent('esx:onPlayerLogout', function() 187 | table.wipe(ESX.PlayerData) 188 | end) 189 | 190 | AddEventHandler('esx:setPlayerData', function(key, val) 191 | if GetInvokingResource() == 'es_extended' then 192 | ESX.PlayerData[key] = val 193 | end 194 | end) 195 | 196 | elseif Config.Framework == 'QB' then 197 | local QBCore = exports['qb-core']:GetCoreObject() 198 | local PlayerData = QBCore.Functions.GetPlayerData() 199 | 200 | ItemCheck = QBCore.Functions.HasItem 201 | 202 | JobCheck = function(job) 203 | if type(job) == 'table' then 204 | job = job[PlayerData.job.name] 205 | if job and PlayerData.job.grade.level >= job then 206 | return true 207 | end 208 | elseif job == 'all' or job == PlayerData.job.name then 209 | return true 210 | end 211 | return false 212 | end 213 | 214 | GangCheck = function(gang) 215 | if type(gang) == 'table' then 216 | gang = gang[PlayerData.gang.name] 217 | if gang and PlayerData.gang.grade.level >= gang then 218 | return true 219 | end 220 | elseif gang == 'all' or gang == PlayerData.gang.name then 221 | return true 222 | end 223 | return false 224 | end 225 | 226 | CitizenCheck = function(citizenid) 227 | return citizenid == PlayerData.citizenid or citizenid[PlayerData.citizenid] 228 | end 229 | 230 | RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() 231 | PlayerData = QBCore.Functions.GetPlayerData() 232 | end) 233 | 234 | RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() 235 | table.wipe(PlayerData) 236 | end) 237 | 238 | RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo) 239 | PlayerData.job = JobInfo 240 | end) 241 | 242 | RegisterNetEvent('QBCore:Client:OnGangUpdate', function(GangInfo) 243 | PlayerData.gang = GangInfo 244 | end) 245 | 246 | RegisterNetEvent('QBCore:Player:SetPlayerData', function(val) 247 | PlayerData = val 248 | end) 249 | end 250 | 251 | function CheckOptions(data, entity, distance) 252 | if data.distance and distance > data.distance then return false end 253 | if data.job and not JobCheck(data.job) then return false end 254 | if data.gang and not GangCheck(data.gang) then return false end 255 | if data.item and not ItemCheck(data.item) then return false end 256 | if data.citizenid and not CitizenCheck(data.citizenid) then return false end 257 | if data.canInteract and not data.canInteract(entity, distance, data) then return false end 258 | return true 259 | end 260 | end) -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | local screen = {} 2 | local Config = Config 3 | local listSprite = {} 4 | 5 | --------------------------------------- 6 | --- Source: https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/libs/scripts/examples/scripting_gta.lua 7 | --- Credits to gottfriedleibniz 8 | local glm = require 'glm' 9 | 10 | -- Cache common functions 11 | local glm_rad = glm.rad 12 | local glm_quatEuler = glm.quatEulerAngleZYX 13 | local glm_rayPicking = glm.rayPicking 14 | 15 | -- Cache direction vectors 16 | local glm_up = glm.up() 17 | local glm_forward = glm.forward() 18 | 19 | local function ScreenPositionToCameraRay() 20 | local pos = GetFinalRenderedCamCoord() 21 | local rot = glm_rad(GetFinalRenderedCamRot(2)) 22 | local q = glm_quatEuler(rot.z, rot.y, rot.x) 23 | return pos, glm_rayPicking( 24 | q * glm_forward, 25 | q * glm_up, 26 | glm_rad(screen.fov), 27 | screen.ratio, 28 | 0.10000, -- GetFinalRenderedCamNearClip(), 29 | 10000.0, -- GetFinalRenderedCamFarClip(), 30 | 0, 0 31 | ) 32 | end 33 | --------------------------------------- 34 | local playerPed 35 | local GetEntityCoords = GetEntityCoords 36 | local Wait = Wait 37 | local pcall = pcall 38 | local HasEntityClearLosToEntity = HasEntityClearLosToEntity 39 | local GetEntityType = GetEntityType 40 | local StartShapeTestLosProbe = StartShapeTestLosProbe 41 | local GetShapeTestResult = GetShapeTestResult 42 | local PlayerPedId = PlayerPedId 43 | 44 | ---@param flag number 45 | ---@param playerCoords vector3 46 | ---@return vector3 coords 47 | ---@return number distance 48 | ---@return number entity 49 | ---@return number entity_type 50 | local function RaycastCamera(flag, playerCoords) 51 | if not playerPed then playerPed = PlayerPedId() end 52 | if not playerCoords then playerCoords = GetEntityCoords(playerPed) end 53 | 54 | local rayPos, rayDir = ScreenPositionToCameraRay() 55 | local destination = rayPos + 16 * rayDir 56 | local rayHandle = StartShapeTestLosProbe(rayPos.x, rayPos.y, rayPos.z, destination.x, destination.y, destination.z, flag or -1, playerPed, 4) 57 | 58 | while true do 59 | local result, _, endCoords, _, entityHit = GetShapeTestResult(rayHandle) 60 | 61 | if result ~= 1 then 62 | local distance = playerCoords and #(playerCoords - endCoords) 63 | 64 | if flag == 30 and entityHit then 65 | entityHit = HasEntityClearLosToEntity(entityHit, playerPed, 7) and entityHit 66 | end 67 | 68 | local entityType = entityHit and GetEntityType(entityHit) 69 | 70 | if entityType == 0 and pcall(GetEntityModel, entityHit) then 71 | entityType = 3 72 | end 73 | 74 | return endCoords, distance, entityHit, entityType or 0 75 | end 76 | 77 | Wait(0) 78 | end 79 | end 80 | exports('raycast', RaycastCamera) 81 | 82 | local hasFocus = false 83 | 84 | local function DisableNUI() 85 | SetNuiFocus(false, false) 86 | SetNuiFocusKeepInput(false) 87 | hasFocus = false 88 | end 89 | 90 | exports('DisableNUI', DisableNUI) 91 | 92 | local targetActive = false 93 | 94 | local function EnableNUI() 95 | if not targetActive or hasFocus then return end 96 | SetCursorLocation(0.5, 0.5) 97 | SetNuiFocus(true, true) 98 | SetNuiFocusKeepInput(true) 99 | hasFocus = true 100 | end 101 | 102 | local success = false 103 | local sendData = {} 104 | local sendDistance = {} 105 | local nuiData = {} 106 | local table_wipe = table.wipe 107 | local pairs = pairs 108 | local CheckOptions 109 | 110 | local function LeaveTarget() 111 | SetNuiFocus(false, false) 112 | SetNuiFocusKeepInput(false) 113 | success, hasFocus = false, false 114 | table_wipe(sendData) 115 | SendNUIMessage({response = 'leftTarget'}) 116 | end 117 | 118 | exports('LeaveTarget', LeaveTarget) 119 | 120 | ---@param forcedisable boolean 121 | local function DisableTarget(forcedisable) 122 | if (not targetActive and hasFocus and not Config.Toggle) or not forcedisable then return end 123 | SetNuiFocus(false, false) 124 | SetNuiFocusKeepInput(false) 125 | Wait(100) 126 | targetActive, success, hasFocus = false, false, false 127 | SendNUIMessage({response = "closeTarget"}) 128 | end 129 | 130 | exports('DisableTarget', DisableTarget) 131 | 132 | ---@param entity number 133 | ---@param bool boolean 134 | local function DrawOutlineEntity(entity, bool) 135 | if not Config.EnableOutline or IsEntityAPed(entity) then return end 136 | SetEntityDrawOutline(entity, bool) 137 | SetEntityDrawOutlineColor(Config.OutlineColor[1], Config.OutlineColor[2], Config.OutlineColor[3], Config.OutlineColor[4]) 138 | end 139 | 140 | exports('DrawOutlineEntity', DrawOutlineEntity) 141 | 142 | ---@param datatable table 143 | ---@param entity number 144 | ---@param distance number 145 | ---@param isZone boolean 146 | ---@return number | string 147 | local function SetupOptions(datatable, entity, distance, isZone) 148 | if not isZone then table_wipe(sendDistance) end 149 | table_wipe(nuiData) 150 | local slot = 0 151 | for _, data in pairs(datatable) do 152 | if CheckOptions(data, entity, distance) then 153 | slot = data.num or slot + 1 154 | sendData[slot] = data 155 | sendData[slot].entity = entity 156 | nuiData[slot] = { 157 | icon = data.icon, 158 | label = data.label 159 | } 160 | if not isZone then 161 | sendDistance[data.distance] = true 162 | end 163 | else 164 | if not isZone then 165 | sendDistance[data.distance] = false 166 | end 167 | end 168 | end 169 | return slot 170 | end 171 | 172 | local IsDisabledControlPressed = IsDisabledControlPressed 173 | 174 | ---@param flag number 175 | ---@param data table 176 | ---@param entity number 177 | ---@param distance number 178 | local function CheckEntity(flag, data, entity, distance) 179 | if not next(data) then return end 180 | SetupOptions(data, entity, distance, false) 181 | if not next(nuiData) then 182 | LeaveTarget() 183 | DrawOutlineEntity(entity, false) 184 | return 185 | end 186 | success = true 187 | SendNUIMessage({response = 'validTarget', data = nuiData}) 188 | DrawOutlineEntity(entity, true) 189 | while targetActive and success do 190 | local _, dist, entity2, _ = RaycastCamera(flag) 191 | if entity ~= entity2 then 192 | LeaveTarget() 193 | DrawOutlineEntity(entity, false) 194 | break 195 | elseif not hasFocus and IsDisabledControlPressed(0, Config.MenuControlKey) then 196 | EnableNUI() 197 | DrawOutlineEntity(entity, false) 198 | else 199 | for k, v in pairs(sendDistance) do 200 | if v and dist > k then 201 | LeaveTarget() 202 | DrawOutlineEntity(entity, false) 203 | break 204 | end 205 | end 206 | end 207 | Wait(0) 208 | end 209 | LeaveTarget() 210 | DrawOutlineEntity(entity, false) 211 | end 212 | 213 | exports('CheckEntity', CheckEntity) 214 | 215 | local Bones = Load('bones') 216 | local GetEntityBoneIndexByName = GetEntityBoneIndexByName 217 | local GetWorldPositionOfEntityBone = GetWorldPositionOfEntityBone 218 | 219 | ---@param coords vector3 220 | ---@param entity number 221 | ---@param bonelist table 222 | ---@return boolean | number 223 | ---@return number? 224 | ---@return string? 225 | local function CheckBones(coords, entity, bonelist) 226 | local closestBone = -1 227 | local closestDistance = 20 228 | local closestPos, closestBoneName 229 | for _, v in pairs(bonelist) do 230 | if Bones.Options[v] then 231 | local boneId = GetEntityBoneIndexByName(entity, v) 232 | local bonePos = GetWorldPositionOfEntityBone(entity, boneId) 233 | local distance = #(coords - bonePos) 234 | if closestBone == -1 or distance < closestDistance then 235 | closestBone, closestDistance, closestPos, closestBoneName = boneId, distance, bonePos, v 236 | end 237 | end 238 | end 239 | if closestBone ~= -1 then return closestBone, closestPos, closestBoneName 240 | else return false end 241 | end 242 | 243 | exports('CheckBones', CheckBones) 244 | 245 | local Types = {{}, {}, {}} 246 | local Players = {} 247 | local Entities = {} 248 | local Models = {} 249 | local Zones = {} 250 | local allowTarget = true 251 | 252 | local SetPauseMenuActive = SetPauseMenuActive 253 | local DisableAllControlActions = DisableAllControlActions 254 | local EnableControlAction = EnableControlAction 255 | local NetworkGetEntityIsNetworked = NetworkGetEntityIsNetworked 256 | local NetworkGetNetworkIdFromEntity = NetworkGetNetworkIdFromEntity 257 | local GetEntityModel = GetEntityModel 258 | local IsPedAPlayer = IsPedAPlayer 259 | local SetDrawOrigin = SetDrawOrigin 260 | local DrawSprite = DrawSprite 261 | local ClearDrawOrigin = ClearDrawOrigin 262 | local HasStreamedTextureDictLoaded = HasStreamedTextureDictLoaded 263 | local RequestStreamedTextureDict = RequestStreamedTextureDict 264 | 265 | local function DrawTarget() 266 | CreateThread(function() 267 | while not HasStreamedTextureDictLoaded("shared") do Wait(10) RequestStreamedTextureDict("shared", true) end 268 | local sleep 269 | while targetActive do 270 | sleep = next(listSprite) and 0 or 500 271 | 272 | for _, zone in pairs(listSprite) do 273 | local r, g, b, a 274 | 275 | if zone.success then 276 | r = zone.targetoptions.successDrawColor?[1] or Config.SuccessDrawColor[1] 277 | g = zone.targetoptions.successDrawColor?[2] or Config.SuccessDrawColor[2] 278 | b = zone.targetoptions.successDrawColor?[3] or Config.SuccessDrawColor[3] 279 | a = zone.targetoptions.successDrawColor?[4] or Config.SuccessDrawColor[4] 280 | else 281 | r = zone.targetoptions.drawColor?[1] or Config.DrawColor[1] 282 | g = zone.targetoptions.drawColor?[2] or Config.DrawColor[2] 283 | b = zone.targetoptions.drawColor?[3] or Config.DrawColor[3] 284 | a = zone.targetoptions.drawColor?[4] or Config.DrawColor[4] 285 | end 286 | 287 | SetDrawOrigin(zone.center.x, zone.center.y, zone.center.z, 0) 288 | DrawSprite("shared", "emptydot_32", 0, 0, 0.02, 0.035, 0, r, g, b, a) 289 | end 290 | 291 | ClearDrawOrigin() 292 | Wait(sleep) 293 | end 294 | 295 | listSprite = {} 296 | end) 297 | end 298 | 299 | local function EnableTarget() 300 | if not allowTarget or success or (Config.Framework == 'QB' and not LocalPlayer.state.isLoggedIn) or IsNuiFocused() then return end 301 | if not CheckOptions then CheckOptions = _ENV.CheckOptions end 302 | if targetActive or not CheckOptions then return end 303 | 304 | targetActive = true 305 | playerPed = PlayerPedId() 306 | screen.ratio = GetAspectRatio(true) 307 | screen.fov = GetFinalRenderedCamFov() 308 | if Config.DrawSprite then DrawTarget() end 309 | 310 | SendNUIMessage({response = 'openTarget'}) 311 | CreateThread(function() 312 | repeat 313 | SetPauseMenuActive(false) 314 | DisableAllControlActions(0) 315 | EnableControlAction(0, 30, true) 316 | EnableControlAction(0, 31, true) 317 | 318 | if not hasFocus then 319 | EnableControlAction(0, 1, true) 320 | EnableControlAction(0, 2, true) 321 | end 322 | 323 | Wait(0) 324 | until not targetActive 325 | end) 326 | 327 | local flag = 30 328 | 329 | while targetActive do 330 | local sleep = 0 331 | if flag == 30 then flag = -1 else flag = 30 end 332 | 333 | local coords, distance, entity, entityType = RaycastCamera(flag) 334 | if distance <= Config.MaxDistance then 335 | if entityType > 0 then 336 | 337 | -- Local(non-net) entity targets 338 | if Entities[entity] then 339 | CheckEntity(flag, Entities[entity], entity, distance) 340 | end 341 | 342 | -- Owned entity targets 343 | if NetworkGetEntityIsNetworked(entity) then 344 | local data = Entities[NetworkGetNetworkIdFromEntity(entity)] 345 | if data then CheckEntity(flag, data, entity, distance) end 346 | end 347 | 348 | -- Player and Ped targets 349 | if entityType == 1 then 350 | local data = Models[GetEntityModel(entity)] 351 | if IsPedAPlayer(entity) then data = Players end 352 | if data and next(data) then CheckEntity(flag, data, entity, distance) end 353 | 354 | -- Vehicle bones and models 355 | elseif entityType == 2 then 356 | local closestBone, _, closestBoneName = CheckBones(coords, entity, Bones.Vehicle) 357 | local data = Bones.Options[closestBoneName] 358 | 359 | if data and next(data) and closestBone then 360 | SetupOptions(data, entity, distance, false) 361 | if next(nuiData) then 362 | success = true 363 | SendNUIMessage({response = 'validTarget', data = nuiData}) 364 | DrawOutlineEntity(entity, true) 365 | while targetActive and success do 366 | local coords2, dist, entity2 = RaycastCamera(flag) 367 | if entity == entity2 then 368 | local closestBone2 = CheckBones(coords2, entity, Bones.Vehicle) 369 | 370 | if closestBone ~= closestBone2 then 371 | LeaveTarget() 372 | DrawOutlineEntity(entity, false) 373 | break 374 | elseif not hasFocus and IsDisabledControlPressed(0, Config.MenuControlKey) then 375 | EnableNUI() 376 | DrawOutlineEntity(entity, false) 377 | else 378 | for k, v in pairs(sendDistance) do 379 | if v and dist > k then 380 | LeaveTarget() 381 | DrawOutlineEntity(entity, false) 382 | break 383 | end 384 | end 385 | end 386 | else 387 | LeaveTarget() 388 | DrawOutlineEntity(entity, false) 389 | break 390 | end 391 | Wait(0) 392 | end 393 | LeaveTarget() 394 | DrawOutlineEntity(entity, false) 395 | end 396 | end 397 | 398 | -- Vehicle model targets 399 | local data = Models[GetEntityModel(entity)] 400 | if data then CheckEntity(flag, data, entity, distance) end 401 | 402 | -- Entity targets 403 | else 404 | local data = Models[GetEntityModel(entity)] 405 | if data then CheckEntity(flag, data, entity, distance) end 406 | end 407 | 408 | -- Generic targets 409 | if not success then 410 | local data = Types[entityType] 411 | if data then CheckEntity(flag, data, entity, distance) end 412 | end 413 | else sleep += 20 end 414 | if not success then 415 | local closestDis, closestZone 416 | for k, zone in pairs(Zones) do 417 | if distance < (closestDis or Config.MaxDistance) and distance <= zone.targetoptions.distance and zone:isPointInside(coords) then 418 | closestDis = distance 419 | closestZone = zone 420 | end 421 | if Config.DrawSprite then 422 | if #(coords - zone.center) < (zone.targetoptions.drawDistance or Config.DrawDistance) then 423 | listSprite[k] = zone 424 | else 425 | listSprite[k] = nil 426 | end 427 | end 428 | end 429 | if closestZone then 430 | SetupOptions(closestZone.targetoptions.options, entity, distance, true) 431 | if next(nuiData) then 432 | success = true 433 | SendNUIMessage({response = 'validTarget', data = nuiData}) 434 | if Config.DrawSprite and listSprite[closestZone.name] then 435 | listSprite[closestZone.name].success = true 436 | end 437 | DrawOutlineEntity(entity, true) 438 | while targetActive and success do 439 | local coords, distance = RaycastCamera(flag) 440 | if not closestZone:isPointInside(coords) or distance > closestZone.targetoptions.distance then 441 | LeaveTarget() 442 | DrawOutlineEntity(entity, false) 443 | break 444 | elseif not hasFocus and IsDisabledControlPressed(0, Config.MenuControlKey) then 445 | EnableNUI() 446 | DrawOutlineEntity(entity, false) 447 | end 448 | Wait(0) 449 | end 450 | if Config.DrawSprite and listSprite[closestZone.name] then -- Check for when the targetActive is false and it removes the zone from listSprite 451 | listSprite[closestZone.name].success = false 452 | end 453 | LeaveTarget() 454 | DrawOutlineEntity(entity, false) 455 | else 456 | repeat 457 | Wait(20) 458 | local coords, _, entity2 = RaycastCamera(flag) 459 | until not targetActive or entity ~= entity2 or not closestZone:isPointInside(coords) 460 | end 461 | else sleep += 20 end 462 | else LeaveTarget() DrawOutlineEntity(entity, false) end 463 | else sleep += 20 end 464 | Wait(sleep) 465 | end 466 | DisableTarget(false) 467 | end 468 | 469 | RegisterNUICallback('selectTarget', function(option, cb) 470 | option = tonumber(option) or option 471 | SetNuiFocus(false, false) 472 | SetNuiFocusKeepInput(false) 473 | Wait(100) 474 | targetActive, success, hasFocus = false, false, false 475 | if not next(sendData) then return end 476 | local data = sendData[option] 477 | if not data then return end 478 | CreateThread(function() 479 | Wait(0) 480 | if data.action then 481 | data.action(data.entity) 482 | cb({status = 'success'}) 483 | elseif data.event then 484 | cb({status = 'success'}) 485 | if data.type == "client" then 486 | TriggerEvent(data.event, data) 487 | elseif data.type == "server" then 488 | TriggerServerEvent(data.event, data) 489 | elseif data.type == "command" then 490 | ExecuteCommand(data.event) 491 | elseif data.type == "qbcommand" then 492 | TriggerServerEvent('QBCore:CallCommand', data.event, data) 493 | else 494 | TriggerEvent(data.event, data) 495 | end 496 | else 497 | cb({status = 'error'}) 498 | error("No trigger setup") 499 | end 500 | end) 501 | end) 502 | 503 | RegisterNUICallback('closeTarget', function() 504 | SetNuiFocus(false, false) 505 | SetNuiFocusKeepInput(false) 506 | Wait(100) 507 | targetActive, success, hasFocus = false, false, false 508 | end) 509 | 510 | RegisterNUICallback('leftTarget', function() 511 | if Config.Toggle then 512 | SetNuiFocus(false, false) 513 | SetNuiFocusKeepInput(false) 514 | Wait(100) 515 | table_wipe(sendData) 516 | success, hasFocus = false, false 517 | else 518 | DisableTarget(true) 519 | end 520 | end) 521 | 522 | if Config.Toggle then 523 | RegisterCommand('playerTarget', function() 524 | if targetActive then 525 | DisableTarget(true) 526 | else 527 | CreateThread(EnableTarget) 528 | end 529 | end, false) 530 | RegisterKeyMapping("playerTarget", "Toggle targeting~", "keyboard", Config.OpenKey) 531 | TriggerEvent('chat:removeSuggestion', '/playerTarget') 532 | else 533 | RegisterCommand('+playerTarget', function() 534 | CreateThread(EnableTarget) 535 | end, false) 536 | RegisterCommand('-playerTarget', DisableTarget, false) 537 | RegisterKeyMapping("+playerTarget", "Enable targeting~", "keyboard", Config.OpenKey) 538 | TriggerEvent('chat:removeSuggestion', '/+playerTarget') 539 | TriggerEvent('chat:removeSuggestion', '/-playerTarget') 540 | end 541 | 542 | ------------------------------------------------------------------------------- 543 | -- Exports 544 | ------------------------------------------------------------------------------- 545 | 546 | ---@param name string 547 | ---@param center vector3 548 | ---@param radius number 549 | ---@param options table 550 | ---@param targetoptions table 551 | ---@return CircleZone 552 | local function AddCircleZone(name, center, radius, options, targetoptions) 553 | local centerType = type(center) 554 | center = (centerType == 'table' or centerType == 'vector4') and vec3(center.x, center.y, center.z) or center 555 | Zones[name] = CircleZone:Create(center, radius, options) 556 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 557 | Zones[name].targetoptions = targetoptions 558 | return Zones[name] 559 | end 560 | exports('AddCircleZone', AddCircleZone) 561 | 562 | ---@param name string 563 | ---@param center vector3 564 | ---@param length number 565 | ---@param width number 566 | ---@param options table 567 | ---@param targetoptions table 568 | ---@return BoxZone 569 | local function AddBoxZone(name, center, length, width, options, targetoptions) 570 | local centerType = type(center) 571 | center = (centerType == 'table' or centerType == 'vector4') and vec3(center.x, center.y, center.z) or center 572 | Zones[name] = BoxZone:Create(center, length, width, options) 573 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 574 | Zones[name].targetoptions = targetoptions 575 | return Zones[name] 576 | end 577 | exports('AddBoxZone', AddBoxZone) 578 | 579 | ---@param name string 580 | ---@param points table 581 | ---@param options table 582 | ---@param targetoptions table 583 | ---@return PolyZone 584 | local function AddPolyZone(name, points, options, targetoptions) 585 | local _points = {} 586 | local pointsType = type(points[1]) 587 | if pointsType == 'table' or pointsType == 'vector3' or pointsType == 'vector4' then 588 | for i = 1, #points do 589 | _points[i] = vec2(points[i].x, points[i].y) 590 | end 591 | end 592 | Zones[name] = PolyZone:Create(#_points > 0 and _points or points, options) 593 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 594 | Zones[name].targetoptions = targetoptions 595 | return Zones[name] 596 | end 597 | exports('AddPolyZone', AddPolyZone) 598 | 599 | ---@param zones table 600 | ---@param options table 601 | ---@param targetoptions table 602 | ---@return ComboZone 603 | local function AddComboZone(zones, options, targetoptions) 604 | Zones[options.name] = ComboZone:Create(zones, options) 605 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 606 | Zones[options.name].targetoptions = targetoptions 607 | return Zones[options.name] 608 | end 609 | exports("AddComboZone", AddComboZone) 610 | 611 | ---@param name string 612 | ---@param entity number 613 | ---@param options table 614 | ---@param targetoptions table 615 | ---@return EntityZone 616 | local function AddEntityZone(name, entity, options, targetoptions) 617 | Zones[name] = EntityZone:Create(entity, options) 618 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 619 | Zones[name].targetoptions = targetoptions 620 | return Zones[name] 621 | end 622 | 623 | exports("AddEntityZone", AddEntityZone) 624 | 625 | ---@param name string 626 | local function RemoveZone(name) 627 | if not Zones[name] then return end 628 | if Zones[name].destroy then Zones[name]:destroy() end 629 | Zones[name] = nil 630 | end 631 | exports('RemoveZone', RemoveZone) 632 | 633 | ---@param tbl table 634 | ---@param distance number 635 | ---@param options table 636 | local function SetOptions(tbl, distance, options) 637 | for _, v in pairs(options) do 638 | if v.required_item then 639 | v.item = v.required_item 640 | v.required_item = nil 641 | end 642 | if not v.distance or v.distance > distance then v.distance = distance end 643 | tbl[v.label] = v 644 | end 645 | end 646 | 647 | ---@param bones table | string 648 | ---@param parameters table 649 | local function AddTargetBone(bones, parameters) 650 | local distance, options = parameters.distance or Config.MaxDistance, parameters.options 651 | if type(bones) == 'table' then 652 | for _, bone in pairs(bones) do 653 | if not Bones.Options[bone] then Bones.Options[bone] = {} end 654 | SetOptions(Bones.Options[bone], distance, options) 655 | end 656 | elseif type(bones) == 'string' then 657 | if not Bones.Options[bones] then Bones.Options[bones] = {} end 658 | SetOptions(Bones.Options[bones], distance, options) 659 | end 660 | end 661 | exports('AddTargetBone', AddTargetBone) 662 | 663 | ---@param bones table | string 664 | ---@param labels table | string 665 | local function RemoveTargetBone(bones, labels) 666 | if type(bones) == 'table' then 667 | for _, bone in pairs(bones) do 668 | if labels then 669 | if type(labels) == 'table' then 670 | for _, v in pairs(labels) do 671 | if Bones.Options[bone] then 672 | Bones.Options[bone][v] = nil 673 | end 674 | end 675 | elseif type(labels) == 'string' then 676 | if Bones.Options[bone] then 677 | Bones.Options[bone][labels] = nil 678 | end 679 | end 680 | else 681 | Bones.Options[bone] = nil 682 | end 683 | end 684 | else 685 | if labels then 686 | if type(labels) == 'table' then 687 | for _, v in pairs(labels) do 688 | if Bones.Options[bones] then 689 | Bones.Options[bones][v] = nil 690 | end 691 | end 692 | elseif type(labels) == 'string' then 693 | if Bones.Options[bones] then 694 | Bones.Options[bones][labels] = nil 695 | end 696 | end 697 | else 698 | Bones.Options[bones] = nil 699 | end 700 | end 701 | end 702 | exports("RemoveTargetBone", RemoveTargetBone) 703 | 704 | ---@param entities table | number 705 | ---@param parameters table 706 | local function AddTargetEntity(entities, parameters) 707 | local distance, options = parameters.distance or Config.MaxDistance, parameters.options 708 | if type(entities) == 'table' then 709 | for _, entity in pairs(entities) do 710 | if NetworkGetEntityIsNetworked(entity) then entity = NetworkGetNetworkIdFromEntity(entity) end -- Allow non-networked entities to be targeted 711 | if not Entities[entity] then Entities[entity] = {} end 712 | SetOptions(Entities[entity], distance, options) 713 | end 714 | elseif type(entities) == 'number' then 715 | if NetworkGetEntityIsNetworked(entities) then entities = NetworkGetNetworkIdFromEntity(entities) end -- Allow non-networked entities to be targeted 716 | if not Entities[entities] then Entities[entities] = {} end 717 | SetOptions(Entities[entities], distance, options) 718 | end 719 | end 720 | exports('AddTargetEntity', AddTargetEntity) 721 | 722 | ---@param entities table | number 723 | ---@param labels table | string 724 | local function RemoveTargetEntity(entities, labels) 725 | if type(entities) == 'table' then 726 | for _, entity in pairs(entities) do 727 | if NetworkGetEntityIsNetworked(entity) then entity = NetworkGetNetworkIdFromEntity(entity) end -- Allow non-networked entities to be targeted 728 | if labels then 729 | if type(labels) == 'table' then 730 | for _, v in pairs(labels) do 731 | if Entities[entity] then 732 | Entities[entity][v] = nil 733 | end 734 | end 735 | elseif type(labels) == 'string' then 736 | if Entities[entity] then 737 | Entities[entity][labels] = nil 738 | end 739 | end 740 | else 741 | Entities[entity] = nil 742 | end 743 | end 744 | elseif type(entities) == 'number' then 745 | if NetworkGetEntityIsNetworked(entities) then entities = NetworkGetNetworkIdFromEntity(entities) end -- Allow non-networked entities to be targeted 746 | if labels then 747 | if type(labels) == 'table' then 748 | for _, v in pairs(labels) do 749 | if Entities[entities] then 750 | Entities[entities][v] = nil 751 | end 752 | end 753 | elseif type(labels) == 'string' then 754 | if Entities[entities] then 755 | Entities[entities][labels] = nil 756 | end 757 | end 758 | else 759 | Entities[entities] = nil 760 | end 761 | end 762 | end 763 | exports('RemoveTargetEntity', RemoveTargetEntity) 764 | 765 | ---@param models table | string | number 766 | ---@param parameters table 767 | local function AddTargetModel(models, parameters) 768 | local distance, options = parameters.distance or Config.MaxDistance, parameters.options 769 | if type(models) == 'table' then 770 | for _, model in pairs(models) do 771 | if type(model) == 'string' then model = joaat(model) end 772 | if not Models[model] then Models[model] = {} end 773 | SetOptions(Models[model], distance, options) 774 | end 775 | else 776 | if type(models) == 'string' then models = joaat(models) end 777 | if not Models[models] then Models[models] = {} end 778 | SetOptions(Models[models], distance, options) 779 | end 780 | end 781 | exports('AddTargetModel', AddTargetModel) 782 | 783 | ---@param models table | string | number 784 | ---@param labels table | string 785 | local function RemoveTargetModel(models, labels) 786 | if type(models) == 'table' then 787 | for _, model in pairs(models) do 788 | if type(model) == 'string' then model = joaat(model) end 789 | if labels then 790 | if type(labels) == 'table' then 791 | for k, v in pairs(labels) do 792 | if Models[model] then 793 | Models[model][v] = nil 794 | end 795 | end 796 | elseif type(labels) == 'string' then 797 | if Models[model] then 798 | Models[model][labels] = nil 799 | end 800 | end 801 | else 802 | Models[model] = nil 803 | end 804 | end 805 | else 806 | if type(models) == 'string' then models = joaat(models) end 807 | if labels then 808 | if type(labels) == 'table' then 809 | for _, v in pairs(labels) do 810 | if Models[models] then 811 | Models[models][v] = nil 812 | end 813 | end 814 | elseif type(labels) == 'string' then 815 | if Models[models] then 816 | Models[models][labels] = nil 817 | end 818 | end 819 | else 820 | Models[models] = nil 821 | end 822 | end 823 | end 824 | exports('RemoveTargetModel', RemoveTargetModel) 825 | 826 | ---@param type number 827 | ---@param parameters table 828 | local function AddType(type, parameters) 829 | local distance, options = parameters.distance or Config.MaxDistance, parameters.options 830 | SetOptions(Types[type], distance, options) 831 | end 832 | 833 | ---@param parameters table 834 | local function AddPed(parameters) AddType(1, parameters) end 835 | exports('Ped', AddPed) 836 | 837 | ---@param parameters table 838 | local function AddVehicle(parameters) AddType(2, parameters) end 839 | exports('Vehicle', AddVehicle) 840 | 841 | ---@param parameters table 842 | local function AddObject(parameters) AddType(3, parameters) end 843 | exports('Object', AddObject) 844 | 845 | ---@param parameters table 846 | local function AddPlayer(parameters) 847 | local distance, options = parameters.distance or Config.MaxDistance, parameters.options 848 | SetOptions(Players, distance, options) 849 | end 850 | exports('Player', AddPlayer) 851 | 852 | ---@param typ number 853 | ---@param labels table | string 854 | local function RemoveType(typ, labels) 855 | if labels then 856 | if type(labels) == 'table' then 857 | for _, v in pairs(labels) do 858 | Types[typ][v] = nil 859 | end 860 | elseif type(labels) == 'string' then 861 | Types[typ][labels] = nil 862 | end 863 | else 864 | Types[typ] = {} 865 | end 866 | end 867 | 868 | ---@param labels table | string 869 | local function RemovePed(labels) RemoveType(1, labels) end 870 | exports('RemovePed', RemovePed) 871 | 872 | ---@param labels table | string 873 | local function RemoveVehicle(labels) RemoveType(2, labels) end 874 | exports('RemoveVehicle', RemoveVehicle) 875 | 876 | ---@param labels table | string 877 | local function RemoveObject(labels) RemoveType(3, labels) end 878 | exports('RemoveObject', RemoveObject) 879 | 880 | ---@param labels table | string 881 | local function RemovePlayer(labels) 882 | if labels then 883 | if type(labels) == 'table' then 884 | for _, v in pairs(labels) do 885 | Players[v] = nil 886 | end 887 | elseif type(labels) == 'string' then 888 | Players[labels] = nil 889 | end 890 | else 891 | Players = {} 892 | end 893 | end 894 | exports('RemovePlayer', RemovePlayer) 895 | 896 | -- Misc. Exports 897 | 898 | local function IsTargetActive() return targetActive end 899 | exports("IsTargetActive", IsTargetActive) 900 | 901 | local function IsTargetSuccess() return success end 902 | exports("IsTargetSuccess", IsTargetSuccess) 903 | 904 | local function GetType(type, label) return Types[type][label] end 905 | exports("GetType", GetType) 906 | 907 | local function GetZone(name) return Zones[name] end 908 | exports("GetZone", GetZone) 909 | 910 | local function GetTargetBone(bone, label) return Bones.Options[bone][label] end 911 | exports("GetTargetBone", GetTargetBone) 912 | 913 | local function GetTargetEntity(entity, label) return Entities[entity][label] end 914 | exports("GetTargetEntity", GetTargetEntity) 915 | 916 | local function GetTargetModel(model, label) return Models[model][label] end 917 | exports("GetTargetModel", GetTargetModel) 918 | 919 | local function GetPed(label) return Types[1][label] end 920 | exports("GetPed", GetPed) 921 | 922 | local function GetVehicle(label) return Types[2][label] end 923 | exports("GetVehicle", GetVehicle) 924 | 925 | local function GetObject(label) return Types[3][label] end 926 | exports("GetObject", GetObject) 927 | 928 | local function GetPlayer(label) return Players[label] end 929 | exports("GetPlayer", GetPlayer) 930 | 931 | local function UpdateType(type, label, data) Types[type][label] = data end 932 | exports("UpdateType", UpdateType) 933 | 934 | local function UpdateZoneOptions (name, targetoptions) 935 | targetoptions.distance = targetoptions.distance or Config.MaxDistance 936 | Zones[name].targetoptions = targetoptions 937 | end 938 | exports("UpdateZoneOptions", UpdateZoneOptions) -- (name, targetoptions) end) 939 | 940 | local function UpdateTargetBone(bone, label, data) Bones.Options[bone][label] = data end 941 | exports("UpdateTargetBone", UpdateTargetBone) 942 | 943 | local function UpdateTargetEntity(entity, label, data) Entities[entity][label] = data end 944 | exports("UpdateTargetEntity", UpdateTargetEntity) 945 | 946 | local function UpdateTargetModel(model, label, data) Models[model][label] = data end 947 | exports("UpdateTargetModel", UpdateTargetModel) 948 | 949 | local function UpdatePed(label, data) Types[1][label] = data end 950 | exports("UpdatePed", UpdatePed) 951 | 952 | local function UpdateVehicle(label, data) Types[2][label] = data end 953 | exports("UpdateVehicle", UpdateVehicle) 954 | 955 | local function UpdateObject(label, data) Types[3][label] = data end 956 | exports("UpdateObject", UpdateObject) 957 | 958 | local function UpdatePlayer(label, data) Players[label] = data end 959 | exports("UpdatePlayer", UpdatePlayer) 960 | 961 | local function AllowTargeting(bool) 962 | allowTarget = bool 963 | 964 | if allowTarget then return end 965 | 966 | DisableTarget(true) 967 | end 968 | exports("AllowTargeting", AllowTargeting) 969 | 970 | -- Debug Option 971 | 972 | if Config.Debug then Load('debug') end 973 | 974 | -- qb-target interoperability 975 | 976 | local qb_targetExports = { 977 | ["RaycastCamera"] = RaycastCamera, 978 | ["DisableNUI"] = DisableNUI, 979 | ["LeftTarget"] = LeaveTarget, 980 | ["DisableTarget"] = DisableTarget, 981 | ["DrawOutlineEntity"] = DrawOutlineEntity, 982 | ["CheckEntity"] = CheckEntity, 983 | ["CheckBones"] = CheckBones, 984 | ["AddCircleZone"] = AddCircleZone, 985 | ["AddBoxZone"] = AddBoxZone, 986 | ["AddPolyZone"] = AddPolyZone, 987 | ["AddComboZone"] = AddComboZone, 988 | ["AddEntityZone"] = AddEntityZone, 989 | ["RemoveZone"] = RemoveZone, 990 | ["AddTargetBone"] = AddTargetBone, 991 | ["RemoveTargetBone"] = RemoveTargetBone, 992 | ["AddTargetEntity"] = AddTargetEntity, 993 | ["RemoveTargetEntity"] = RemoveTargetEntity, 994 | ["AddTargetModel"] = AddTargetModel, 995 | ["RemoveTargetModel"] = RemoveTargetModel, 996 | ["AddGlobalPed"] = AddPed, 997 | ["AddGlobalVehicle"] = AddVehicle, 998 | ["AddGlobalObject"] = AddObject, 999 | ["AddGlobalPlayer"] = AddPlayer, 1000 | ["RemoveGlobalPed"] = RemovePed, 1001 | ["RemoveGlobalVehicle"] = RemoveVehicle, 1002 | ["RemoveGlobalObject"] = RemoveObject, 1003 | ["RemoveGlobalPlayer"] = RemovePlayer, 1004 | ["IsTargetActive"] = IsTargetActive, 1005 | ["IsTargetSuccess"] = IsTargetSuccess, 1006 | ["GetGlobalTypeData"] = GetType, 1007 | ["GetZoneData"] = GetZone, 1008 | ["GetTargetBoneData"] = GetTargetBone, 1009 | ["GetTargetEntityData"] = GetTargetEntity, 1010 | ["GetTargetModelData"] = GetTargetModel, 1011 | ["GetGlobalPedData"] = GetPed, 1012 | ["GetGlobalVehicleData"] = GetVehicle, 1013 | ["GetGlobalObjectData"] = GetObject, 1014 | ["GetGlobalPlayerData"] = GetPlayer, 1015 | ["UpdateGlobalTypeData"] = UpdateType, 1016 | ["UpdateZoneData"] = UpdateZoneOptions, 1017 | ["UpdateTargetBoneData"] = UpdateTargetBone, 1018 | ["UpdateTargetEntityData"] = UpdateTargetEntity, 1019 | ["UpdateTargetModelData"] = UpdateTargetModel, 1020 | ["UpdateGlobalPedData"] = UpdatePed, 1021 | ["UpdateGlobalVehicleData"] = UpdateVehicle, 1022 | ["UpdateGlobalObjectData"] = UpdateObject, 1023 | ["UpdateGlobalPlayerData"] = UpdatePlayer, 1024 | ["AllowTargeting"] = AllowTargeting 1025 | } 1026 | 1027 | for exportName, func in pairs(qb_targetExports) do 1028 | AddEventHandler(('__cfx_export_qb-target_%s'):format(exportName), function(setCB) 1029 | setCB(func) 1030 | end) 1031 | end -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 3, 29 June 2007 4 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for 12 | software and other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | the GNU General Public License is intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. We, the Free Software Foundation, use the 19 | GNU General Public License for most of our software; it applies also to 20 | any other work released this way by its authors. You can apply it to 21 | your programs, too. 22 | 23 | When we speak of free software, we are referring to freedom, not 24 | price. Our General Public Licenses are designed to make sure that you 25 | have the freedom to distribute copies of free software (and charge for 26 | them if you wish), that you receive source code or can get it if you 27 | want it, that you can change the software or use pieces of it in new 28 | free programs, and that you know you can do these things. 29 | 30 | To protect your rights, we need to prevent others from denying you 31 | these rights or asking you to surrender the rights. Therefore, you have 32 | certain responsibilities if you distribute copies of the software, or if 33 | you modify it: responsibilities to respect the freedom of others. 34 | 35 | For example, if you distribute copies of such a program, whether 36 | gratis or for a fee, you must pass on to the recipients the same 37 | freedoms that you received. You must make sure that they, too, receive 38 | or can get the source code. And you must show them these terms so they 39 | know their rights. 40 | 41 | Developers that use the GNU GPL protect your rights with two steps: 42 | (1) assert copyright on the software, and (2) offer you this License 43 | giving you legal permission to copy, distribute and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains 46 | that there is no warranty for this free software. For both users' and 47 | authors' sake, the GPL requires that modified versions be marked as 48 | changed, so that their problems will not be attributed erroneously to 49 | authors of previous versions. 50 | 51 | Some devices are designed to deny users access to install or run 52 | modified versions of the software inside them, although the manufacturer 53 | can do so. This is fundamentally incompatible with the aim of 54 | protecting users' freedom to change the software. The systematic 55 | pattern of such abuse occurs in the area of products for individuals to 56 | use, which is precisely where it is most unacceptable. Therefore, we 57 | have designed this version of the GPL to prohibit the practice for those 58 | products. If such problems arise substantially in other domains, we 59 | stand ready to extend this provision to those domains in future versions 60 | of the GPL, as needed to protect the freedom of users. 61 | 62 | Finally, every program is threatened constantly by software patents. 63 | States should not allow patents to restrict development and use of 64 | software on general-purpose computers, but in those that do, we wish to 65 | avoid the special danger that patents applied to a free program could 66 | make it effectively proprietary. To prevent this, the GPL assures that 67 | patents cannot be used to render the program non-free. 68 | 69 | The precise terms and conditions for copying, distribution and 70 | modification follow. 71 | 72 | TERMS AND CONDITIONS 73 | 74 | 0. Definitions. 75 | 76 | "This License" refers to version 3 of the GNU General Public License. 77 | 78 | "Copyright" also means copyright-like laws that apply to other kinds of 79 | works, such as semiconductor masks. 80 | 81 | "The Program" refers to any copyrightable work licensed under this 82 | License. Each licensee is addressed as "you". "Licensees" and 83 | "recipients" may be individuals or organizations. 84 | 85 | To "modify" a work means to copy from or adapt all or part of the work 86 | in a fashion requiring copyright permission, other than the making of an 87 | exact copy. The resulting work is called a "modified version" of the 88 | earlier work or a work "based on" the earlier work. 89 | 90 | A "covered work" means either the unmodified Program or a work based 91 | on the Program. 92 | 93 | To "propagate" a work means to do anything with it that, without 94 | permission, would make you directly or secondarily liable for 95 | infringement under applicable copyright law, except executing it on a 96 | computer or modifying a private copy. Propagation includes copying, 97 | distribution (with or without modification), making available to the 98 | public, and in some countries other activities as well. 99 | 100 | To "convey" a work means any kind of propagation that enables other 101 | parties to make or receive copies. Mere interaction with a user through 102 | a computer network, with no transfer of a copy, is not conveying. 103 | 104 | An interactive user interface displays "Appropriate Legal Notices" 105 | to the extent that it includes a convenient and prominently visible 106 | feature that (1) displays an appropriate copyright notice, and (2) 107 | tells the user that there is no warranty for the work (except to the 108 | extent that warranties are provided), that licensees may convey the 109 | work under this License, and how to view a copy of this License. If 110 | the interface presents a list of user commands or options, such as a 111 | menu, a prominent item in the list meets this criterion. 112 | 113 | 1. Source Code. 114 | 115 | The "source code" for a work means the preferred form of the work 116 | for making modifications to it. "Object code" means any non-source 117 | form of a work. 118 | 119 | A "Standard Interface" means an interface that either is an official 120 | standard defined by a recognized standards body, or, in the case of 121 | interfaces specified for a particular programming language, one that 122 | is widely used among developers working in that language. 123 | 124 | The "System Libraries" of an executable work include anything, other 125 | than the work as a whole, that (a) is included in the normal form of 126 | packaging a Major Component, but which is not part of that Major 127 | Component, and (b) serves only to enable use of the work with that 128 | Major Component, or to implement a Standard Interface for which an 129 | implementation is available to the public in source code form. A 130 | "Major Component", in this context, means a major essential component 131 | (kernel, window system, and so on) of the specific operating system 132 | (if any) on which the executable work runs, or a compiler used to 133 | produce the work, or an object code interpreter used to run it. 134 | 135 | The "Corresponding Source" for a work in object code form means all 136 | the source code needed to generate, install, and (for an executable 137 | work) run the object code and to modify the work, including scripts to 138 | control those activities. However, it does not include the work's 139 | System Libraries, or general-purpose tools or generally available free 140 | programs which are used unmodified in performing those activities but 141 | which are not part of the work. For example, Corresponding Source 142 | includes interface definition files associated with source files for 143 | the work, and the source code for shared libraries and dynamically 144 | linked subprograms that the work is specifically designed to require, 145 | such as by intimate data communication or control flow between those 146 | subprograms and other parts of the work. 147 | 148 | The Corresponding Source need not include anything that users 149 | can regenerate automatically from other parts of the Corresponding 150 | Source. 151 | 152 | The Corresponding Source for a work in source code form is that 153 | same work. 154 | 155 | 2. Basic Permissions. 156 | 157 | All rights granted under this License are granted for the term of 158 | copyright on the Program, and are irrevocable provided the stated 159 | conditions are met. This License explicitly affirms your unlimited 160 | permission to run the unmodified Program. The output from running a 161 | covered work is covered by this License only if the output, given its 162 | content, constitutes a covered work. This License acknowledges your 163 | rights of fair use or other equivalent, as provided by copyright law. 164 | 165 | You may make, run and propagate covered works that you do not 166 | convey, without conditions so long as your license otherwise remains 167 | in force. You may convey covered works to others for the sole purpose 168 | of having them make modifications exclusively for you, or provide you 169 | with facilities for running those works, provided that you comply with 170 | the terms of this License in conveying all material for which you do 171 | not control copyright. Those thus making or running the covered works 172 | for you must do so exclusively on your behalf, under your direction 173 | and control, on terms that prohibit them from making any copies of 174 | your copyrighted material outside their relationship with you. 175 | 176 | Conveying under any other circumstances is permitted solely under 177 | the conditions stated below. Sublicensing is not allowed; section 10 178 | makes it unnecessary. 179 | 180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 181 | 182 | No covered work shall be deemed part of an effective technological 183 | measure under any applicable law fulfilling obligations under article 184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 185 | similar laws prohibiting or restricting circumvention of such 186 | measures. 187 | 188 | When you convey a covered work, you waive any legal power to forbid 189 | circumvention of technological measures to the extent such circumvention 190 | is effected by exercising rights under this License with respect to 191 | the covered work, and you disclaim any intention to limit operation or 192 | modification of the work as a means of enforcing, against the work's 193 | users, your or third parties' legal rights to forbid circumvention of 194 | technological measures. 195 | 196 | 4. Conveying Verbatim Copies. 197 | 198 | You may convey verbatim copies of the Program's source code as you 199 | receive it, in any medium, provided that you conspicuously and 200 | appropriately publish on each copy an appropriate copyright notice; 201 | keep intact all notices stating that this License and any 202 | non-permissive terms added in accord with section 7 apply to the code; 203 | keep intact all notices of the absence of any warranty; and give all 204 | recipients a copy of this License along with the Program. 205 | 206 | You may charge any price or no price for each copy that you convey, 207 | and you may offer support or warranty protection for a fee. 208 | 209 | 5. Conveying Modified Source Versions. 210 | 211 | You may convey a work based on the Program, or the modifications to 212 | produce it from the Program, in the form of source code under the 213 | terms of section 4, provided that you also meet all of these conditions: 214 | 215 | a) The work must carry prominent notices stating that you modified 216 | it, and giving a relevant date. 217 | 218 | b) The work must carry prominent notices stating that it is 219 | released under this License and any conditions added under section 220 | 7. This requirement modifies the requirement in section 4 to 221 | "keep intact all notices". 222 | 223 | c) You must license the entire work, as a whole, under this 224 | License to anyone who comes into possession of a copy. This 225 | License will therefore apply, along with any applicable section 7 226 | additional terms, to the whole of the work, and all its parts, 227 | regardless of how they are packaged. This License gives no 228 | permission to license the work in any other way, but it does not 229 | invalidate such permission if you have separately received it. 230 | 231 | d) If the work has interactive user interfaces, each must display 232 | Appropriate Legal Notices; however, if the Program has interactive 233 | interfaces that do not display Appropriate Legal Notices, your 234 | work need not make them do so. 235 | 236 | A compilation of a covered work with other separate and independent 237 | works, which are not by their nature extensions of the covered work, 238 | and which are not combined with it such as to form a larger program, 239 | in or on a volume of a storage or distribution medium, is called an 240 | "aggregate" if the compilation and its resulting copyright are not 241 | used to limit the access or legal rights of the compilation's users 242 | beyond what the individual works permit. Inclusion of a covered work 243 | in an aggregate does not cause this License to apply to the other 244 | parts of the aggregate. 245 | 246 | 6. Conveying Non-Source Forms. 247 | 248 | You may convey a covered work in object code form under the terms 249 | of sections 4 and 5, provided that you also convey the 250 | machine-readable Corresponding Source under the terms of this License, 251 | in one of these ways: 252 | 253 | a) Convey the object code in, or embodied in, a physical product 254 | (including a physical distribution medium), accompanied by the 255 | Corresponding Source fixed on a durable physical medium 256 | customarily used for software interchange. 257 | 258 | b) Convey the object code in, or embodied in, a physical product 259 | (including a physical distribution medium), accompanied by a 260 | written offer, valid for at least three years and valid for as 261 | long as you offer spare parts or customer support for that product 262 | model, to give anyone who possesses the object code either (1) a 263 | copy of the Corresponding Source for all the software in the 264 | product that is covered by this License, on a durable physical 265 | medium customarily used for software interchange, for a price no 266 | more than your reasonable cost of physically performing this 267 | conveying of source, or (2) access to copy the 268 | Corresponding Source from a network server at no charge. 269 | 270 | c) Convey individual copies of the object code with a copy of the 271 | written offer to provide the Corresponding Source. This 272 | alternative is allowed only occasionally and noncommercially, and 273 | only if you received the object code with such an offer, in accord 274 | with subsection 6b. 275 | 276 | d) Convey the object code by offering access from a designated 277 | place (gratis or for a charge), and offer equivalent access to the 278 | Corresponding Source in the same way through the same place at no 279 | further charge. You need not require recipients to copy the 280 | Corresponding Source along with the object code. If the place to 281 | copy the object code is a network server, the Corresponding Source 282 | may be on a different server (operated by you or a third party) 283 | that supports equivalent copying facilities, provided you maintain 284 | clear directions next to the object code saying where to find the 285 | Corresponding Source. Regardless of what server hosts the 286 | Corresponding Source, you remain obligated to ensure that it is 287 | available for as long as needed to satisfy these requirements. 288 | 289 | e) Convey the object code using peer-to-peer transmission, provided 290 | you inform other peers where the object code and Corresponding 291 | Source of the work are being offered to the general public at no 292 | charge under subsection 6d. 293 | 294 | A separable portion of the object code, whose source code is excluded 295 | from the Corresponding Source as a System Library, need not be 296 | included in conveying the object code work. 297 | 298 | A "User Product" is either (1) a "consumer product", which means any 299 | tangible personal property which is normally used for personal, family, 300 | or household purposes, or (2) anything designed or sold for incorporation 301 | into a dwelling. In determining whether a product is a consumer product, 302 | doubtful cases shall be resolved in favor of coverage. For a particular 303 | product received by a particular user, "normally used" refers to a 304 | typical or common use of that class of product, regardless of the status 305 | of the particular user or of the way in which the particular user 306 | actually uses, or expects or is expected to use, the product. A product 307 | is a consumer product regardless of whether the product has substantial 308 | commercial, industrial or non-consumer uses, unless such uses represent 309 | the only significant mode of use of the product. 310 | 311 | "Installation Information" for a User Product means any methods, 312 | procedures, authorization keys, or other information required to install 313 | and execute modified versions of a covered work in that User Product from 314 | a modified version of its Corresponding Source. The information must 315 | suffice to ensure that the continued functioning of the modified object 316 | code is in no case prevented or interfered with solely because 317 | modification has been made. 318 | 319 | If you convey an object code work under this section in, or with, or 320 | specifically for use in, a User Product, and the conveying occurs as 321 | part of a transaction in which the right of possession and use of the 322 | User Product is transferred to the recipient in perpetuity or for a 323 | fixed term (regardless of how the transaction is characterized), the 324 | Corresponding Source conveyed under this section must be accompanied 325 | by the Installation Information. But this requirement does not apply 326 | if neither you nor any third party retains the ability to install 327 | modified object code on the User Product (for example, the work has 328 | been installed in ROM). 329 | 330 | The requirement to provide Installation Information does not include a 331 | requirement to continue to provide support service, warranty, or updates 332 | for a work that has been modified or installed by the recipient, or for 333 | the User Product in which it has been modified or installed. Access to a 334 | network may be denied when the modification itself materially and 335 | adversely affects the operation of the network or violates the rules and 336 | protocols for communication across the network. 337 | 338 | Corresponding Source conveyed, and Installation Information provided, 339 | in accord with this section must be in a format that is publicly 340 | documented (and with an implementation available to the public in 341 | source code form), and must require no special password or key for 342 | unpacking, reading or copying. 343 | 344 | 7. Additional Terms. 345 | 346 | "Additional permissions" are terms that supplement the terms of this 347 | License by making exceptions from one or more of its conditions. 348 | Additional permissions that are applicable to the entire Program shall 349 | be treated as though they were included in this License, to the extent 350 | that they are valid under applicable law. If additional permissions 351 | apply only to part of the Program, that part may be used separately 352 | under those permissions, but the entire Program remains governed by 353 | this License without regard to the additional permissions. 354 | 355 | When you convey a copy of a covered work, you may at your option 356 | remove any additional permissions from that copy, or from any part of 357 | it. (Additional permissions may be written to require their own 358 | removal in certain cases when you modify the work.) You may place 359 | additional permissions on material, added by you to a covered work, 360 | for which you have or can give appropriate copyright permission. 361 | 362 | Notwithstanding any other provision of this License, for material you 363 | add to a covered work, you may (if authorized by the copyright holders of 364 | that material) supplement the terms of this License with terms: 365 | 366 | a) Disclaiming warranty or limiting liability differently from the 367 | terms of sections 15 and 16 of this License; or 368 | 369 | b) Requiring preservation of specified reasonable legal notices or 370 | author attributions in that material or in the Appropriate Legal 371 | Notices displayed by works containing it; or 372 | 373 | c) Prohibiting misrepresentation of the origin of that material, or 374 | requiring that modified versions of such material be marked in 375 | reasonable ways as different from the original version; or 376 | 377 | d) Limiting the use for publicity purposes of names of licensors or 378 | authors of the material; or 379 | 380 | e) Declining to grant rights under trademark law for use of some 381 | trade names, trademarks, or service marks; or 382 | 383 | f) Requiring indemnification of licensors and authors of that 384 | material by anyone who conveys the material (or modified versions of 385 | it) with contractual assumptions of liability to the recipient, for 386 | any liability that these contractual assumptions directly impose on 387 | those licensors and authors. 388 | 389 | All other non-permissive additional terms are considered "further 390 | restrictions" within the meaning of section 10. If the Program as you 391 | received it, or any part of it, contains a notice stating that it is 392 | governed by this License along with a term that is a further 393 | restriction, you may remove that term. If a license document contains 394 | a further restriction but permits relicensing or conveying under this 395 | License, you may add to a covered work material governed by the terms 396 | of that license document, provided that the further restriction does 397 | not survive such relicensing or conveying. 398 | 399 | If you add terms to a covered work in accord with this section, you 400 | must place, in the relevant source files, a statement of the 401 | additional terms that apply to those files, or a notice indicating 402 | where to find the applicable terms. 403 | 404 | Additional terms, permissive or non-permissive, may be stated in the 405 | form of a separately written license, or stated as exceptions; 406 | the above requirements apply either way. 407 | 408 | 8. Termination. 409 | 410 | You may not propagate or modify a covered work except as expressly 411 | provided under this License. Any attempt otherwise to propagate or 412 | modify it is void, and will automatically terminate your rights under 413 | this License (including any patent licenses granted under the third 414 | paragraph of section 11). 415 | 416 | However, if you cease all violation of this License, then your 417 | license from a particular copyright holder is reinstated (a) 418 | provisionally, unless and until the copyright holder explicitly and 419 | finally terminates your license, and (b) permanently, if the copyright 420 | holder fails to notify you of the violation by some reasonable means 421 | prior to 60 days after the cessation. 422 | 423 | Moreover, your license from a particular copyright holder is 424 | reinstated permanently if the copyright holder notifies you of the 425 | violation by some reasonable means, this is the first time you have 426 | received notice of violation of this License (for any work) from that 427 | copyright holder, and you cure the violation prior to 30 days after 428 | your receipt of the notice. 429 | 430 | Termination of your rights under this section does not terminate the 431 | licenses of parties who have received copies or rights from you under 432 | this License. If your rights have been terminated and not permanently 433 | reinstated, you do not qualify to receive new licenses for the same 434 | material under section 10. 435 | 436 | 9. Acceptance Not Required for Having Copies. 437 | 438 | You are not required to accept this License in order to receive or 439 | run a copy of the Program. Ancillary propagation of a covered work 440 | occurring solely as a consequence of using peer-to-peer transmission 441 | to receive a copy likewise does not require acceptance. However, 442 | nothing other than this License grants you permission to propagate or 443 | modify any covered work. These actions infringe copyright if you do 444 | not accept this License. Therefore, by modifying or propagating a 445 | covered work, you indicate your acceptance of this License to do so. 446 | 447 | 10. Automatic Licensing of Downstream Recipients. 448 | 449 | Each time you convey a covered work, the recipient automatically 450 | receives a license from the original licensors, to run, modify and 451 | propagate that work, subject to this License. You are not responsible 452 | for enforcing compliance by third parties with this License. 453 | 454 | An "entity transaction" is a transaction transferring control of an 455 | organization, or substantially all assets of one, or subdividing an 456 | organization, or merging organizations. If propagation of a covered 457 | work results from an entity transaction, each party to that 458 | transaction who receives a copy of the work also receives whatever 459 | licenses to the work the party's predecessor in interest had or could 460 | give under the previous paragraph, plus a right to possession of the 461 | Corresponding Source of the work from the predecessor in interest, if 462 | the predecessor has it or can get it with reasonable efforts. 463 | 464 | You may not impose any further restrictions on the exercise of the 465 | rights granted or affirmed under this License. For example, you may 466 | not impose a license fee, royalty, or other charge for exercise of 467 | rights granted under this License, and you may not initiate litigation 468 | (including a cross-claim or counterclaim in a lawsuit) alleging that 469 | any patent claim is infringed by making, using, selling, offering for 470 | sale, or importing the Program or any portion of it. 471 | 472 | 11. Patents. 473 | 474 | A "contributor" is a copyright holder who authorizes use under this 475 | License of the Program or a work on which the Program is based. The 476 | work thus licensed is called the contributor's "contributor version". 477 | 478 | A contributor's "essential patent claims" are all patent claims 479 | owned or controlled by the contributor, whether already acquired or 480 | hereafter acquired, that would be infringed by some manner, permitted 481 | by this License, of making, using, or selling its contributor version, 482 | but do not include claims that would be infringed only as a 483 | consequence of further modification of the contributor version. For 484 | purposes of this definition, "control" includes the right to grant 485 | patent sublicenses in a manner consistent with the requirements of 486 | this License. 487 | 488 | Each contributor grants you a non-exclusive, worldwide, royalty-free 489 | patent license under the contributor's essential patent claims, to 490 | make, use, sell, offer for sale, import and otherwise run, modify and 491 | propagate the contents of its contributor version. 492 | 493 | In the following three paragraphs, a "patent license" is any express 494 | agreement or commitment, however denominated, not to enforce a patent 495 | (such as an express permission to practice a patent or covenant not to 496 | sue for patent infringement). To "grant" such a patent license to a 497 | party means to make such an agreement or commitment not to enforce a 498 | patent against the party. 499 | 500 | If you convey a covered work, knowingly relying on a patent license, 501 | and the Corresponding Source of the work is not available for anyone 502 | to copy, free of charge and under the terms of this License, through a 503 | publicly available network server or other readily accessible means, 504 | then you must either (1) cause the Corresponding Source to be so 505 | available, or (2) arrange to deprive yourself of the benefit of the 506 | patent license for this particular work, or (3) arrange, in a manner 507 | consistent with the requirements of this License, to extend the patent 508 | license to downstream recipients. "Knowingly relying" means you have 509 | actual knowledge that, but for the patent license, your conveying the 510 | covered work in a country, or your recipient's use of the covered work 511 | in a country, would infringe one or more identifiable patents in that 512 | country that you have reason to believe are valid. 513 | 514 | If, pursuant to or in connection with a single transaction or 515 | arrangement, you convey, or propagate by procuring conveyance of, a 516 | covered work, and grant a patent license to some of the parties 517 | receiving the covered work authorizing them to use, propagate, modify 518 | or convey a specific copy of the covered work, then the patent license 519 | you grant is automatically extended to all recipients of the covered 520 | work and works based on it. 521 | 522 | A patent license is "discriminatory" if it does not include within 523 | the scope of its coverage, prohibits the exercise of, or is 524 | conditioned on the non-exercise of one or more of the rights that are 525 | specifically granted under this License. You may not convey a covered 526 | work if you are a party to an arrangement with a third party that is 527 | in the business of distributing software, under which you make payment 528 | to the third party based on the extent of your activity of conveying 529 | the work, and under which the third party grants, to any of the 530 | parties who would receive the covered work from you, a discriminatory 531 | patent license (a) in connection with copies of the covered work 532 | conveyed by you (or copies made from those copies), or (b) primarily 533 | for and in connection with specific products or compilations that 534 | contain the covered work, unless you entered into that arrangement, 535 | or that patent license was granted, prior to 28 March 2007. 536 | 537 | Nothing in this License shall be construed as excluding or limiting 538 | any implied license or other defenses to infringement that may 539 | otherwise be available to you under applicable patent law. 540 | 541 | 12. No Surrender of Others' Freedom. 542 | 543 | If conditions are imposed on you (whether by court order, agreement or 544 | otherwise) that contradict the conditions of this License, they do not 545 | excuse you from the conditions of this License. If you cannot convey a 546 | covered work so as to satisfy simultaneously your obligations under this 547 | License and any other pertinent obligations, then as a consequence you may 548 | not convey it at all. For example, if you agree to terms that obligate you 549 | to collect a royalty for further conveying from those to whom you convey 550 | the Program, the only way you could satisfy both those terms and this 551 | License would be to refrain entirely from conveying the Program. 552 | 553 | 13. Use with the GNU Affero General Public License. 554 | 555 | Notwithstanding any other provision of this License, you have 556 | permission to link or combine any covered work with a work licensed 557 | under version 3 of the GNU Affero General Public License into a single 558 | combined work, and to convey the resulting work. The terms of this 559 | License will continue to apply to the part which is the covered work, 560 | but the special requirements of the GNU Affero General Public License, 561 | section 13, concerning interaction through a network will apply to the 562 | combination as such. 563 | 564 | 14. Revised Versions of this License. 565 | 566 | The Free Software Foundation may publish revised and/or new versions of 567 | the GNU General Public License from time to time. Such new versions will 568 | be similar in spirit to the present version, but may differ in detail to 569 | address new problems or concerns. 570 | 571 | Each version is given a distinguishing version number. If the 572 | Program specifies that a certain numbered version of the GNU General 573 | Public License "or any later version" applies to it, you have the 574 | option of following the terms and conditions either of that numbered 575 | version or of any later version published by the Free Software 576 | Foundation. If the Program does not specify a version number of the 577 | GNU General Public License, you may choose any version ever published 578 | by the Free Software Foundation. 579 | 580 | If the Program specifies that a proxy can decide which future 581 | versions of the GNU General Public License can be used, that proxy's 582 | public statement of acceptance of a version permanently authorizes you 583 | to choose that version for the Program. 584 | 585 | Later license versions may give you additional or different 586 | permissions. However, no additional obligations are imposed on any 587 | author or copyright holder as a result of your choosing to follow a 588 | later version. 589 | 590 | 15. Disclaimer of Warranty. 591 | 592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 600 | 601 | 16. Limitation of Liability. 602 | 603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 611 | SUCH DAMAGES. 612 | 613 | 17. Interpretation of Sections 15 and 16. 614 | 615 | If the disclaimer of warranty and limitation of liability provided 616 | above cannot be given local legal effect according to their terms, 617 | reviewing courts shall apply local law that most closely approximates 618 | an absolute waiver of all civil liability in connection with the 619 | Program, unless a warranty or assumption of liability accompanies a 620 | copy of the Program in return for a fee. 621 | 622 | END OF TERMS AND CONDITIONS 623 | 624 | How to Apply These Terms to Your New Programs 625 | 626 | If you develop a new program, and you want it to be of the greatest 627 | possible use to the public, the best way to achieve this is to make it 628 | free software which everyone can redistribute and change under these terms. 629 | 630 | To do so, attach the following notices to the program. It is safest 631 | to attach them to the start of each source file to most effectively 632 | state the exclusion of warranty; and each file should have at least 633 | the "copyright" line and a pointer to where the full notice is found. 634 | 635 | 636 | Copyright (C) 637 | 638 | This program is free software: you can redistribute it and/or modify 639 | it under the terms of the GNU General Public License as published by 640 | the Free Software Foundation, either version 3 of the License, or 641 | (at your option) any later version. 642 | 643 | This program is distributed in the hope that it will be useful, 644 | but WITHOUT ANY WARRANTY; without even the implied warranty of 645 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 646 | GNU General Public License for more details. 647 | 648 | You should have received a copy of the GNU General Public License 649 | along with this program. If not, see . 650 | 651 | Also add information on how to contact you by electronic and paper mail. 652 | 653 | If the program does terminal interaction, make it output a short 654 | notice like this when it starts in an interactive mode: 655 | 656 | {project} Copyright (C) {year} {fullname} 657 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 658 | This is free software, and you are welcome to redistribute it 659 | under certain conditions; type `show c' for details. 660 | 661 | The hypothetical commands `show w' and `show c' should show the appropriate 662 | parts of the General Public License. Of course, your program's commands 663 | might be different; for a GUI interface, you would use an "about box". 664 | 665 | You should also get your employer (if you work as a programmer) or school, 666 | if any, to sign a "copyright disclaimer" for the program, if necessary. 667 | For more information on this, and how to apply and follow the GNU GPL, see 668 | . 669 | 670 | The GNU General Public License does not permit incorporating your program 671 | into proprietary programs. If your program is a subroutine library, you 672 | may consider it more useful to permit linking proprietary applications with 673 | the library. If this is what you want to do, use the GNU Lesser General 674 | Public License instead of this License. But first, please read 675 | . 676 | --------------------------------------------------------------------------------