Jump to content

this is correct rank?


Fabioxps

Recommended Posts

Posted (edited)

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
Posted

Why ask if this is correct? If not working tell us what the problem is.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
Why ask if this is correct? If not working tell us what the problem is.

I want to appear the nick of the player who is in the rank and not on who types the command

Posted

You want to get all the online player ranks?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted
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 ;)

INVINCIBLE's Script Page:

My Scripts Page

---------------------

User Profile script : %100 - Show pictures and pm me :)

User profile system (1)

User profile system (2)

-------------

Need paid scripter just pm me i will accept every job!

  • 3 weeks later...
Posted

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 
) 

Posted

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) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted
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

Posted

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) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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