JoZeFSvK Posted December 15, 2012 Share Posted December 15, 2012 hey i have problem all players recieved cash and first nothing function earnMoney(thePlayer) local position = getAliveRacePlayers() if not (position <= 0) then if getPlayerCount() >= 3 then local pAlive = getAliveRacePlayers() local pDead = getDeadRacePlayers() local maxCash = 21*(pAlive+pDead) local portion = 0 local finalCash = 0 if not (position == 1) then portion = math.ceil(maxCash/(pAlive+pDead-1)) finalCash = math.ceil(portion*(pDead)) else finalCash = maxCash end local playerCash = loadPlayerData(thePlayer,"cash") outputChatBox("#0095FF* #FFFFFFYou have recieved $" .. finalCash .. "!",thePlayer,255,255,255,true) savePlayerData(thePlayer,"cash",playerCash +finalCash) outputDebugString("Final cash for player "..getPlayerName(thePlayer)..": "..finalCash) totalMoneyEarnedAdd(thePlayer,finalCash,finalCash) else outputChatBox("#0095FF* #FFFFFFNot enough players to earn money - #ABCDEF3 #FFFFFFrequired.",thePlayer,255,255,255,true) return end scoreboardRefresh(thePlayer) refreshStats(thePlayer) progressBarUpdate(thePlayer) totalMoneyAchievements(thePlayer) end end Link to comment
Techial Posted December 15, 2012 Share Posted December 15, 2012 EDIT: Sorry, the problem is in your eventHandler. Because, I guess this one checks when a player is wasted. if(position == 2) then for i,v in ipairs(pAlive) do --Code here (Give the money to player v) end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now