Jump to content

setWeaponProperty don't work


boro

Recommended Posts

Hi all please why this don't work

if i use grenade for zombie kill so grenade still take -80% health but i have set it to -1 how is problem ?

addEventHandler("onResourceStart",resourceRoot, 
    function ( ) 
setWeaponProperty(16, "pro", "damage", 1) 
setWeaponProperty(16, "std", "damage", 1) 
setWeaponProperty(16, "poor", "damage", 1) 
    end 
end 
) 

Link to comment

Try this:

addEventHandler("onResourceStart",resourceRoot, 
function ( ) 
    setWeaponProperty(16, "pro", "damage", 1) 
    setWeaponProperty(16, "std", "damage", 1) 
    setWeaponProperty(16, "poor", "damage", 1) 
end 
) 
  

Link to comment

You can cancelEvent on clientside.

addEventHandler("onClientPlayerDamage", getLocalPlayer(), 
function (attacker, weapon) 
if not weapon then return end 
if weapon == 16 then 
cancelEvent() 
local health = getElementHealth(source) 
setElementHealth(source, health-1) 
end 
end 
) 

Link to comment
  • Moderators

Nope, that isn't going to work. First of all when you get damage, there is most of the time a weapon, and gta will see that was weapon 16. "if not weapon then return end"

and next to that gta/mta does have a very annoying bug. If you set a player his health at the same time he got damaged, his event won't be cancelled.

This works, but I won't say it is the best solution.

  
addEventHandler("onClientPlayerDamage", getLocalPlayer(), 
function (attacker, weapon) 
    if weapon == 16 then 
        setTimer(setMyHealth,50,1) 
        cancelEvent() 
    end 
end 
) 
  
function setMyHealth () 
    local health= getElementHealth(localPlayer) 
    if health-20 > 0 then  
        setElementHealth(localPlayer, health-20) 
    else  
        setElementHealth(localPlayer, 0) 
    end 
end 
  
  
  

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