I'm trying to make my own notification system but I have encountered couple of problems. The deletion is not working AT ALL as I want.
I want it so that when a message is already active, it will delete the old one and the timer will start all over again. Currently I can make one message, and I can make yet another one on top of that (does not remove it) so yeah, help is highly appreciated! And yea, I know the code is highly fucked up.
local dxMessage = {}
dxStatus = false
function dxEvent(message, r, g, b)
for index, message in pairs(dxMessage) do dxDrawText(message[1],573.0,1040.0,1516.0,1080.0,tocolor(message[2],message[3],messageData[4],255),1.5,"arial","center","center",false,false,true)
dxStatus = true
end
theTimer = setTimer(removeMessages, 4000, 1)
dxStatus = false
end
function removeMessages()
removeEventHandler("onClientRender", root, dxEvent)
end
function dxOutput(message, r, g, b)
table.insert(dxMessage, {message, r, g, b})
addEventHandler("onClientRender", root, dxEvent)
if (dxStatus) == false then
dxStatus = true
else
dxStatus = false
end
if (dxStatus == false) then removeEventHandler("onClientRender", root, dxEvent) outputChatBox("active") killTimer(theTimer) end
end
addEvent("dxOutput", true)
addEventHandler("dxOutput", root, dxOutput)
addCommandHandler("lol",
function()
triggerEvent("dxOutput", root, "testing hehe", 0, 250, 0)
end)