Jump to content

help with script


Kenix

Recommended Posts

Here's the script when you touch a knife they give you 1 point kill

and another 1 point in death.

script does not work.

  
function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) 
    if ( weapon == 4 ) then                  
     if attacker then 
            if attacker ~= source then 
                -- killer killed victim 
                getElementData(attacker, "kills" + 1) 
                outputChatBox ("1")  
                getElementData(source, "deaths" + 1) 
                outputChatBox ("2")  
                 
            end 
        end  
             
      
    end 
         
end 
  
addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) 
  

Link to comment

Try this..

function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) 
  
    if weapon == 4 then 
        local getElementKills = getElementData ( attacker, "data.kills" ) or 0 
        local getElementDeaths = getElementData ( source, "data.deaths" ) or 0 
        setElementData ( attacker, "data.kills", getElementKills + 1 ) 
        setElementData ( source, "data.deaths", getElementDeaths + 1 ) 
         
    end 
     
end 
  
addEventHandler ( "onPlayerDamage", root, addTabStaticsInfect ) 

Link to comment
Try this..
function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) 
  
    if weapon == 4 then 
        local getElementKills = getElementData ( attacker, "data.kills" ) or 0 
        local getElementDeaths = getElementData ( source, "data.deaths" ) or 0 
        setElementData ( attacker, "data.kills", getElementKills + 1 ) 
        setElementData ( source, "data.deaths", getElementDeaths + 1 ) 
         
    end 
     
end 
  
addEventHandler ( "onPlayerDamage", root, addTabStaticsInfect ) 

I need to use existing elementData kills and deaths.

Link to comment
  • Moderators

If you want to keep yours elementData, try this:

function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) 
    if attacker then              
        if attacker ~= source then 
            if ( weapon == 4 ) then    
                -- killer killed victim with a knife 
                local playerKills = getElementData(attacker, "kills" ) or 0 
                local playerDeaths = getElementData(source, "deaths" ) or 0 
                playerKills = playerKills+1 
                playerDeaths = playerDeaths+1 
                setElementData( attacker, "kills", playerKills ) 
                setElementData( source, "deaths", playerDeaths ) 
               outputChatBox( "Killer's kills:"..playerKills.."  |  player's deaths: "..playerDeaths )  
            end 
        end  
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) 

It should work I think.

EDIT: I tested it and there was an error. Now this script works very well, you juste have to copy-paste :wink:

Link to comment
If you want to keep yours elementData, try this:
function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) 
    if attacker then              
        if attacker ~= source then 
            if ( weapon == 4 ) then    
                -- killer killed victim with a knife 
                local playerKills = getElementData(attacker, "kills" ) or 0 
                local playerDeaths = getElementData(source, "deaths" ) or 0 
                playerKills = playerKills+1 
                playerDeaths = playerDeaths+1 
                setElementData( attacker, "kills", playerKills ) 
                setElementData( source, "deaths", playerDeaths ) 
               outputChatBox( "Killer's kills:"..playerKills.."  |  player's deaths: "..playerDeaths )  
            end 
        end  
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) 

It should work I think.

EDIT: I tested it and there was an error. Now this script works very well, you juste have to copy-paste :wink:

it works thank you very much we (:

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