Текст в чат из 3DText

K_M

Новичок
Автор темы
4
0
Версия MoonLoader
.026-beta
Есть вот такой текст
1654895767490.png

Можно ли как-то сделать так, что когда я подхожу на определённое расстояние мне в чат высвечивалась строчка "Тип бизнеса: xxx " и вместо ххх текст из этого 3d текста
Если не трудно можно пример👉👈
 
Решение
Lua:
function main()
    repeat wait(0) until isSampAvailable()
    while true do wait(0)
        for i = 0,2048 do
            if sampIs3dTextDefined(i) then
                local pp = {sampGet3dTextInfoById(i)}
                if pp[1]:match('your text') then
                    local x,y,z = getCharCoordinates(PLAYER_PED)
                    if getDistanceBetweenCoords3d(x,y,z,pp[3],pp[4],pp[5]) <= 10 then
                        sampAddChatMessage('text', -1)
                    end
                end
            end
        end
    end
end
с помощью match достаешь нужный тебе текст. Это без samp.events

krim

Известный
304
132
Lua:
function main()
    repeat wait(0) until isSampAvailable()
    while true do wait(0)
        for i = 0,2048 do
            if sampIs3dTextDefined(i) then
                local pp = {sampGet3dTextInfoById(i)}
                if pp[1]:match('your text') then
                    local x,y,z = getCharCoordinates(PLAYER_PED)
                    if getDistanceBetweenCoords3d(x,y,z,pp[3],pp[4],pp[5]) <= 10 then
                        sampAddChatMessage('text', -1)
                    end
                end
            end
        end
    end
end
с помощью match достаешь нужный тебе текст. Это без samp.events
 

K_M

Новичок
Автор темы
4
0
Lua:
function main()
    repeat wait(0) until isSampAvailable()
    while true do wait(0)
        for i = 0,2048 do
            if sampIs3dTextDefined(i) then
                local pp = {sampGet3dTextInfoById(i)}
                if pp[1]:match('your text') then
                    local x,y,z = getCharCoordinates(PLAYER_PED)
                    if getDistanceBetweenCoords3d(x,y,z,pp[3],pp[4],pp[5]) <= 10 then
                        sampAddChatMessage('text', -1)
                    end
                end
            end
        end
    end
end
с помощью match достаешь нужный тебе текст. Это без samp.events
А через events как сделать, просто это флудит в чат бесконечно, а мне нужно чтобы просто один раз написало в чат и всё

И ещё, можно ли как-то сделать что после телепорта к бизу, например /gotobiz 188, в чат выводилась строчка с владельцем бизака
1654898124198.png

Что-то типо "Вы телепортировались к бизнесу. Владелец бизнеса: Rowie_Gold"
 

krim

Известный
304
132
А через events как сделать, просто это флудит в чат бесконечно, а мне нужно чтобы просто один раз написало в чат и всё

И ещё, можно ли как-то сделать что после телепорта к бизу, например /gotobiz 188, в чат выводилась строчка с владельцем бизака
Посмотреть вложение 151974
Что-то типо "Вы телепортировались к бизнесу. Владелец бизнеса: Rowie_Gold"

А через events как сделать, просто это флудит в чат бесконечно, а мне нужно чтобы просто один раз написало в чат и всё

И ещё, можно ли как-то сделать что после телепорта к бизу, например /gotobiz 188, в чат выводилась строчка с владельцем бизака
Посмотреть вложение 151974
Что-то типо "Вы телепортировались к бизнесу. Владелец бизнеса: Rowie_Gold"
хукаешь onCreate3DText, насчёт телепорта не понял, на аризоне не играю
 

Vespan

loneliness
Проверенный
2,105
1,639
Lua:
local w = ''
---
while true do wait(0)
local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
local res, text, color, x, y, z, distance, ignoreWalls, player, vehicle = Search3Dtext(posX, posY, posZ, 30.0, "")--[[30 радиус]]
if text:find('Бизнес продаеться') and w ~= text then
-- не будет флудить
    sampAddChatMessage('!',-1)
    w = text
end
----
function Search3Dtext(x, y, z, radius, patern)
    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 = getDistanceBetweenCoords3d(posX2, posY2,posZ2, x,y,z)
                    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

хукаешь onCreate3DText, насчёт телепорта не понял, на аризоне не играю
onCreate3DText оно реагирует когда создался 3d text,но не будет если изменился текст.
вроде как,я уже не помню когда я это юзал.
 
  • Влюблен
Реакции: tyukapa

krim

Известный
304
132
Lua:
local w = ''
---
while true do wait(0)
local posX, posY, posZ = getCharCoordinates(PLAYER_PED)
local res, text, color, x, y, z, distance, ignoreWalls, player, vehicle = Search3Dtext(posX, posY, posZ, 30.0, "")--[[30 радиус]]
if text:find('Бизнес продаеться') and w ~= text then
-- не будет флудить
    sampAddChatMessage('!',-1)
    w = text
end
----
function Search3Dtext(x, y, z, radius, patern)
    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 = getDistanceBetweenCoords3d(posX2, posY2,posZ2, x,y,z)
                    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


onCreate3DText оно реагирует когда создался 3d text,но не будет если изменился текст.
вроде как,я уже не помню когда я это юзал.
текст создался, создал поток, цикл и вперёд