Jump to content

[Solved] Damage canceling


ManeXi

Recommended Posts

Posted (edited)

I want to cancel damage in every weapon with some exceptions, but because god wanted RPG(35) and RPG-HS(36) can't be exceptions.

function cancelPedDamage ( attacker, weapon ) --This is to cancel the damage 
    if not (weapon == 16) or (weapon == 35) or (weapon == 36) then 
        cancelEvent() 
    end 
    outputChatBox("Player Weapon is: "..getPedWeapon(attacker, weapon).."") 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelPedDamage ) 

In other words, damage is not cancelled in Grenade(16) but yes in RPG(35) and in RPG-HS(36)

And for another unknown reason I can't output the weapon that the attacker used it puts:

ERROR: damage_c.lua:5: attempt to concatenate a boolean value 

Edited by Guest

Interested on a paid 3D modder?

My Skype: awdsasda.sdasdaad

Posted

this

.."" 

isn't needed only if you want to continue a string afterwards.

getPedWeapon's 2nd argument is weapon SLOT and you provide the weapon ID, that's not the same.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
this
.."" 

isn't needed only if you want to continue a string afterwards.

getPedWeapon's 2nd argument is weapon SLOT and you provide the weapon ID, that's not the same.

No, sir.

https://wiki.multitheftauto.com/wiki/On ... ayerDamage

weapon: An integer representing the weapon ID the attacker used

And I still getting the output error

Interested on a paid 3D modder?

My Skype: awdsasda.sdasdaad

Posted
this
.."" 

isn't needed only if you want to continue a string afterwards.

getPedWeapon's 2nd argument is weapon SLOT and you provide the weapon ID, that's not the same.

No, sir.

https://wiki.multitheftauto.com/wiki/On ... ayerDamage

weapon: An integer representing the weapon ID the attacker used

And I still getting the output error

Uhm, yes

https://wiki.multitheftauto.com/wiki/GetPedWeapon

Optional Arguments 
weaponSlot: an integer representing the weapon slot (set to the ped's current slot if not given). 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
function cancelPedDamage ( attacker, weapon ) --This is to cancel the damage 
    if attacker then 
        if not (weapon == 16) or (weapon == 35) or (weapon == 36)  then 
            cancelEvent() 
        end 
    end 
--  outputChatBox("Player Weapon is: "..getPedWeapon(attacker, weapon)) 
end 
addEventHandler ( "onClientPedDamage", getRootElement(), cancelPedDamage ) 
addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelPedDamage ) 

this is my code now, I don't care much about Ped's weapon, but still canceling RPG and RPG-HS damage, I have tried to put special IDs like explosions etc... but nothing

Interested on a paid 3D modder?

My Skype: awdsasda.sdasdaad

  • Moderators
Posted

Explosion damage can't be cancelled, because the weapon is most of the time unknown.

Unless you write a system, that replaces the damage dealing.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
Explosion damage can't be cancelled, because the weapon is most of the time unknown.

Unless you write a system, that replaces the damage dealing.

Couldn't you cancel the shoot event if getPedTarget equals a player?

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

  • Moderators
Posted

Explosions are splash damage and not bullet damage. The use of getPedTarget won't help you.

Only a GTA san damage overwrite would.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

Instead of making a list of exceptions(Grenade, RPG...) I made a list of all the weapons I want to be their damage canceled, now is working, thanks alot, this can be set as solved.

Interested on a paid 3D modder?

My Skype: awdsasda.sdasdaad

Posted
Explosions are splash damage and not bullet damage. The use of getPedTarget won't help you.

Only a GTA san damage overwrite would.

I know but what I ment was if the bullet wasn't fired there wouldn't be no splash damage, so wouldn't it be better to cancel the shooting instead of cancelling the damage and still having the explosion.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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...