Jump to content

Stat system


Recommended Posts

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 
); 

Link to comment

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

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 
); 
  

Link to comment

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 
); 

Link to comment

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

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 
); 

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