You are viewing a potentially older version of this package. View all versions.
S2Mods-ClientKillCallback-2.0.0 icon

ClientKillCallback

Used as a dependency for other mods, resource for modders.

Date uploaded a year ago
Version 2.0.0
Download link S2Mods-ClientKillCallback-2.0.0.zip
Downloads 7258
Dependency string S2Mods-ClientKillCallback-2.0.0

README

KillCallback

Adds a client sided callback triggered each player kill in the match.


Note:

Thanks to Fifty#8113 and Spoon#1812 as they did most of the work on this, I just put it together and made it into a mod.


For end users:

This alone does nothing but is required for other mods to function.

If another mod listed this one as its dependency, download it!


For modders:

Due to the new update, all mods which require this one must be updated.

AddClientCallback_OnPlayerKilled ( void functionref ( ObituaryCallbackParams {entity victim, entity attacker, int damageSourceId, int scriptDamageType} ) customCallback)

With the new update made by Uniboi, the arguments of current callbacks need to be replaced with an ObituaryCallbackParams struct.
The struct currently contains:

  • attacker (entity)
  • victim (entity)
  • damageSourceId (int)
  • scriptDamageType (int)

Example:

void function afterClientInit(){
    AddCallback_OnPlayerKilled ( myCallbackFunction )
}

void function myCallbackFunction ( ObituaryCallbackParams inputParams ) {
    if(inputParams.attacker == GetLocalClientPlayer() && DamageSourceIDToString(inputParams.damageSourceId) == "mp_weapon_sniper")
        thread myOnKillFunction()
}

Note: this is triggered each time a player gets killed in a match, not just by the client player. If you only care about client player's kills, simply check if inputParams.attacker == GetLocalClientPlayer()