Memory Posted September 26, 2012 Share Posted September 26, 2012 Hi, have problem with points system, point in DM, DD maps got second player, not winner. Code function check() local alive = getAlivePlayers() local acc = getPlayerAccount( source ) local ptzData = getAccountData( acc, "Points" ) if (#alive == 1) then local player = alive[1] local playerCount = getPlayerCount() local pointsToWin = playerCount *10 if ptzData then setAccountData( acc, "Points", ptzData + pointsToWin ) else setAccountData( acc, "Points", pointsToWin ) end outputChatBox("#FF9900[Points]#FFFFFF " .. getPlayerName(player).. " #00FF00 receive "..pointsToWin, getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerWasted",getRootElement(),check) For money work, money got winner function check() local alive = getAlivePlayers() if (#alive == 1) then local player = alive[1] givePlayerMoney(player,300) outputChatBox("#FFFFFF"..getPlayerName(player).." #00FF00has earned $300 for being the last player alive",getRootElement(),255,255,255, true) end end addEventHandler("onPlayerWasted",getRootElement(),check) Link to comment
DiSaMe Posted September 26, 2012 Share Posted September 26, 2012 Because 'acc' is account of 'source' and 'source' is the player who was wasted. Instead, you need to get account of 'player' whom you get from 'alive' table. Link to comment
Memory Posted September 26, 2012 Author Share Posted September 26, 2012 Thanks, work function check() local alive = getAlivePlayers() local player = alive[1] local acc = getPlayerAccount( player ) local ptzData = getAccountData( acc, "Points" ) if (#alive == 1) then local playerCount = getPlayerCount() local pointsToWin = playerCount *10 if ptzData then setAccountData( acc, "Points", ptzData + pointsToWin ) else setAccountData( acc, "Points", pointsToWin ) end outputChatBox("#FF9900[Points]#FFFFFF " .. getPlayerName(player).. " #00FF00 receive "..pointsToWin, getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerWasted",getRootElement(),check) 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