bt-target icon indicating copy to clipboard operation
bt-target copied to clipboard

Wont work with for "" in pairs "".

Open deenz-dev opened this issue 3 years ago • 9 comments

Wont work when entering the server for first time if not using normal coords. Screenshot_1 But if i put the exact coords it works well... does anyone know why?

Wont work if i change Wait time, is not about that, i tried everything.

deenz-dev avatar Feb 26 '21 01:02 deenz-dev

Don't do it in a while true loop, every time you interate your config you're overwriting the polyzone. Try changing the name to "abrirTaquilla"..i, you're also using a table for cooridnates, it needs and x, y z value.

LiamDormon avatar Feb 26 '21 08:02 LiamDormon

The thing is that it works, but not everytime :/

deenz-dev avatar Feb 26 '21 12:02 deenz-dev

The thing is that it works, but not everytime :/

You're doing it completely wrong. You only need to loop once, you can't have two poly zones with the same name and you can't pass the coords as a table.

LiamDormon avatar Feb 26 '21 14:02 LiamDormon

I know, i just tried more things, not only the one on the picture, damnit xd

deenz-dev avatar Feb 26 '21 16:02 deenz-dev

Just keep it as

for k, vin pairs(Config.PoliceStations) do
    for i = 1, #v.Cloakrooms, 1 do
        name = "Cloakrooms"..i
        exports["bt-target"]:AddBoxZone(name, vector3(v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z), 0.5, 2.0 {
            name = name,
            --- etc, etc

LiamDormon avatar Feb 26 '21 17:02 LiamDormon

Ill try, ty so much ma man

deenz-dev avatar Feb 26 '21 17:02 deenz-dev

Nothing, it wont work automatically, u have to restart it to make it work :(

deenz-dev avatar Feb 26 '21 18:02 deenz-dev

Citizen.CreateThread(function()
    Citizen.Wait(2000)
    for shop, _ in pairs(Config.Locations) do
        local position = Config.Locations[shop]["coords"]
        for _, loc in pairs(position) do
            local random = math.random(1, 200)
            exports["bt-target"]:AddBoxZone("Shops"..shop, vector3(loc["x"], loc["y"], loc["z"]), 2.0, 2.0, {
                name="Shops"..shop,
                heading = 92.0,
                debugPoly= false,
                minZ = loc["z"] - 0.5 ,
                maxZ = loc["z"] + 0.5
            }, {
                options = {
                    {
                        event = "xxx",
                        fuck = xx,
                        icon = "xx",
                        label = "xx",
                    },
                },
                job = {"all"},
                distance = 2.0
            })
        end
    end
end)

I had the same issue. You just need to make unique polyzone's for each place you want to add it.

Also you dont need "white true do" or it will fry your PC.

Take my example and change the tables for your need.

xDope7137 avatar Mar 12 '21 14:03 xDope7137

I had the same issue. You just need to make unique polyzone's for each place you want to add it.

Also you dont need "white true do" or it will fry your PC.

Take my example and change the tables for your need.

I wouldn't recommend using box zones in this example otherwise you're just going to have random box zones in places for people to find, I would either combine it with OP's bt-polyzone to create zones which spawn an NPC which can be interacted with (demonstration) or adjust your config specifically for this interaction system so you can have the box zones in specific places like around the till or something like so:

   ["locations"] = {
    [1] = {  
        x = 479.78272705078,
        y = -996.72406005859,
        z = 30.689367294312,
        h = 268.19369506836,
        minZ = 30.52,
        maxZ = 30.87,
        width = 0.4,
        length = 0.8,
        distance = 1.5,
    },

and then adjust your code to look more like this:


    for k, v in pairs(Config["locations"]) do
        name = "Shop"..k
        exports["qb-targetting"]:AddBoxZone(name, vector3(v.x, v.y, v.z), v.width, v.length, {
            name= name,
            heading = v.h,
            debugPoly=false,
            minZ= v.minZ,
            maxZ= v.maxZ
        }, {
            options = {
                {
                    event = "",
                    icon = "fas fa-arrow-alt-circle-right",
                    label = "Shop",
                }
            },

            distance = v.distance,
            job = {"all"}
        })
    end
    ```

LiamDormon avatar Mar 19 '21 17:03 LiamDormon