Jump to content

Player Status


Dimos7

Recommended Posts

Kills = {} 
Deaths = {} 
Headshot = {} 
Money = {} 
Playtime = {} 
  
exports.scoreboard:scoreboardAddColumn("Kills", 20, root, "Kills", 3) 
exports.scoreboard:scoreboardAddColumn("Deaths", 20, root, "Deaths", 4) 
exports.scoreboard:scoreboardAddColumn("Headshot", 20, root, "Headshot", 5) 
exports.scoreboard:scoreboardAddColumn("Money", 20, root, "Money", 6) 
exports.scoreboard:scoreboardAddColumn("Playtime", 20, root, "Playtime", 9) 
  
  
addEventHandler("onPlayerLogin", root, 
function() 
    for i = 0, Kills do 
        if not Kills[i] then 
            Kills[i] = source 
            setElementData(source, "Kills", i) 
            break; 
        end 
    end 
    for i = 0 , Deaths do 
        if not Deaths[i] then 
           Deaths[i] = source 
           setElementData(source, "Deaths", i) 
           break; 
        end 
    end 
    for i = 0 , Headshot do 
        if not Headshot[i] then 
           Headshot[i] = source 
           setElementData(source, "Headshot", i) 
           break; 
        end 
    end 
    for i = 0, Money do 
        if not Money[i] then 
            Money[i] = source 
            setElementData(source, "Money", i) 
            break; 
        end 
    end 
    for i = 0, Playtime do 
        if not Playtime[i] then 
           Playtime[i] = source 
            local time = getRealTime() 
            local hours = time.hour 
            local minutes = time.minute 
            getTickCount() 
           setElementData(source, "Playtime", i) 
           break; 
        end 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for _, v in ipairs(getElementsByType("player")) do 
        for i = 0, Kills do 
            if not Kills[i] then 
                Kills[i] = v 
                setElementData(v, "Kills", i) 
                break; 
            end 
        end 
        for i = 0, Deaths do 
            if not Deaths[i] then 
                Deaths[i] = v 
                setElementData(v, "Deaths", i) 
                break; 
            end 
        end 
        for i = 0, Headshot do 
            if not Headshot[i] then 
                Headshot[i] = v 
                setElementData(v, "Headshot", i) 
                break; 
            end 
        end 
        for i = 0, Money do 
            if not Money[i] then 
               Money[i] = v 
               setElementData(v, "Money", i) 
               break; 
            end 
        end 
        for i = 0 , Playtime do 
            if not Playtime[i] then 
               Playtime[i] = v 
               local time = getRealTime() 
               local hours = time.hour 
               local minutes = time.minute 
               getTickCount() 
               setElementData(v, "Playtime", i) 
               break; 
            end 
        end 
    end 
end) 
  
function setPlayerStatus(attacker, weapon, bodypart) 
    if attacker then 
       if (getElementType(attacker) == "player") then 
           killPed(source, attacker, weapon) 
           setElementData(attacker, "Kills", Kills + 1) 
           setElementData(source, "Deaths", Deaths + 1) 
       end 
       if bodypart == 9 then 
          killPed(source, attacker, weapon, bodypart) 
          setElementData(attacker, "Headshot", Headshot + 1) 
       end 
    end 
end 
addEventHandler("onPlayerWasted", root, setPlayerStatus) 
  
  
function getPlayerStatus(player) 
    if isElement(player) and getElementType(player) == "player"  and getElementData(player, "Kills") and getElementData(player, "Deaths") and getElementData(player, "Headshot") and getElementData(player, "Money") and getElementData(player, "Playtime") then 
       return getElementData(player, "Kills"), getElementData(player, "Deaths"), getElementData(player, "Headshot"), getElementData(player, "Money"), getElementData(player, "Playtime") 
    end 
end 

error line 60 must be number

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