Actions on death

hi guys i would like to do something on player death. for example in my server i created a script for mount unmount weapons so the typical WEAPON_PISTOL (weapon) became the item (PISTOL) and this also prevent the item from duplicate when looted so now i would like to create something to automatically unmount weapons on death is that possible?

You could possibly set up an event handler using either onPlayerDied or onPlayerKilled, then do what you want from within the functions.

In a clientside script, you could put:

AddEventHandler( "baseevents:onPlayerDied", function()
    -- do stuff
end )

i try it

how can i say if player is dead and he has the weapon_pistol?

Well the event only gets triggered if the player has actually died, so you shouldn’t need to check again. As for checking if they have weapon_pistol, as far as I’m aware there isn’t a way to check if a player has a specific weapon unless they are actively holding it.

so i tried it and the script does:
remove weapon_pistol
add item pistol

but this happens also if the player doesnt have weapon_pistol
so if you have weapon_pistol mounted it works correctly
is you dont have weapon_pistol it gives u a pistol

:confused: