Checking if keys in dictionary all have the same integer value

So I have a dictionary that contains two teams, and their total kill count as the values. How would I determine if all the keys found in the dictionary all contain the same value?

I need to know this so I can script a stalemate.

1 Like

You can keep track of the integers by creating an array. For 3+ teams, you can do:

local KillCounts = {};

for i, v in pairs(Dictionary) do
    local ispresent= false;
    for i = 1,# KillCounts do
        if (KillCounts[i] == v) then
            ispresent= true -- Killcount is present in table
            break; -- Stop the loop
    if (ispresent) then -- If the same killcount is present
        -- do something
        table.inset(v) -- Add the kill count into the table

That is scaleable for multiple teams, if you only have two teams. You could just compare both dictionary values dirrectly.

if (Dictionary[Team1] == Dictionary[Team2]) then
    -- Identical kill count, do something
1 Like

Also, the line where you add the kill count into the table should be

table.insert(KillCount, v)


1 Like

Haha yes my bad, darn typos! :slight_smile:

1 Like