0

有错误的行:

for zone, data in pairs(Config.zones) do

我对此很陌生(我已经完成了 python 编程,我真的需要解决这个问题,如果你能帮助我并指导我如何解决这个问题,我将不胜感激!错误在这个标题中。

完整代码:

ESX = nil local CurrentAction = nil local CurrentActionMsg = '' local HasAlreadyEnteredMarker = false local LastZone = nil

Citizen.CreateThread(function()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj)ESX = obj end)
        Citizen.Wait(0)
    end end)

AddEventHandler('tp:hasEnteredMarker', function(zone)
    if zone == 'MethEnter' then
        CurrentAction = zone
    end
    
    if zone == 'MethExit' then
        CurrentAction = zone
    end

    if zone == 'WeedEnter' then
        CurrentAction = zone
    end         if zone == 'WeedExit' then
        CurrentAction = zone
    end

    if zone == 'MoneyWashEnter' then
        CurrentAction = zone
    end         if zone == 'MoneyWashExit' then
        CurrentAction = zone
    end
    
    if zone == 'CokeEnter' then
        CurrentAction = zone
    end
    
    if zone == 'CokeExit' then
        CurrentAction = zone
    end end)

AddEventHandler('tp:hasExitedMarker', function(zone)
    CurrentAction = nil end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(3)

        local coords = GetEntityCoords(PlayerPedId())
        local isInMarker = false
        local currentZone = nil
        
        for zone, data in pairs(Config.zones) do
            local dist = #(coords - vector3(data.x, data.y, data.z));

            if dist < (data.w) then
                isInMarker = true
                currentZone = zone
                ESX.Game.Teleport(PlayerPedId(), {
                    x = Config.point[zone].x,
                    y = Config.point[zone].y,
                    z = Config.point[zone].z
                })
                CurrentAction = nil
                break
            end

            if data.visible and dist < 10 then
                DrawMarker(
                    data.t,
                    data.x,
                    data.y,
                    data.z,
                    0.0,
                    0.0,
                    0.0,
                    0,
                    0.0,
                    0.0,
                    data.w,
                    data.w,
                    data.h,
                    data.color.r,
                    data.color.g,
                    data.color.b,
                    255,
                    false,
                    true,
                    2,
                    false,
                    false,
                    false,
                    false
                )
            end
        end
        
        if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
            HasAlreadyEnteredMarker = true
            LastZone = currentZone
            TriggerEvent('tp:hasEnteredMarker', currentZone)
        end
        
        if not isInMarker and HasAlreadyEnteredMarker then
            HasAlreadyEnteredMarker = false
            TriggerEvent('tp:hasExitedMarker', LastZone)
        end
 
    end end) 

4

1 回答 1

0

检查您的配置中是否有“Config.zones”,而不是“Config.Zones”,如果有,那么您可能没有在 Config.zones 中输入任何内容,或者您​​没有正确输入。

于 2021-10-18T08:19:56.590 回答