0

您好,我在这里发布了两个不同的代码片段,我不确定如何在另一个脚本中调用它们。我尝试添加事件处理程序,但它破坏了两个脚本。这是一个触发服务器事件并在我的客户端 lua 中显示该项目的商店脚本:

 Citizen.CreateThread(function()
    while true do
        local InRange = false
        local PlayerPed = GetPlayerPed(-1)
        local PlayerPos = GetEntityCoords(PlayerPed)

        for shop, _ in pairs(Config.Locations) do
            local position = Config.Locations[shop]["coords"]
            for _, loc in pairs(position) do
                local dist = GetDistanceBetweenCoords(PlayerPos, loc["x"], loc["y"], loc["z"])
                if dist < 10 then
                    InRange = true
                    DrawMarker(2, loc["x"], loc["y"], loc["z"], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.2, 0.1, 255, 255, 255, 155, 0, 0, 0, 1, 0, 0, 0)
                    if dist < 1 then
                        DrawText3Ds(loc["x"], loc["y"], loc["z"] + 0.15, '~g~E~w~ - Shop')
                        if IsControlJustPressed(0, Config.Keys["E"]) then
                            local ShopItems = {}
                            ShopItems.label = Config.Locations[shop]["label"]
                            ShopItems.items = Config.Locations[shop]["products"]
                            ShopItems.slots = 30
                            TriggerServerEvent("inventory:server:OpenInventory", "shop", "Itemshop_"..shop, ShopItems)
                        end
                    end
                end
            end
        end

        if not InRange then
            Citizen.Wait(5000)
        end
        Citizen.Wait(5)
    end
end)

这是我需要在里面调用服务器事件的代码,目前这个片段不起作用,因为我试图添加不同的服务器事件来尝试。:

local gasstation = {
    303280717,
}
AddTargetModel(gasstation, {
    options = {
        {
            event = "qb-shops:client:UpdateShop",
            icon = "fas fa-creditcard",
            label = "Shop Items",
        },
    },
    distance = 2.5
})
4

0 回答 0