Feche1320 Posted December 26, 2010 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 www.host-ar.com.ar
dzek (varez) Posted December 26, 2010 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. Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Feche1320 Posted December 26, 2010 Author 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. www.host-ar.com.ar
BinSlayer1 Posted December 26, 2010 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
Feche1320 Posted December 27, 2010 Author Posted December 27, 2010 Still doesn't work, it says rank 1 for everyone www.host-ar.com.ar
J.S. Posted December 27, 2010 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) Kinetic Roleplay Forums || Mantis || YouTube
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