получение координат 3д текста

TimeLordRu

Известный
Автор темы
151
38
Версия MoonLoader
.026-beta
lua:
{'onCreate3DText', {id = 'int16'}, {color = 'int32'}, {position = 'vector3d'}, {distance = 'float'}, {testLOS = 'bool8'}, {attachedPlayerId = 'int16'}, {attachedVehicleId = 'int16'}, {text = 'encodedString4096'}}
я так понял, надо работать с position. когда я пытался вывести position в чат - выводило пустую строку. когда пытался x, y, z = position - крашило. Как узнать координаты 3д текста?
 
Последнее редактирование:
Решение
lua:
{'onCreate3DText', {id = 'int16'}, {color = 'int32'}, {position = 'vector3d'}, {distance = 'float'}, {testLOS = 'bool8'}, {attachedPlayerId = 'int16'}, {attachedVehicleId = 'int16'}, {text = 'encodedString4096'}}
я так понял, надо работать с position. когда я пытался вывести position в чат - выводило пустую строку. когда пытался x, y, z = position - крашило. Как узнать айди 3д текста?
вроде так
position.x
position.y
position.z

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,777
11,227
lua:
{'onCreate3DText', {id = 'int16'}, {color = 'int32'}, {position = 'vector3d'}, {distance = 'float'}, {testLOS = 'bool8'}, {attachedPlayerId = 'int16'}, {attachedVehicleId = 'int16'}, {text = 'encodedString4096'}}
я так понял, надо работать с position. когда я пытался вывести position в чат - выводило пустую строку. когда пытался x, y, z = position - крашило. Как узнать айди 3д текста?
вроде так
position.x
position.y
position.z
 
  • Нравится
Реакции: TimeLordRu

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,777
11,227
Как сделать так, когда игрок подходит происходило действие?
это должно сработать
Lua:
local sampev = require 'lib.samp.events'
local textCoords = {x = nil, y = nil, z = nil}

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        if textCoords.x then
            if isCharInArea3d(PLAYER_PED, textCoords.x - 3, textCoords.y - 3, textCoords.z - 3, textCoords.x + 3, textCoords.y + 3, textCoords.z + 3, false) then
                sampAddChatMessage('ты рядом с текстом', -1)
            end
            --или
            x, y, z = getCharCoordinates(PLAYER_PED)
            if getDistanceBetweenCoords3d(x, y, z, textCoords.x, textCoords.y, textCoords.z) <= 3 then
                sampAddChatMessage('ты рядом с текстом', -1)
            end
        end
    end
end

function sampev.onCreate3DText(id, color, position, distance, testLOS, attPid, attVid, text)
    if text:find('текст 3д текста') then
        textCoords.x = position.x
        textCoords.y = position.y
        textCoords.z = position.z
    end
end
 
  • Нравится
Реакции: NutorCoco