Jump to content

Help with script


Feche1320

Recommended Posts

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

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

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...