Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sx, sy = guiGetScreenSize()
- local tick
- local font = dxCreateFont('medium.ttf', 13/1920*sx, true);
- local colors = {
- error = tocolor(252, 3, 3),
- info = tocolor(252, 186, 3),
- success = tocolor(69, 219, 46),
- }
- local notifications = {};
- function anim(startTick, startValue, stopValue, time, type)
- local anim = interpolateBetween(startValue, 0, 0, stopValue, 0, 0, (getTickCount() - startTick) / time, type)
- if (getTickCount() - startTick) > time then
- return anim, false
- else
- return anim, true
- end
- end
- function renderNoti()
- for index, value in pairs(notifications) do
- noti = anim(tick, 1800, 1493, 2000, 'Linear')
- if getTickCount() > value[3] + (value[4] + 500) then
- table.remove(notifications, 1)
- if (#notifications == 0) then
- removeEventHandler('onClientRender', root, renderNoti);
- end
- end
- local addY = 100 * (index - 1);
- dxDrawRectangle(noti, 340 + addY, 417, 93, tocolor(34, 35, 66, 255), false)
- dxDrawText(value[2], 1493, 339 + addY, 1910, 430 + addY, tocolor(255, 255, 255, 255), 1, font, 'center', 'center', false, true, true);
- end
- end
- function createAlert(type, text)
- if not type then type = 'info' end
- tick = getTickCount
- table.insert(notifications, { type, text, getTickCount(), 5000});
- outputConsole('['..type..'] '..text);
- if (#notifications == 1) then
- addEventHandler('onClientRender', root, renderNoti);
- end
- if (#notifications > 5) then
- table.remove(notifications, 1);
- end
- end
- addEvent("createAlert", true)
- addEventHandler("createAlert", resourceRoot,
- function(...)
- createAlert(...)
- end
- )
- addCommandHandler("createAlert1", function()
- createAlert("success", "Pomyślnie się zalogowałeś!")
- end)
Advertisement
Add Comment
Please, Sign In to add comment