local screenSize = {guiGetScreenSize()}
local lastTick = 0
local isNotificationActive = false
local notificationText, notificationType = nil, nil
local startY, endY = 0, 0
local infoboxTimer = nil
function addNotification(typ, text)
if string.lower(typ) == \"info\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
elseif string.lower(typ) == \"warning\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
elseif string.lower(typ) == \"error\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
elseif string.lower(typ) == \"success\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
eelseif string.lower(typ) == \"admindutyon\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
elseif string.lower(typ) == \"admindutyoff\" then
notificationText = text
notificationType = typ
isNotificationActive = true
lastTick = getTickCount()
startY = ((screenSize[1]/2 - 319/2) * 2) + 300
endY = ((screenSize[1]/2 - 319/2) * 2)
playSound(\"fajlok/hang.mp3\", false)
end
end
if not isTimer(infoboxTimer) then
addEventHandler(\"onClientRender\", root, renderNotification)
end
if isTimer(infoboxTimer) then
killTimer(infoboxTimer)
end
infoboxTimer = setTimer(function()
startY = ((screenSize[1]/2 - 319/2) * 2)
endY = ((screenSize[1]/2 - 319/2) * 2) + 300
lastTick = 0
lastTick = getTickCount()
end, 5000, 1)
end
addEvent(\"showNotification\", true)
addEventHandler(\"showNotification\", root, showNotification)
function renderNotification()
if notificationText and notificationType and isNotificationActive then
animX = interpolateBetween(startY, 0, 0, endY, 0, 0, getProgress(800), \"Linear\")
dxDrawImage(animX, 150, 319, 171, \"files/\" .. notificationType .. \".png\")
dxDrawText(notificationText, animX + 30, 225, 319, 200, tocolor(255, 255, 255, 150), 1, \"default-bold\")
if animX == ((screenSize[1]/2 - 319/2) * 2) + 300 then
removeEventHandler(\"onClientRender\", root, renderNotification)
lastTick = 0
end
end
end
addEventHandler(\"onClientRender\", root, renderNotification)
function getProgress( addtick )
local now = getTickCount()
local elapsedTime = now - lastTick
local duration = lastTick+addtick - lastTick
local progress = elapsedTime / duration
return progress
end
addCommandHandler(\"e\", function()
showNotification(\"error\", \"Ez egy szöveg amit tesztelek.\")
end)
addCommandHandler(\"s\", function()
showNotification(\"success\", \"Ez egy szöveg amit tesztelek.\")
end)
addCommandHandler(\"i\", function()
showNotification(\"info\", \"Ez egy szöveg amit tesztelek.\")
end)
addCommandHandler(\"w\", function()
showNotification(\"warning\", \"Ez egy szöveg amit tesztelek.\")
end)
Így néz ki az infobox ami működik házi szerveren, de ha rp szeróra berakom és átírkálom a showboxot addNotificationra akkor sem működik /asay error meg egyebekkel
szerver oldali
function showNotification(playerSource, typ, text)
if playerSource and typ and text then
triggerClientEvent(playerSource, \"showNotification\", playerSource, typ, text)
end
end
addCommandHandler(\"noticetests\", function(player, cmd)
showNotification(player, \"error\", cmd)
end)
meta
<meta>
<script src=\"sourceC.lua\" type=\"client\"></script>
<script src=\"sourceS.lua\" type=\"server\"></script>
<file src=\"files/info.png\"></file>
<file src=\"files/warning.png\"></file>
<file src=\"files/error.png\"></file>
<file src=\"files/success.png\"></file>
<file src=\"files/bip.mp3\"></file>
<export function=\"showNotification\" type=\"shared\"></export>
</meta>