local sampev = require 'samp.events'
local labels = {}
local function renderInLoop()
for id, label in pairs(labels)
-- code...
-- label.text - выводит текст
-- label.id - выводит ид лабела
-- label.position.x = выводит координаты на x
end
end
function main()
repeat wait(0) until isSampAvailable()
print('Hey!')
while true do
wait(0)
if #labels ~= 0 then renderInLoop() end
end
end
-- {'onCreate3DText', {id = 'uint16'}, {color = 'int32'}, {position = 'vector3d'},
-- {distance = 'float'}, {testLOS = 'bool8'}, {attachedPlayerId = 'uint16'},
-- {attachedVehicleId = 'uint16'}, {text = 'encodedString4096'}}
-- при появлении 3д текст в стриме
function sampev.onCreate3DText(id, color, position, distance, testLOS, attPlayerId, attVehicleId, text)
print('Created3DTextLabel: ', id, color, position, distance, testLOS, attPlayerId, attVehicleId, text)
labels[id] = {
id = id,
color = color,
position = position,
distance = distance,
testLOS = testLOS,
attPlayerId = attPlayerId,
attVehicleId = attVehicleId,
text = text,
}
end
-- {'onTextDrawSetString', {id = 'uint16'}, {text = 'string16'}}
-- при обновлении строка
function sampev.onTextDrawSetString(id, newText)
if labels[id] then
local fmt = string.format(
'Updated new text in labels[%d].\nOld: %s\nNew: %s',
labelId, labels[id].text, newText
)
print(fmt)
labels[id].text = newText
end
end
-- {'onRemove3DTextLabel', {textLabelId = 'uint16'}}
-- при удалении 3д текст в стриме
function sampev.onRemove3DTextLabel(id)
if labels[id] then
print('Removed3DTextLabel: ', id)
table.remove(labels, id)
end
end