Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ERROR: main.lua:9: attempt to perform arithmetic on a nil value (global 'playerCoords') help?

Asked by 3 years ago
-- Enter / Exit marker events & Draw Markers
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local coords = GetEntityCoords(PlayerPedId())
        local isInMarker, letSleep, currentZone = false, true

        for k,v in pairs(Config.Zones) do
            local distance = #(playerCoords - v.Pos)

            if distance < Config.DrawDistance then
                letSleep = false

                if v.Type ~= -1 then
                    DrawMarker(v.Type, v.Pos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false)
                end

                if distance < v.Size.x then
                    isInMarker, currentZone = true, k
                end
            end
        end

        if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
            HasAlreadyEnteredMarker, LastZone = true, currentZone
            LastZone = currentZone
            TriggerEvent('esx_aircraftshop:hasEnteredMarker', currentZone)
        end

        if not isInMarker and HasAlreadyEnteredMarker then
            HasAlreadyEnteredMarker = false
            TriggerEvent('esx_aircraftshop:hasExitedMarker', LastZone)
        end

        if letSleep then
            Citizen.Wait(500)
        end
    end
end)
0
hmm xxaxxaz 42 — 3y

1 answer

Log in to vote
0
Answered by
xxaxxaz 42
3 years ago
Edited 3 years ago

you have a # before the (playerCoords - v.Pos) hash tags are supposed to meen the number of things in it for example #game.Players wich would probaly give you a error to but I dont know much about these, that is all I know about them.

0
btw I might be wrong because I dont know much about them. xxaxxaz 42 — 3y
Ad

Answer this question