- 83
- 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