GithubHelp home page GithubHelp logo

qbcore-framework / qb-target Goto Github PK

View Code? Open in Web Editor NEW
89.0 12.0 240.0 378 KB

A better interaction system for FiveM

License: GNU General Public License v3.0

Lua 88.83% HTML 0.82% CSS 1.12% JavaScript 9.24%

qb-target's Introduction

qb-target

qb-target is a targeting solution that allows interaction with any predefined entity, model, entity type or polyzone. While activated you can easily and safely replace markers and distance checking, instead relying on intuitive design to improve player experiences and optimize interaction.

Credits

  • Lots of credits goes to qtarget for rewriting all of bt-target to make it more optimized and this resource is pretty much a fork of it.

  • Huge credit to bt-target from brentN5 for making the target a thing!

  • Credit to ms-peds for allowing me to use their awesome ped spawner inside the target!

Dependency

Optional Dependency

Information

This repository was originally a direct fork and now it's own repository as it's basically qtarget but with lots of changes to it to make it better, most of the code comes from qtarget as I find their work awesome on this and what they've achieved with it.

You are free to help through Pull Requests and leave as much suggestions or issues, I love some help!

The TEMPLATES.md and EXAMPLES.md are always being improved and new examples can be made on request, just let me know!

Features

  • Maintains compatibility with bt-target while providing improved utility and performance
  • Optimised and improved raycasting function allows interaction with a wider range of entities
  • Add generic options to apply for all players, peds, vehicles, or objects
  • Trigger an event, function or command after clicking an option, with the ability to pass any data through
  • Define distance on a per-option or overall basis when triggering a target option
  • Ability to redefine or remove options and add new options without replacing old ones
  • Update the option list when moving towards or away from a target with variable distances on their options
  • Support for entity bones, with built-in tables for opening vehicle doors
  • Support checking for job, gang, citizenid, items, or specific entities
  • Utilise the canInteract function for advanced checks to show or hide an option based on any trigger
  • Ped spawner to spawn peds and assign target options to them all in one place

qb-target's People

Contributors

archangelza1 avatar berkiebb avatar ghzgarage avatar hamz-project avatar idrisdose avatar izmystic avatar jnccloud avatar kamuikody avatar liamdormon avatar mahanmoulaei avatar menacingmethodz avatar r0adra93 avatar s33g avatar theilleniumstudios avatar tom-osborne avatar usermacieg avatar z3rio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qb-target's Issues

only works for select people on qbcore

only works for like 3 of 10 people. any help is appreciated. no errors client or server side. for the people it works for it is perfect. then the rest cant even get the eye to show up.

when restart bt-target

when restart bt-target
must logout char
and re join
and I also think it should be deleted standalone
unnecessary
Make the project private qbcore

shouldShow = function()

I'm looking for the right use
shouldShow = function()

for example
When using the following traditional code

                for k, v in pairs(Config.Locations["duty"]) do
                    local dist = #(pos - vector3(v.x, v.y, v.z))
                    if dist < 5 then
                        if dist < 1.5 then
                            if onDuty then
                                DrawText3D(v.x, v.y, v.z, "~r~E~w~ - Go Off Duty")
                            else
                                DrawText3D(v.x, v.y, v.z, "~g~E~w~ - Go On Duty")
                            end
                            if IsControlJustReleased(0, 38) then
                                onDuty = not onDuty
                                TriggerServerEvent("QBCore:ToggleDuty")
                                TriggerServerEvent("police:server:UpdateBlips")
                            end
                        elseif dist < 4.5 then
                            DrawText3D(v.x, v.y, v.z, "on/off duty")
                        end  
                    end
                end

If you are logged in
It is when you approach DrawText3D
show Go Off Duty
and If you are out of work, he will give you
Go On Duty

Can this thing be applied through bt-target
Does it show the opposite? with shouldShow ?

Passing Arguments Through qb-target Export

Are you capable of doing as the title suggests? I have a scenario in which I want the player to pick up an order from a specific location, optimally using qb-target to interact with something to obtain it, but this requires parameters to be passed through the server function, as such:

exports['qb-target']:AddTargetModel('a_f_o_salton_01', {
		options = {
			{
                type = "server",
				event = "merty:esyaekle", -- where this event requires two parameters, item and count, to be passed
				icon = "fas fa-burger",
				label = "Pick Up Order",
                item = item,
                count = count,
			},
		},
			distance = 2.5 
	})

Is this possible, and can it be obtained through AddTargetModel, or might it require a different format using qb-target?

Thanks

Just wondering how to trigger all players ?

I have used the example to try target all players I spawn the same ped mp_m_freemode_01 in it works but not for players is there a specific way to do this? Awesome job on this it really has saved my live when using QBCore love it man ๐Ÿ’ฏ

Routing bucket breaks target

Steps :

  • Be in instance 0
  • Create a AddEntityZone
  • Change your instance
  • Change your instance back to 0
  • The zone will be gone.

Weird issue with Box heights.

im trying to change the height at where the box is seen (im using debugPoly) but no matter what i do, i can move the box around changing vector3 but i cant move it up or down. is that known?

Question about template

@BerkieBb
I got this inside my LegacyFuel to add this to my car
image
image

I also have this script inside another files to add the door option on my vehicle but it doesn't show them when i use the target.
image

but sometime, depending on where i click with my target, it show everything
image

finnnace vehicles shop

script:qb-target:nui Uncaught (in promise) ReferenceError: cb is not defined (|qb-target/html/js/app.js:50)

[Suggestion]

make target work with citizen id and job (to have both)

AddComboZone: table index is nil

I have been trying to test the AddCombZone export from the templates.md and keep getting "table index is nil" referencing client.lua line 414

`local function AddComboZone(zones, options, targetoptions)
Zones[name] = ComboZone:Create(zones, options) <
targetoptions.distance = targetoptions.distance or Config.MaxDistance
Zones[name].targetoptions = targetoptions
end

exports("AddComboZone", AddComboZone)`

I believe it is due to Zones[name] as it doesnt enter the table and would expect some kind of a for loop.

Am i doing something wrong or am i missing something?

RemovePed

i have been trying to use RemovePed, this shows no such Export.. but its listed in the Examples..

Peds not spawning

I have added some peds but since the last updates they are not spawning anymore. I dont get errors on my console either.

image

Discord

sorry if this is not the right place to say this but not sure where to go but no discord link I've tried to join just says the invitation is invalid I'm needing support with QB target

unable to use box?

hey so i was testing this out and i see you posted your example in another issue but when i go in game and try it i press alt to bring up the eye and nothing shows here is my config

local Config, Entities, Models, Zones, Bones, Players, Types, Intervals, ConfigFunctions, PlayerData = {}, {}, {}, {}, {}, {}, {}, {}, {}, {}
Types[1], Types[2], Types[3] = {}, {}, {}

Config.ESX = true
Config.QBCore = false
Config.UseGrades = false
Config.LindenInventory = false
Config.MaxDistance = 2 -- Fallback for if you left the distance in the wrong place or forgot it
Config.Debug = false -- Debug mode

Config.VehicleBones = {'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', 'misc_e', 'seat_dside_f', 'seat_pside_f', 'Gun_Nuzzle', 'seat_r'}

Config.BoxZones = {
-- the name of the table and the name parameter can be the same
["OpenCloakroomMenu"] = { -- has to be unique
name = "OpenCloakroomMenu", -- has to be unique
coords = vector3(461.22,-1000.01,31.689), -- example coords
length = 1.0, -- float value
width = 4.0, -- float value
heading = 178.0, -- integer
debugPoly = true, -- boolean, it makes a green box if true
minZ = 30.00, -- float value
maxZ = 31.30, -- float value
options = {
{
type = "function", -- client, server, function (only function in bt-target), action (if you use this you can make the action parameter a function, this will get the entity you're looking at sent to so you can check on that)
event = "esx_policejob:OpenCloakroomMenu",
-- parameters = {}, -- put anything you want inside this to get it through an event get it with: data.parameters, same goes for any other option here, you can get them too
icon = "fas fa-shield-alt", -- an example one, get it from fontawesome.com
label = "Change Clothes",
job = "police" -- or a table if you have more jobs, like this {["police"] = 1, ["ambulance"] = 3}
},
},
distance = 2.0 -- float value in gta units, 1.8 is mostly against an object
},
}

Config.CircleZones = {

}

Config.TargetModels = {

}

Config.TargetEntities = {

}

Config.TargetBones = {

}

Config.EntityZones = {

}

Config.PedOptions = {

}

Config.VehicleOptions = {

}

Config.ObjectOptions = {

}

Config.PlayerOptions = {

}

ConfigFunctions.ItemCount = function(item)
if Config.LindenInventory then return exports['linden_inventory']:CountItems(item)[item] > 0
elseif Config.ESX then
for k, v in pairs(PlayerData.inventory) do
if v.name == item then
return v.count > 0
end
end
elseif Config.QBCore then
for k, v in pairs(PlayerData.items) do
if v.name == item then
return v.amount > 0
end
end
end

return false

end

return Config, Entities, Models, Zones, Bones, Players, Types, Intervals, ConfigFunctions, PlayerData

BUG: cb is not defined app.js:50

So when using target I get this error every time however nothing appears to break other than just the error being thrown. This is on all my boxzone targets.

hello you accept new suggest

hello
thank you
i have new pull for add custem animation for trigger

    type = "client",
    event = "Toggle:Duty",
    icon = "fas fa-sign-in-alt",
    label = "Sign In",
    job = "police",
   animation = "WORLD_HUMAN_COP_IDLES", -- not requrment

and thank you

attempt to index nil value

Screenshot_6
gettin this error after updating this from the old version, even tried it without anything in the config incase i had fucked something up but definetely not anything to do with the config at all

[Feature Request] Don't close menu after MenuControlKey press

I think qb-target was previously setup like this, but now I have to keep the MenuControlKey held down in order to use this.

I personally have my MenuControlKey tied to middle mouse click which makes it a little bit of a dance to select anything.
Is there a way I can get is to stay open after MenuControlKey has been pushed?

attempt to call a nil value?

I just downloaded qb-target just after installing the new qb-core and oxmysql- I start it and get this error?

image

Mouse stuck to center of screen, labels appearing far away from icon

Describe the bug
Two users have reported that when trying to use the third eye, the options, or #target-label-wrapper is far away from the center of the screen with the "eye" icon. This behavior seems to be when users are using higher resolutions than 1080p. Oddly enough, both of these users have an issue with the mouse being glued to the center of the screen. This happens no matter the type of target being used. I have not included steps to reproduce the text being off-centered because it most likely happens to anyone using a super high-resolution monitor (Mac users running Windows via Bootcamp for example).

Video to show both issues: https://streamable.com/9doso5

To Reproduce Stuck Mouse
Steps to reproduce the behavior:

  1. Open Settings in GTA after loading FiveM
  2. Click on Keyboard/Mouse
  3. Change Mouse Input Method to Windows
  4. Save settings
  5. Attempt to target an object
  6. When the icon turns blue, try to select the object's menu option ("Search Garbage" for example)
  7. Mouse should be stuck in the center of the screen

Expected behavior
Expect to be able to use the mouse to select any options available via the target system.

Solution
Enable Raw Input under Mouse Input Method in GTA Settings > Keyboard/Mouse

Screenshots
image

Questions (please complete the following information):

  • When you last updated: Latest version (Updated 36 hours ago)
  • Are you using custom resource? Yes, but not for this resource.
  • Have you renamed qb- to something custom? Negative.

Additional context
The stuck mouse issue appears to be most likely due to the client/user and may not be possible or worth the effort to solve on the resource side. The solution listed above corrects the issue for my end users. For the labels, I will be creating a PR with a tested fix to optimally place it to avoid overlapping text, icons or appearing off-centered as in the video.

[Suggestion]

hello can you make something like an option to reveal the third eye anywhere with clicking alt something like
Config.ShowEye = true -- show third eye even if not inside polyzone

Target peds?

Is there a posibility to utilize the target specific peds? So I can have a more simple solution to hunting triggers and so on?

hello , no issue , just a suggetion to see if it is possible

A qb-target function for the police to cuff people , to save time going to radial menu or using the command /cuff

I have tried it in many ways, but i can't seem to make it work

I tried it like this :

["targetmodel1"] = {
models = {"mp_m_freemode_01","mp_f_freemode_01"},
options = {
{
type = "client",
event = "police:client:CuffPlayerSoft",
icon = "fas fa-hands",
label = "Cuff",
job = "police",
},
},
distance = 2.5,
},
I've tried also with:

type = "command"
event = "cuff"

I haven't tried with command "sc" (soft cuff) but i dont see much diference from the "cuff" command

Am I doing something wrong? Is something missing? What can I do? Is it even possible?

Thanks in advance, and sorry for the bad english!

Dosen't work if qbcore

Hello! Thanks for this awsome script!

I have a litle problem, I have to run the script as standalone for it to work on my qbcore server.
When I set it to qbcore I cant open the eye.

But when running the script as standalone I cant get the ( job = "police", ) to work.

Issue with BoxZones

Hey there, its me again.

I've setup a 24/7 Shop that should be open-able with qb-target.

heres my code in the config file.

	["boxzone3"] = {
        name = "247supermarket2",
        coords = vector3(25.06, -1344.97, -90.83),
        length = 0.45,
        width = 0.35,
        heading = 0.0,
        debugPoly = false,
        minZ = 30.10000,
        maxZ = 29.27834,
        options = {
            {
              type = "client",
              event = "inventory:server:OpenInventory",
              icon = "fas fa-sign-in-alt",
              label = "Open Shop",
            },
        },
        distance = 2.5
    },

i checked with debugPoly and it is in the correct place. around the cash-register but when eyeing it, it doesnt get detected. the example at the police station (from the config you provided) on the other hand works just fine.

Any ideas on this?

Items not saving on dropped

If Item is requied and you start script without the item it doesnt work.
And if you drop the item you can still do the task that requires the item

Can't user target

Hi, today i downloaded this qb-target to test it out. It's working for other players but i can't use it. The problem occured after one restart of a server without even touching the qb-target files. It's not a keybind problem. Do anybody have something to fix it on my side?

Thank you, Coffister.

Do not open

Hello i downloaded this qb-target the problem occured after one restart of a server without even touching the qb-target files. I don't know what it could be. I can't use it after this.

Could you provide an example in the cofig.lua

First off love the resource however since I migrated from the brent one to you one none of it is working i know its probably an option that im not inputting so thought it would be handy to put an example in the config :)

Older vs New version

I'm using an export to qb-target on one specific vehicle.
And also a export on a bone target on all vehicles.

On the latest qb-target update i only get to use one of them... (the one on the bone)
While on the older version i am able to use both.

What am i doing wrong?

Alvast bedankt voor de gedane moeite.

Targeting "Eye" Doesn't even show while in game

Hello, I've download the script "QB-TARGET" and while using it on my server it worked I had no errors, but I know that to use it I have to press a certain keybind, so I assigned it to one of my keys and It still did not work, Do you have any idea why It would not work?.

Hello, thanks for the great effort

Hello, thanks for the great effort
I think the script is theoretically the best out there
but export It has many problems
Use config In entering the information
something new
The problems started when programmers switched from the normal system to your system
See the amount of problems when using
Not everyone can convert to your script
I wish I could reproduce and rewrite the code
For compatibility with all versions
To make it easier for people to move to your script

No Target

Hi,

I have installed this like any other resource but sadly cant seem to get it working. I was using another 3rd Eye but wanted to replace it with this. I removed the old one, and removed the prior QB-target, and replaced it with yours. The resource starts up, but nothing when pressing LALT / trying to use 3rd Eye. I'm sorry, a little new here to QBCore & FiveM in general, if there are better ways I could trouble shoot this problem feel free to let me know! (:

Missing = nill

Getting parsing error at client/main.lua:75 after elseif I assume that value is supposed to be Types[type][labels] = nil in line 74?

Make qb-target work with qb-shops (or something similar)

Hello,

This is not an issue, more so a suggestion/question looking for help.

I am fairly new to using qb-target, but I am wondering if anyone knows how to make it work with qb-shops.What I am trying to do is have specific peds open specific shops where a player can buy those items.

For example: Let's say there is I had this ped: "a_m_m_indian_01" at every Ammunation shop in my server. When people use the eye it would open the Gun Shop associated with what items should be purchasable in my qb-shops config.

The closest I have been able to do is to make the eye open the normal players inventory when using it, but that doesn't show items to purchase. Any help would be much appreciated as I have tried to figure this out for a week now and haven't had any success yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.