Jump to content

[Solved] Damage canceling


ManeXi

Recommended Posts

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
Link to comment
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). 

Link to comment
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

Link to comment
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.

Link to comment

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