Как вывести текст на экран после события сампевентс?

Kirillka_

Новичок
Автор темы
20
10
Версия MoonLoader
.026-beta
Решил я значит написать небольшой скрипт для помощи работы в полиции и столкнулся с проблемой, что выводить текст в чат неудобно. Как вывести текст на экран (чтобы он висел 8 секунд и убирался по нажатию определенной клавиши) когда происходит событие из сампевентс, допустим onSendTakeDamage?

И тут ещё вопросик подъехал... Допустим я вывел сообщение через sampAddChatMessage в чат, и мне нужно в бесконечном цикле разделить, что было написано в чат (if, else)
 
Последнее редактирование:
Решение
Lua:
require ('lib.moonloader')
local sampev = require ('lib.samp.events')

local font = renderCreateFont("Arial Black", 13, 12)

local TakeDamage = {}

for i=0,1000 do
    table.insert(TakeDamage, {-1,0,-1})
end

function main()
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampIsLocalPlayerSpawned()
    sampAddChatMessage('Test')
    while true do
        wait(0)
        for i=0,1000 do
            if sampIsPlayerConnected(i) then
                for k,v in ipairs(TakeDamage) do
                    if v[1] ~= -1 then
                        if v[2] - os.time() > -5 then
                            renderFontDrawText(font,string.format('{29871f}%0.1f by ID %s',v[3],tostring(v[1])), 1000, 500, -1)...

Manuel Leon

Известный
266
166
Lua:
require ('lib.moonloader')
local sampev = require ('lib.samp.events')

local font = renderCreateFont("Arial Black", 13, 12)

local TakeDamage = {}

for i=0,1000 do
    table.insert(TakeDamage, {-1,0,-1})
end

function main()
    while not isSampAvailable() do wait(100) end
    repeat wait(0) until sampIsLocalPlayerSpawned()
    sampAddChatMessage('Test')
    while true do
        wait(0)
        for i=0,1000 do
            if sampIsPlayerConnected(i) then
                for k,v in ipairs(TakeDamage) do
                    if v[1] ~= -1 then
                        if v[2] - os.time() > -5 then
                            renderFontDrawText(font,string.format('{29871f}%0.1f by ID %s',v[3],tostring(v[1])), 1000, 500, -1)
                        else
                            TakeDamage[i] =  {-1, 0, -1}
                        end
                    end
                end
            end
        end
    end
end

function sampev.onSendTakeDamage(playerId, damage, weapon, bodypart)
    TakeDamage[playerId] =  {playerId, os.time(), damage}
end

Быдло код, осторожно
 
  • Bug
Реакции: atomlin