table.insert(players, {
--steamID32 required in here
steamID32 = PlayerResource:GetSteamAccountID(playerID),
--old stats
ph = GetHeroName(playerID), --Hero by its short name
pk = hero:GetKills(), --Number of kills of this players hero
pd = hero:GetDeaths(), --Number of deaths of this players hero
nt = GetNetworth(hero), --Sum of hero gold and item worth
il = GetItemNameList(hero),
heroID = PlayerResource:GetSelectedHeroID(playerID),
level = PlayerResource:GetLevel(playerID),
kills = PlayerResource:GetKills(playerID),
assists = PlayerResource:GetAssists(playerID),
deaths = PlayerResource:GetDeaths(playerID),
gold = PlayerResource:GetGold(playerID),
denies = PlayerResource:GetDenies(playerID),
lastHits = PlayerResource:GetLastHits(playerID),
stunAmount = PlayerResource:GetStuns(playerID),
goldSpentBuyBack = PlayerResource:GetGoldSpentOnBuybacks(playerID),
goldSpentConsumables = PlayerResource:GetGoldSpentOnConsumables(playerID),
goldSpentItems = PlayerResource:GetGoldSpentOnItems(playerID),
goldSpentSupport = PlayerResource:GetGoldSpentOnSupport(playerID),
numPurchasedConsumables = PlayerResource:GetNumConsumablesPurchased(playerID),
numPurchasedItems = PlayerResource:GetNumItemsPurchased(playerID),
totalEarnedGold = PlayerResource:GetTotalEarnedGold(playerID),
totalEarnedXP = PlayerResource:GetTotalEarnedXP(playerID),
itemNameList = GetItemNameList(hero),
ablityNameList = GetAbilityNameList(hero),
playerTeamName = teamname,
})
function GetHeroName( playerID )
local heroName = PlayerResource:GetSelectedHeroName( playerID )
heroName = string.gsub(heroName,"npc_dota_hero_","") --Cuts the npc_dota_hero_ prefix
return heroName
end
function GetNetworth( hero )
local gold = hero:GetGold()
-- Iterate over item slots adding up its gold cost
for i=0,15 do
local item = hero:GetItemInSlot(i)
if item then
gold = gold + item:GetCost()
end
end
return gold
end
function GetItemNameList(hero)
local item
local itemID
local itemTable = {}
local itemList
for i=0,5 do
item = hero:GetItemInSlot(i)
if item then
itemID = item:GetAbilityName()
itemID = string.gsub(itemID,"item_","")
if itemID then
table.insert(itemTable,itemID)
end
end
end
table.sort(itemTable)
itemList = table.concat(itemTable, ",")
return itemList
end
function GetAbilityNameList( hero )
local abilityName
abilityData = {}
local abilityCount = 0
while abilityCount < 16 do
local ab = hero:GetAbilityByIndex(abilityCount)
if IsValidEntity(ab) then
abilityName = ab:GetAbilityName()
table.insert(abilityData,abilityName)
end
abilityCount = abilityCount + 1
end
table.sort(abilityData)
local abilityNameList = table.concat(abilityData, ",")
return abilityNameList
end
Console Log:
schema.lua: