No less than then clarify how he ought to enhance reasonably than simply popping out as a jerk.

  1. Why would you test if ESX is nil when you realize for a reality that it’ll at all times be on file load. Simply do like this as a substitute :stuck_out_tongue:
    TriggerEvent('esx:getSharedObject', perform(obj) ESX = obj finish)
  1. Higher for efficiency to solely request the animDict as soon as reasonably than each 5 tick in loadAnimDict(dict).

  2. PlayerPedId() is quicker than GetPlayerPed(-1).

  3. As a substitute of utilizing GetDistanceBetweenCoords use correct vector math, like #(vector1 - vector2) to calculate distance between. A lot sooner than invoking recreation natives.

  4. You don’t want to create a thread inside a occasion handler, because the occasion handler already does that for you.

  5. Why would you want a occasion to set off one thing inside the identical shopper file? a perform would simply be wonderful and what you often use.

Aside from that, the loops appear a bit over-complicated and repetitive, Attempt to preserve all the pieces in a single loop and cache indexes and so forth. I made for you a little bit instance, I’ve not examined this however yeah, you get the purpose. not excellent however extra “compact” and simpler to maintain monitor off. Usually when repeating code you will get misplaced and whenever you uncover a situation you might want to change it on all factors :stuck_out_tongue:

native script_config = {
    {label="test1", teleport = vec(433.4736328125, -982.64184570312, 30.709762573242), teleport_to = vec(437.33459472656, -982.35681152344, 30.698640823364)},

native is_inside = false

perform HelpText(str)

    whereas true do Wait(0)
        for i, merchandise in ipairs(script_config) do

            -- just a few fundamental stuff so we kinda "reverse" the handlers for coords to exit/enter via.
            native deal with = merchandise.teleport
            native handle2 = merchandise.teleport_to
            native str="enter"

            if is_inside then
                deal with = merchandise.teleport_to
                handle2 = merchandise.teleport

            native coords = GetEntityCoords(PlayerPedId())
            native dist = #(coords - deal with)

            if dist < 50 then
                -- draw the marker, lower off by 1 as in any other case we often have a floating circle, dosent have to be the case although :p
                DrawMarker(1, deal with[1], deal with[2], deal with[3]-1,0,0,0,0,0,0,0.8,0.8,0.8, 0, 155, 255,70,0,0,0,0)

                -- if inside the circle considerably then make it so participant can enter
                if dist < 1 then
                    HelpText('Press ~INPUT_CONTEXT~ to '..str..' the '..merchandise.label..'.')

                    if IsControlJustPressed(0, 51) then
                        is_inside = not is_inside
                        SetEntityCoords(PlayerPedId(), handle2)

Looking for paid scripts? Click here