View Issue Details

IDProjectCategoryView StatusLast Update
0005495Multi Theft Auto : San AndreasServerpublic2013-01-21 21:46
ReporterkarlozAssigned Toccw 
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version 
Target Version1.3.1Fixed in Version1.3.1 
Summary0005495: event handlers prioritization
Description

allow to set priorities for event handlers

bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true], [int priority=5])

I can imagine lots of cases where this could come handy
An example:

I give some special weapon to a player that should never drop
so if the player dies i want remove it.
The deathpickups resource creates pickups of that weapon before i can remove it from the player.
I havent found a way to make my event handler run before the deathpickups one.
Starting my resource before deathpickups doesnt assure me my event handler will run first.

Other example:
The interiors resource send an event when a player is gonna enter an interior
A third party resource handling houses properties could want to run an event handler on that event with higher priority, in order to check is the player is the owner of the house. If it is not it would cancel the event.

I believe this stuff cannot be done directly since the interiors resource now nothing about that other resource.

TagsNo tags attached.

Activities

Talidan

2010-07-23 21:36

administrator   ~~0011809

The more clean solution to this is to make events for when resources do stuff, and make them cancellable. For example, the interiors resource's onPlayerInteriorHit (i think that's the name) is cancellable.

Event priorities have come up several times in the past however, and they would have their uses regardless.

karloz

2010-07-23 21:59

viewer   ~~0011810

Yes i think that is what i mean. Instead of doing directly an action send an event to 'myself', but let others process the event before 'me'.

I understand, but if by the time i cancel the event, it has already being procesed somewhere. Doesnt solve the problem. I dont see event handlers being procesed in any specific order. Or i dont understand how they are processed.

Or you mean, when the sender resource make the event cancelable. that set that resource as the last one to proccess the event with its own event handler.

Talidan

2010-07-23 22:05

administrator   ~~0011811

What i mean is that resources such as deathpickups should add a cancellable onPlayerDeathPickupCreate so you can modify it's behaviour yourself.

But again, it doesnt invalidate the report.

arranTuna

2013-01-18 21:59

manager   ~~0017979

This was fixed a long time ago in http://code.google.com/p/mtasa-blue/source/detail?r=3793

Issue History

Date Modified Username Field Change