Jump to content

Help with script


Feche1320

Recommended Posts

Posted

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

Posted

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.

Posted

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) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...