Sory here is the full code!
function getAliveGuys ( mode )
if not mode then return end
if mode == 1 then
pAlive = { };
for _, player in ipairs ( getElementsByType ( "player" ) ) do
if ( getElementData ( player, "state" ) == "alive" ) then
table.insert ( pAlive, player );
end
end
return pAlive;
elseif mode == 2 then
return #pAlive;
elseif mode == 3 then
if pAlive then
pAlive = nil;
end
return false
end
end
function getDeadGuys ( )
local pDead = 0
for _, player in ipairs ( getElementsByType ( "player" ) ) do
if getElementData ( player, "state" ) == "dead" then
pDead = pDead + 1;
end
end
return pDead;
end
function giveMoneyWinDie ( )
local account = getPlayerAccount ( source );
local playersAlive = getAliveGuys ( 2 );
local playersDead = getDeadGuys ( );
local pAll = playersAlive + playersDead;
local checkYourPos = pAll - playersDead;
local pos = nil;
if tonumber ( checkYourPos ) == 1 then pos = 1 else pos = checkYourPos + 1; end
if tonumber ( checkYourPos ) == 2 then pos = 2; end
if pos == 1 or pos == 21 or pos == 31 then
posName = "st";
elseif pos == 2 or pos == 22 or pos == 32 then
posName = "nd";
elseif pos == 3 or pos == 23 or pos == 33 then
posName = "rd";
else
posName = "th";
end
if not getElementData ( source, "gotMoney" ) then
local mother = getPlayerCount ( )
if mother == 1 then
outputChatBox ( "* There are #abcdef2#FFFFFF or more players #abcdefneeded #FFFFFFto earn money!",source, 255, 255, 255, true );
else
local money = math.ceil ( getPlayerCount ( ) * 50 / pos );
givePlayerMoney ( source, money );
outputChatBox ( "* You were #abcdef[#ff0000" .. pos .. posName .. "#abcdef]#ffffff and #abcdefearned #ffffff" .. money .. "#00ff00$!", source, 255, 255, 255, true );
local hi = getPlayerName(source)
outputChatBox ( "* "..hi.."#ffffff was #abcdef[#ff0000" .. pos .. posName .. "#abcdef]",g_Root, 255, 255, 255, true );
setElementData ( source, "gotMoney", true );
if account then
setAccountData ( account, "money", tostring ( getPlayerMoney ( source ) ) );
end
end
end
end
addEventHandler ( "onPlayerWasted", root , giveMoneyWinDie )