Had to write this code for my server because when player PVP they die faster than they should, so i gave players protection through this code depending on their vocation, so this code won't work verses monsters only players, you can easily change it by removing the if function i will show you it...
otland.net