50p Posted March 1, 2008 Share Posted March 1, 2008 ifEventAlreadyHandled : addEventHandler: is already handled - Line: This message comes if you want to addEventHandler the same function. How to avoid it? To avoid it I have to use a boolean variable which is set to true when I add the handler and is set to false when I remove the handler. So I know if the event was handled already or not. If we had isEvenAlreadyHandled we didn't have to do the trick that I do. isPlayerInMarker Same trick here. We have to create a variable and set it to true when player enters marker or to false when player leaves marker. That's the way I created isPlayerInBank in bank script to check whether player can use commands. Link to comment
lil Toady Posted March 2, 2008 Share Posted March 2, 2008 events problem: (not tested) _events = {} _addEventHandler = addEventHandler function addEventHandler ( event, element, function ) if ( _addEventHandler ( event, element, function ) ) then _events.insert ( { event, element, function } ) return true end return false end _removeEventHandler = removeEventHandler function removeEventHandler ( event, element, function ) for i, event in ipairs ( _events ) do if ( ( event[1] == event ) and ( event[2] == element ) and ( event[3] == function ) ) then _events.remove ( i ) end end return _removeEventHandler ( event, element, function ) end function isEventHandled ( event, function ) for i, event in ipairs ( _events ) do if ( ( event[1] == event ) and ( event[2] == element ) and ( event[3] == function ) ) then return true end end return false end and isPlayerInMarker, mta is not going to use low level functions like that, player is an element and markers have ther own col shape so function isPlayerInMarker ( player, marker ) return isElementWithinColShape ( player, getElementColShape ( marker ) ) end Link to comment
Recommended Posts