How to use OnDamage events on player/party members?

As the title says, i’m trying to apply a poison whenever a creature attacks and damages the player.

Why not just apply the poison to the creature’s weapon as an On Monster Hit ability?

Is it a specific creature or any creature?

Any creature that haves that ability which is granted by a custom class that i’m working on.

That’s the solution that i applied but i wanted to see if it was possible to make it closer to the PnP ability, this is the PnP ability:

Poison Blood: While you are bound to Eurynome, your blood becomes poisonous. Any creature that ingests it (by either making a bite attack against you or swallowing you whole) must immediately make a successful Fortitude save or take 1d6 points of damage. After 1 minute, the creature must make another Fortitude save at the same DC or take another 1d6 points of damage per three effective binder levels you possess (maximum 5d6). Each bite attack (or each round that you remain in the creature’s gullet) poisons the creature anew, forcing a new round of saving throws. Your poison blood becomes inert 1 minute after leaving your body.

My NWN2 version:

Poison Blood: While you are bound to Eurynome, your blood becomes poisonous. You can cause 2 hit points of damage to yourself to coat a non-bludgeoning weapon or projectile with your blood. A creature that is struck with it must make a successful Fortitude save or take 1d6 points of acid damage, plus an additional 1d6 points of acid damage per three effective binder levels you possess beyond 7th (maximum 5d6). After 1 minute, the creature must make another Fortitude save at the same DC or suffer the same consequences. Your poison blood last 3 rounds on your weapon or projectile.

Ah, you need to have the PC OnDamage event and if the PC has the trait, the creature attacking gets poisoned.
My first thought would be the “default” script, though I know some people don’t like to use it.
If you don’t already have a custom script named “default”, you can make a new one. If you already have a custom script with the name, you would add the functions to it.
This would go in the void main() section.
The “default” script fires on most events for the PC and is run by the PC. OBJECT_SELF is the PC

//Some bit to get the damaging creature
object oCreature = GetLastDamager(OBJECT_SELF);
int nPAbility = ABILITY_NAME;//Whatever that ability is going to be called 
                       //- or the actual number if you know it
int nPoison = GetHasFeat(nPAbility, OBJECT_SELF);//Check if the PC has the ability
if(nPoison==TRUE)//If so, poison the attacker
    {
    effect ePoison = EffectPoison(POISON_ARSENIC);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, ePoison, oCreature);
    }