local global_map_storages = {
{45001, "thais"},
{45002, "carlin"},
{45003, "ab'dendriel"},
{45004, "venore"},
{45005, "kazordoon"}
}
function onThink(interval)
local vote_count, maps = 0, "" -- will hold information to be used later in script.
for i = 1, #global_map_storages do -- will loop through the main table above. (going down the list 1 by 1)
local temp_count = getGlobalStorageValue(global_map_storages[i][1]) -- finds the current value of a global storage in the above table.
if vote_count ~= 0 and temp_count == vote_count then -- if the global storage is equal to the current 'maximum' votes...
if maps ~= "" then
maps = maps .. ", " -- adds a comma to separate multiple cities
end
maps = maps .. global_map_storages[i][2] -- stores the city name for later use, along with previous city names.
elseif temp_count > vote_count then -- if the global storage is greater then the current 'maximum' votes...
vote_count = temp_count -- update the highest vote total
maps = global_map_storages[i][2] -- update the current map 'selected'
end
setGlobalStorageValue(global_map_storages[i][1], -1) -- reset the global storage, so votes can be cast again
end
if maps == "" then -- if no votes were cast, then no city was selected, so update text to advise.
maps = "not enough votes to choose a map"
end
print("vote_count = " .. vote_count .. " | maps = " .. maps .. "") -- print to console the highest vote found, and the city or cities that held the highest amount.
return true
end