Jump to content

this is correct rank?


Fabioxps

Recommended Posts

this is correct?

addCommandHandler ( "rank", 
function(rankPlayersWasted) 
local rank = exports.race:getPlayerRank(rankPlayersWasted)+0 
if (rank == 1) then 
outputChatBox("#ffffff1º "..getPlayerName(rankPlayersWasted).." Winner!",getRootElement(),0,0,0,true) 
elseif(rank == 2) then 
outputChatBox("#ffffff1º "..getPlayerName(rankPlayersWasted).." Second!",getRootElement(),0,0,0,true) 
elseif(rank == 3) then 
outputChatBox("#ffffff1º "..getPlayerName(rankPlayersWasted).." Third!",getRootElement(),0,0,0,true) 
end 
end) 

Edited by Guest
Link to comment
addCommandHandler ( "rank", 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            local rank = exports.race:getPlayerRank ( player ) 
            if ( rank == 1 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Winner!", root, 0, 0, 0, true ) 
            elseif ( rank == 2 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Second!", root, 0, 0, 0, true ) 
            elseif ( rank == 3 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Third!", root, 0, 0, 0, true ) 
            end 
        end 
    end 
) 

Link to comment

I'm getting both players won

addCommandHandler ( "rank", 
    function (player) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            local rank = exports.race:getPlayerRank ( player ) 
            if ( rank == 1 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Winner!", root, 0, 0, 0, true ) 
            elseif ( rank == 2 ) then 
                outputChatBox ( "#ffffff2º ".. getPlayerName ( player ) .." Second!", root, 0, 0, 0, true ) 
            elseif ( rank == 3 ) then 
                outputChatBox ( "#ffffff3º ".. getPlayerName ( player ) .." Third!", root, 0, 0, 0, true ) 
            end 
        end 
    end 
) 
  

mtascreen20130402165501.png

Link to comment
addCommandHandler ( "rank", 
    function ( player ) 
            local rank = getElementData(player,"race rank") 
            if ( rank == 1 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Winner!", root, 0, 0, 0, true ) 
            elseif ( rank == 2 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Second!", root, 0, 0, 0, true ) 
            elseif ( rank == 3 ) then 
                outputChatBox ( "#ffffff1º ".. getPlayerName ( player ) .." Third!", root, 0, 0, 0, true ) 
            end 
    end 
) 

Try this ;)

Link to comment
  • 3 weeks later...

getPlayerName(player) is wrong, someone help me please

addCommandHandler ( "rank", 
    function ( player ) 
            local rank = getElementData(player,"race rank") 
            if ( rank == 3 ) then 
                outputChatBox ( "#ffffff3º "..getPlayerName(player).." Winner!", root, 0, 0, 0, true ) 
            end 
    end 
) 

Link to comment

try this:

addCommandHandler ( "rank",function(source) --source is the player who entered the command 
    for _,p in ipairs(getElementsByType("player"))do 
        local rank = exports.race:getPlayerRank(p) 
        local name = getPlayerName(p) 
        if rank == 1 then 
            outputChatBox("#ffffff1º "..name.." Winner!",root,0,0,0,true) 
        elseif rank == 2 then 
            outputChatBox("#ffffff1º "..name.." Second!",root,0,0,0,true) 
        elseif rank == 3 then 
            outputChatBox("#ffffff1º "..name.." Third!",root,0,0,0,true) 
        end 
    end 
end) 

Link to comment

try this:

addCommandHandler ( "rank",function() 
    for _,p in ipairs(getElementsByType("player"))do 
        if exports.race:isPlayerFinished(p) then 
            local rank = exports.race:getPlayerRank(p) 
            local name = getPlayerName(p) 
            if rank == 1 then 
                outputChatBox("#ffffff1º "..name.." Winner!",root,0,0,0,true) 
            elseif rank == 2 then 
                outputChatBox("#ffffff1º "..name.." Second!",root,0,0,0,true) 
            elseif rank == 3 then 
                outputChatBox("#ffffff1º "..name.." Third!",root,0,0,0,true) 
            end 
        end 
    end 
end) 

We needed to check if they're finished...

Link to comment
try this:
addCommandHandler ( "rank",function() 
    for _,p in ipairs(getElementsByType("player"))do 
        if exports.race:isPlayerFinished(p) then 
            local rank = exports.race:getPlayerRank(p) 
            local name = getPlayerName(p) 
            if rank == 1 then 
                outputChatBox("#ffffff1º "..name.." Winner!",root,0,0,0,true) 
            elseif rank == 2 then 
                outputChatBox("#ffffff1º "..name.." Second!",root,0,0,0,true) 
            elseif rank == 3 then 
                outputChatBox("#ffffff1º "..name.." Third!",root,0,0,0,true) 
            end 
        end 
    end 
end) 

We needed to check if they're finished...

not working

Link to comment

try this then:

addCommandHandler ( "rank",function() 
    for _,p in ipairs(getElementsByType("player"))do 
        local finished = exports.race:isPlayerFinished(p) or getElementData(p,"race.finished") 
        if finished then 
            local rank = exports.race:getPlayerRank(p) or getElementData(p,"race rank") 
            local name = getPlayerName(p) 
            if rank == 1 then 
                outputChatBox("#ffffff1º "..name.." Winner!",root,0,0,0,true) 
            elseif rank == 2 then 
                outputChatBox("#ffffff1º "..name.." Second!",root,0,0,0,true) 
            elseif rank == 3 then 
                outputChatBox("#ffffff1º "..name.." Third!",root,0,0,0,true) 
            end 
        end 
    end 
end) 

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