Jump to content

help with dx messages


Andreas.

Recommended Posts

Posted

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) 

Posted
Using the function removeMessages in the commandhandler would be an easy fix, right?

The command handler is obviously only there to test it.

Posted
I don't really get your problem, could you explain yourself further?

I want the dxmessage to disappear directly if I trigger the event while it's already active.

Posted
local dxMessage = { } 
dxStatus = false 
  
function dxEvent ( message, r, g, b ) 
    for index, message in ipairs ( dxMessage ) do 
        dxDrawText ( message [ 1 ], 573, 1040, 1516, 1080, tocolor ( message [ 2 ], message [ 3 ], message [ 4 ], 255 ), 1.5, "arial", "center", "center", false, false, true ) 
        dxStatus = true 
    end 
    dxStatus = false 
end 
  
function removeMessages ( ) 
    removeEventHandler ( "onClientRender", root, dxEvent ) 
end 
  
function dxOutput ( message, r, g, b ) 
    if ( dxStatus ) then 
        removeEventHandler ( "onClientRender", root, dxEvent ) 
        outputChatBox ( "active" ) 
        killTimer ( theTimer ) 
    end 
    table.insert ( 
        dxMessage, 
        { 
            message, 
            r, 
            g, 
            b 
        } 
    ) 
    addEventHandler ( "onClientRender", root, dxEvent ) 
    theTimer = setTimer ( removeMessages, 4000, 1 ) 
    dxStatus = ( not dxStatus ) 
end 
addEvent ( "dxOutput", true ) 
addEventHandler ( "dxOutput", root, dxOutput ) 
  
addCommandHandler ( "lol", 
    function ( ) 
        triggerEvent ( "dxOutput", root, "testing hehe", 0, 250, 0 ) 
    end 
) 

That's what you mean?

Posted
local dxMessage = { } 
dxStatus = false 
  
function dxEvent ( message, r, g, b ) 
    for index, message in ipairs ( dxMessage ) do 
        dxDrawText ( message [ 1 ], 573, 1040, 1516, 1080, tocolor ( message [ 2 ], message [ 3 ], message [ 4 ], 255 ), 1.5, "arial", "center", "center", false, false, true ) 
        dxStatus = true 
    end 
    dxStatus = false 
end 
  
function removeMessages ( ) 
    removeEventHandler ( "onClientRender", root, dxEvent ) 
end 
  
function dxOutput ( message, r, g, b ) 
    if ( not dxStatus ) then 
        removeEventHandler ( "onClientRender", root, dxEvent ) 
        outputChatBox ( "active" ) 
        killTimer ( theTimer ) 
    end 
    table.insert ( 
        dxMessage, 
        { 
            message, 
            r, 
            g, 
            b 
        } 
    ) 
    addEventHandler ( "onClientRender", root, dxEvent ) 
    theTimer = setTimer ( removeMessages, 4000, 1 ) 
    dxStatus = ( not dxStatus ) 
end 
addEvent ( "dxOutput", true ) 
addEventHandler ( "dxOutput", root, dxOutput ) 
  
addCommandHandler ( "lol", 
    function ( ) 
        triggerEvent ( "dxOutput", root, "testing hehe", 0, 250, 0 ) 
    end 
) 

That's what you mean?

bad arguement at killTimer: 20

and it doesn't remove the dxtext, it's still there

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...