you can simply count them yourself if you set up an easy function:
function getAliveRacePlayers()
local playertable = {} -- create an empty table
for index,player in ipairs(getElementsByType("player")) do -- loop through all players
if getElementData(player,"state") == "alive" then -- check if race considers them alive
table.insert(playertable,player) -- insert the player in our table if he's alive
end
end
return playertable -- return the table to whatever called the function
end
all you need to do then is this to check how many players are alive:
#getAliveRacePlayers() -- # is used to get the length of stuff, in case of a table it gives you the amount of entries
you can then use it like this:
function playerCheck()
local players = getElementsByType("player")
local aliveplayers = getAliveRacePlayers()
givePlayerMoney(source,100*(#players-#aliveplayers)) -- give a player 100$ per player they beat
end
addEventHandler("onPlayerWasted",getRootElement(),playerCheck)