E-mail Posted September 3, 2011 Share Posted September 3, 2011 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) Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 You have taken this from another topic, but you forgot to remove code line numbers... post the original topic link. Link to comment
E-mail Posted September 3, 2011 Author Share Posted September 3, 2011 This is the original topic viewtopic.php?f=91&t=34834 Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 (edited) 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 September 3, 2011 by Guest Link to comment
E-mail Posted September 3, 2011 Author Share Posted September 3, 2011 i dont want it /stats show stats can you set it bing key F7 show stats Please so i can test it Link to comment
JR10 Posted September 3, 2011 Share Posted September 3, 2011 addEventHandler("onPlayerLogin", root, function() bindKey(source,"F7","down",getPlayerStats) end ) Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 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
E-mail Posted September 3, 2011 Author Share Posted September 3, 2011 one last Help Please if Playr press key F7 and he not login outPutChatBox("Please Login to see your stats !")255,255,0 Please add it to script Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 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
E-mail Posted September 3, 2011 Author Share Posted September 3, 2011 /debugscript show attempt to perform arithmetic on a nill value ? Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 Would you tell me in which line? I'm not telephatic you know? Link to comment
E-mail Posted September 3, 2011 Author Share Posted September 3, 2011 Thank you very much working, thanks to you! I want to ask you a small service can you make /top5 show on chat the top 5 Players Made it for me if I would be grateful to you Thx Link to comment
Castillo Posted September 3, 2011 Share Posted September 3, 2011 My answer is No, don't you think you are being abussive? this is not a place where you requests and you get it done, start learning how to script by yourself. https://wiki.multitheftauto.com/wiki/Main_Page Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now