Feche1320 Posted December 26, 2010 Share Posted December 26, 2010 I have this: addEvent("onPostFinish") function OnMapFinish() for i, player in ipairs(getElementsByType('player')) do local rank = getPlayerRank(player) if(rank == 1) then givePlayerMoney(player, 1500) outputChatBox('Rank 1:' .. getPlayerName(player).. '') end if(rank == 2) then givePlayerMoney(player, 1500) outputChatBox('Rank 2:' .. getPlayerName(player).. '') end end end addEventHandler("onPostFinish", getRootElement(), OnMapFinish) But it gives me for all players rank 1, why it isn't working? Thanks Link to comment
dzek (varez) Posted December 26, 2010 Share Posted December 26, 2010 post your getPlayerRank function. also - in this way, ranks won't be sorted from 1 to X, but will be displayed in player join order probably. Link to comment
Feche1320 Posted December 26, 2010 Author Share Posted December 26, 2010 This is: function getPlayerRank(player) if not g_CurrentRaceMode or not g_CurrentRaceMode:isRanked() then return false end return g_CurrentRaceMode:getPlayerRank(player) end It's the one that comes with the race gamemode. Link to comment
BinSlayer1 Posted December 26, 2010 Share Posted December 26, 2010 Instead of: local rank = getPlayerRank(player) use this: local rank = exports.race:getPlayerRank(player) I just read on https://wiki.multitheftauto.com/wiki/RU/Resource:Race that getPlayerRank is an exported function Ooh and delete your getPlayerRank function Link to comment
Feche1320 Posted December 27, 2010 Author Share Posted December 27, 2010 Still doesn't work, it says rank 1 for everyone Link to comment
J.S. Posted December 27, 2010 Share Posted December 27, 2010 No need to bump, when someone knows an answer they'll give it to you for i, player in ipairs(getElementsByType('player')) do is a fishy looking line. Try this: addEvent("onPostFinish") function OnMapFinish() for i,v in ipairs(getElementsByType('player')) do local rank = getPlayerRank(v) if(rank == 1) then givePlayerMoney(v, 1500) outputChatBox('Rank 1:' .. getPlayerName(v).. '') end if(rank == 2) then givePlayerMoney(v, 1500) outputChatBox('Rank 2:' .. getPlayerName(v).. '') end end end addEventHandler("onPostFinish", getRootElement(), OnMapFinish) 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