Event MP PLAYER HITS TARGET: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 38: | Line 38: | ||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Scripting]] | [[Category:Scripting]] | ||
[[Category:Event]] |
Revision as of 09:45, 8 July 2025
MP_PLAYER_HITS_TARGET is one of these events that are called from multiple places with multiple argument count.
Therefore accessing the parameters passed to that event require proper handling to avoid errors.
Currently it is called 3 times in sum:
GameEventBus.call(GameEventType.MP_PLAYER_HITS_TARGET, ftClient, game, skill); // ftClient might be changed to connection in future GameEventBus.call(GameEventType.MP_PLAYER_HITS_TARGET, connection, game, newHealth, skillHitsTarget); GameEventBus.call(GameEventType.MP_PLAYER_HITS_TARGET, connection, game, newHealth, skill, skillHitsTarget);
You need to register and handle it the following way:
geb.on("MP_PLAYER_HITS_TARGET", function () {
switch (arguments.length) {
case 3:
handleUniqueSkill(arguments[0], arguments[1], arguments[2]);
break;
case 4:
handleBallLossDamage(arguments[0], arguments[1], arguments[2], arguments[3]);
break;
case 5:
handleSkillDamage(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
default:
logUnexpectedArgs(arguments);
}
});
arguments
is a built-in object in JavaScript functions, especially in non-arrow (function (...) {}
) style functions. It is implicitly available inside any function declared with the classic function (...) {}
syntax.
It is:
- an array-like object
- holds all the values passed to the function
- always available in classic functions (not in arrow
functions ()=>{}
)