Jump to content

Event in function


Rutex

Recommended Posts

Posted

Hi guys. I have small problem. I need to have event listener in function. Server:

  
function enterVehicle( theVehicle, seat, jacked) 
... some code 
if(CurrectCarID == 437) then 
        if(seat == 0)then 
            triggerClientEvent( Player, "EnterBus",getRootElement() ) 
                        addEventHandler( "BusMarsh1",getRootElement(  ), function () 
                        log("marsh1") 
end)  
  

its send on client event, that activate the gui, and return the selected button in event

The problem is, in every car enter, the event is dupe.

for example. 1 st. enter - its print only 1 time "marsh1". In next enter car, its print 2 times "marsh1", in 3 enter 3, and etc....

How i can do this right? or fix? Without this dupe.

P.s. Log. func.

  
function log( Msg ) 
    outputChatBox( Msg,getRootElement(  )) 
end 
  

Posted

Because every time the function enterVehicle is called, a new event handler is created for "BusMarsh1". You'll have to remove it using removeEventHandler.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Yes. I know why its dupe. For me was intresing how i can " fix " it. I was think here is special event listener for this.

Thank you:)

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...