function OnGameEnd takes nothing returns nothing
local integer PlayerNumber = 1
local integer WinnerPoints
local integer PlayerPoints
local player Winner = Player(0)
local force TieForce = CreateForce()
loop
exitwhen PlayerNumber > 11
set WinnerPoints = GetPlayerPoints(Winner)
set PlayerPoints = GetPlayerPoints(Player(PlayerNumber))
if PlayerPoints > WinnerPoints then
set Winner = Player(PlayerNumber)
call ForceClear(TieForce)
call ForceAddPlayer(TieForce, Player(PlayerNumber))
elseif PlayerPoints == WinnerPoints then
call ForceAddPlayer(TieForce, Player(PlayerNumber))
endif
set PlayerNumber = PlayerNumber + 1
endloop
if CountPlayersInForceBJ(TieForce) > 1 then
// Whatever you want to do to the players who are tied, add here.
else
call DisplayTextToForce(GetPlayersAll(),GetPlayerName(Winner) + " has won with " + I2S(WinnerPoints) + " points!")
// Whatever you want to do when the winner has been declared, add here.
endif
call DestroyForce(TieForce)
set Winner = null
set TieForce = null
endfunction