3dText цыкл

MixailScripts

Участник
Автор темы
84
6
Версия MoonLoader
.027.0-preview
Приветствую, можно ли сделать так чтобы при нахождении 3д текста, не выводило бесконечно в чат сообщение, а только один раз при каждом новом 3д тексте?
Пример кода.
Lua:
function main()
    if not isSampLoaded() and not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(0) end
    while not sampIsLocalPlayerSpawned() do wait(100) end
    sampRegisterChatCommand('far', test)
    sampAddChatMessage('1113', -1)
    lockPlayerControl(false)
    j = 0
    n = 0
    local saveX = {}
    local saveY = {}
    local saveZ = {}
    x3 = 0.0
    y3 = 0.0
    z3 = 0.0
    while true do
        wait(0)
        if state then
            if isPlayerPlaying(playerHandle) then
                local posX, posY, posZ = getCharCoordinates(playerPed)
                local res, text, color, x, y, z, distance, ignoreWalls, player, vehicle = Search3Dtext(posX, posY, posZ, 50.0, "Для сбора")
                if res then
                    sampAddChatMessage('1', -1)
                    res = false
                end
            end
        end
    end
end


function Search3Dtext(x, y, z, radius, patern) -- https://www.blast.hk/threads/13380/post-119168
    local text = ""
    local color = 0
    local posX = 0.0
    local posY = 0.0
    local posZ = 0.0
    local distance = 0.0
    local ignoreWalls = false
    local player = -1
    local vehicle = -1
    local result = false
    for id = 0, 2048 do
        if sampIs3dTextDefined(id) then
            local text2, color2, posX2, posY2, posZ2, distance2, ignoreWalls2, player2, vehicle2 = sampGet3dTextInfoById(id)
            if getDistanceBetweenCoords3d(x, y, z, posX2, posY2, posZ2) < radius then
                if string.len(patern) ~= 0 then
                    if string.match(text2, patern, 0) ~= nil then result = true end
                else
                    result = true
                end
                if result then
                    text = text2
                    color = color2
                    posX = posX2
                    posY = posY2
                    posZ = posZ2
                    distance = distance2
                    ignoreWalls = ignoreWalls2
                    player = player2
                    vehicle = vehicle2
                    radius = getDistanceBetweenCoords3d(x, y, z, posX, posY, posZ)
                end
            end
        end
    end
    return result, text, color, posX, posY, posZ, distance, ignoreWalls, player, vehicle
end
 

манку хлебал

Потрачен
305
120
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Lua:
local events = require('lib.samp.events')

function main()
    while true do
        wait(1)
    end
end

function events.onCreate3DText(id, color, position, distance, LOS, attachedPlayer, attachedVehicle, text)
    sampAddChatMessage(('[onCreate3DText] id: %d x: %.2f y: %.2f z: %.2f'):format(id, position.x, position.y, position.z))
end
 
Последнее редактирование:
  • Bug
Реакции: frit

MixailScripts

Участник
Автор темы
84
6
Lua:
local events = require('lib.samp.events')

function main()
    while true do
        wait(1)
    end
end

function events.onCreate3DText(id, color, position, distance, LOS, attachedPlayer, attachedVehicle, text)
    sampAddChatMessage(('[onCreate3DText] id: %d x: %.2f y: %.2f z: %.2f'):format(id, position.x, position.y, position.z))
end
Мне создавать его не надо, а просто что-бы он его нашел, а потом бесконечный цикл выключился.
 

манку хлебал

Потрачен
305
120
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.

Похожие темы

  1. У
    • Закрыта
    Ответы
    4
    Просмотры
    1K
    Архив
    Удалённый пользователь 111847
    У