Jump to content

custom damage handler


kaos057

Recommended Posts

Posted

I am trying to make a full MMO with levels, custom armor/weapons, etc. To do this I need to disable default damage and handle it myself in order to take into consideration extra hitpoints and damage modifiers from the custom gear. I know I can disable the damage on client side using onClientPlayerDamage which works for any self inflicted damage but the server side still does damage.

So is there any way to either stop all damage completely or somehow make a player have more hitpoints than others?

Posted

Yes I know that. My question was how to do that if its possible. You cant cancel the server sided damage event as far as i know. So is there any other way to completely cancel damage on server side?

Posted

Try Using this

addEventHandler ( "onPlayerDamage", getRootElement(), cancelEvent ) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

@X-SHADOW: No.

It should also be noted that canceling this event has no effect. Cancel the client-side event onClientPlayerDamage instead.

@kaos057: Use onClientPlayerDamage.

If I helped you, please click the like button on the right ;) Thanks!

Posted

How myonlake said, the onPlayerDamage cannot be canceled (has no effect). So, for solve it, can do:

function SetPlayerInvencible(attacker, attackerweapon, bodypart, loss) 
    setElementHealth(source, getElementHealth(source)+loss) 
addEventHandler("onPlayerDamage", getRootElement(), SetPlayerInvencible) 
 

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

Posted (edited)

To delete player damage use:

addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), cancelEvent )  

To make another damage , you can try this:

setElementHealth ( source, getElementHealth(source) - 20 )  

-- Example

///EDIT

Oh.. someone write this first : |

Edited by Guest
Posted

You can anyways use triggers from server side and vice versa if your scripts won't work without this.

triggerClientEvent 
triggerServerEvent 

If I helped you, please click the like button on the right ;) Thanks!

Posted

There's two ways:

- Use my first example, when you use setElementHealth()

- Use client-side script to use onClientPlayerDamage and trigger using triggerClientEvent().

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...