Jump to content

Stat system


Recommended Posts

Posted

Hello all, i maked this stat system, 1pt for each kill, but sadly it wont work here is the lua

addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 9 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 2 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 8 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 7 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 6 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 5 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 4 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 
  
addEvent( "onPlayerWasted", true ); 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 3 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); 
            end 
        end 
    end 
); 

Posted (edited)

Why not using elseif?

addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if bodypart == 9 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 2 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 8 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 7 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 6 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 5 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 4 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 3 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        end 
    end 
); 

Edited by Guest
Posted

Remove

addEvent( "onPlayerWasted", true ); 

local bodyparts = { [9] = 2, [8] = 1, [7] = 1, [6] = 1, [5] = 1, [4] = 1, [3] = 1 } 
addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
        if killer and killer ~= source then 
            if weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + bodyparts[bodypart] ); 
            end 
        end 
    end 
); 
  

Posted

Try this:

addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
    local weapon = getPedWeapon( source ) 
        if killer and killer ~= source then 
            if bodypart == 9 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 2 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 8 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 7 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 6 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 5 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 4 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 3 and weapon == 22 then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        end 
    end 
); 

Posted (edited)

I'm not sure this will works

addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
    local weapon = getElementType ( "weapon" ) 
        if killer and killer ~= source then 
            if bodypart == 9 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 2 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 8 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 7 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 6 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 5 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 4 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 3 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        end 
    end 
); 

EDITED

Edited by Guest
Posted

try this then :wink:

addEventHandler( "onPlayerWasted", root, 
    function (ammo, killer, weapon, bodypart ) 
    local weapon = getElementType ( "weapon" ) 
        if killer and killer ~= source then 
            if bodypart == 9 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 2 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 8 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 7 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 6 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 5 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 4 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        elseif killer and killer ~= source then 
            if bodypart == 3 and weapon then 
                setPedStat( killer, 69, getPedStat( killer, 69 ) + 1 ); end 
        end 
    end 
); 

Posted

@StevyDK: Will only work with the pistol because it will check if weapon ID is 22, if you want to it for all weapons then remove it.

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