Jump to content

SoldSnake14 Stats Bug Help me Please!


E-mail

Recommended Posts

Hi all

i have tested soldsnake14 Stats system it dont count kills see

1.addEventHandler("onPlayerLogin",getRootElement(), 
2.function () 
3.    local account = getPlayerAccount(source) 
4.    local kills = getAccountData(account,"kills") 
5.    local deaths = getAccountData(account,"deaths") 
6.    local headshots = getAccountData(account,"headshots") 
7.    if not kills then setAccountData(account,"kills",0) end 
8.    if not deaths then setAccountData(account,"deaths",0) end 
9.    if not headshots then setAccountData(account,"headshots",0) end 
10.end) 
11.  
12.function updatePlayerStats(ammo, attacker, weapon, bodypart) 
13.    local account = getPlayerAccount(attacker) 
14.    if account then 
15.        local kills = getAccountData(account,"kills") 
16.        local headshots = getAccountData(account,"headshots") 
17.        setAccountData(account,"kills",kills+1) 
18.        if bodypart == 9 then 
19.            setAccountData(account,"headshots",headshots+1) 
20.        end 
21.    end 
22.    if not attacker or attacker == source then return end 
23.    local accountS = getPlayerAccount(source) 
24.    if accountS then 
25.        local deaths = getAccountData(accountS,"deaths") 
26.        setAccountData(accountS,"deaths",deaths+1) 
27.        end 
28.    end 
29.end 
30.addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) 
31.  
32.function getPlayerStats(thePlayer) 
33.    local account = getPlayerAccount(thePlayer) 
34.    if account then 
35.        local kills = getAccountData(account,"kills") or 0 
36.        local headshots = getAccountData(account,"headshots") or 0 
37.        local deaths = getAccountData(account,"deaths") or 0 
38.        local ratio = string.format("%.2f", kills / deaths) 
39.        outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) 
40.    end 
41.end 
42.addCommandHandler("stats",getPlayerStats) 

:mrgreen:

Link to comment

Try using this instead:

addEventHandler("onPlayerLogin",getRootElement(), 
function () 
    local account = getPlayerAccount(source) 
    local kills = getAccountData(account,"kills") 
    local deaths = getAccountData(account,"deaths") 
    local headshots = getAccountData(account,"headshots") 
    if not kills then setAccountData(account,"kills",0) end 
    if not deaths then setAccountData(account,"deaths",0) end 
    if not headshots then setAccountData(account,"headshots",0) end 
end) 
  
function updatePlayerStats(ammo, attacker, weapon, bodypart) 
    updateAccountData(getPlayerAccount(source), "deaths", 1) 
    if attacker or attacker == source then 
        local account = getPlayerAccount(attacker) 
        if account and attacker and getElementType(attacker) == "player" then 
            updateAccountData(account, "kills", 1) 
            if bodypart == 9 then 
                updateAccountData(account, "headshots", 1) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) 
  
function getPlayerStats(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account then 
        local kills = getAccountData(account,"kills") or 0 
        local headshots = getAccountData(account,"headshots") or 0 
        local deaths = getAccountData(account,"deaths") or 0 
        local ratio = string.format("%.2f", kills / deaths) 
        outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) 
    end 
end 
addCommandHandler("stats",getPlayerStats) 
  
function updateAccountData(account, dataName, toUpdate) 
    if account then 
        local oldData = getAccountData(account,dataName) 
        setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) 
    end 
end 

Edited by Guest
Link to comment

Ok, here.

addEventHandler("onPlayerLogin",getRootElement(), 
function () 
    local account = getPlayerAccount(source) 
    local kills = getAccountData(account,"kills") 
    local deaths = getAccountData(account,"deaths") 
    local headshots = getAccountData(account,"headshots") 
    if not kills then setAccountData(account,"kills",0) end 
    if not deaths then setAccountData(account,"deaths",0) end 
    if not headshots then setAccountData(account,"headshots",0) end 
end) 
  
addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"F7","down",getPlayerStats) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in pairs(getElementsByType("player")) do 
        bindKey(player,"F7","down",getPlayerStats) 
    end 
end) 
  
function updatePlayerStats(ammo, attacker, weapon, bodypart) 
    updateAccountData(getPlayerAccount(source), "deaths", 1) 
    if attacker or attacker == source then 
        local account = getPlayerAccount(attacker) 
        if account and attacker and getElementType(attacker) == "player" then 
            updateAccountData(account, "kills", 1) 
            if bodypart == 9 then 
                updateAccountData(account, "headshots", 1) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) 
  
function getPlayerStats(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account then 
        local kills = getAccountData(account,"kills") or 0 
        local headshots = getAccountData(account,"headshots") or 0 
        local deaths = getAccountData(account,"deaths") or 0 
        local ratio = string.format("%.2f", kills / deaths) 
        outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) 
    end 
end 
addCommandHandler("stats",getPlayerStats) 
  
function updateAccountData(account, dataName, toUpdate) 
    if account then 
        local oldData = getAccountData(account,dataName) 
        setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) 
    end 
end 

Link to comment

You should learn to do that by yourself as it's really easy to, but this time I'll do it.

addEventHandler("onPlayerLogin",getRootElement(), 
function () 
    local account = getPlayerAccount(source) 
    local kills = getAccountData(account,"kills") 
    local deaths = getAccountData(account,"deaths") 
    local headshots = getAccountData(account,"headshots") 
    if not kills then setAccountData(account,"kills",0) end 
    if not deaths then setAccountData(account,"deaths",0) end 
    if not headshots then setAccountData(account,"headshots",0) end 
end) 
  
addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"F7","down",getPlayerStats) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in pairs(getElementsByType("player")) do 
        bindKey(player,"F7","down",getPlayerStats) 
    end 
end) 
  
function updatePlayerStats(ammo, attacker, weapon, bodypart) 
    updateAccountData(getPlayerAccount(source), "deaths", 1) 
    if attacker or attacker == source then 
        local account = getPlayerAccount(attacker) 
        if account and attacker and getElementType(attacker) == "player" then 
            updateAccountData(account, "kills", 1) 
            if bodypart == 9 then 
                updateAccountData(account, "headshots", 1) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerWasted",getRootElement(),updatePlayerStats) 
  
function getPlayerStats(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if not isGuestAccount(account) then 
        local kills = getAccountData(account,"kills") or 0 
        local headshots = getAccountData(account,"headshots") or 0 
        local deaths = getAccountData(account,"deaths") or 0 
        local ratio = string.format("%.2f", kills / deaths) 
        outputChatBox("[sTATS]".. getPlayerName(thePlayer) .."'s Stats: Kills: ".. tostring(kills) .." (".. tostring(headshots) .." Headshots), ".. tostring(deaths) .." Deaths, Ratio: ".. tostring(ratio).."", getRootElement(), 255, 255, 0) 
    else 
       outputChatBox("[sTATS] You must be logged in able to see your stats.",thePlayer,255,0,0) 
    end 
end 
addCommandHandler("stats",getPlayerStats) 
  
function updateAccountData(account, dataName, toUpdate) 
    if account then 
        local oldData = getAccountData(account,dataName) 
        setAccountData(account,tostring(dataName),tonumber(oldData)+tonumber(toUpdate)) 
    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...