Jump to content

[HELP]Set player melee damage


joao1234

Recommended Posts

Whenever you attack other player, use the function getElementHealth to get the current health and then use function setElementHealth to set the health to lower, also you might need killPed when the health is low, so you will always have a killer.

Link to comment
  • Moderators

LOL I am thinking back to the day I started to script. This was one of my first scrips, I don't even know if it is still working xD

local weaponsTrue = { [0]=true,[1]=true, [2]=true, [3]=true, [4]=true, [5]=true, [6]=true, [7]=true, [8]=true, [9]=true, [10]=true, [11]=true, [12]=true, [14]=true, [15]=true } 
local weaponsDamage = { [0]=1,[1]=1, [2]=1, [3]=1, [4]=1, [5]=1, [6]=1, [7]=1, [8]=1, [9]=1, [10]=1, [11]=1, [12]=1, [14]=1, [15]=1 } 
function playerDamage ( attacker, weapon, bodypart, loss )  
    if weaponsTrue[weapon] then 
        local health = getElementHealth(source) 
        local Dloss = weaponsDamage[weapon] 
        if health-Dloss > 0 then 
            setElementHealth ( source,  health-Dloss) 
        else 
            killPed(source) 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage ) 

Note: you have to edit the damage by your self.

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