Jump to content

GetplayerRank (racefunction)


Klesh

Recommended Posts

I need to ask how i can get the player rank, for example if the player is 1, define that function:

Example script

function(source) 
local pRank = getPlayerRank(source) 
if (pRank == "1") then  
setPlayerMoney(source, 1000)----Its only an example, i need how to call the player rank when its 1. 
end 
end 

That's the correct way? or it have another one more effective?

Link to comment

I want to add that to scoreboard, but does not work.

------------------- 
----DEFINITION---- 
------------------- 
local root = getRootElement() 
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Wins", getRootElement(), 3, .08 )-----| 
------------ 
---WINNER--- 
------------ 
function winHandler(player) 
local pRank = exports["race"]:getPlayerRank(player) 
    if (pRank == "1" or pRank == 1) then 
        setElementData ( pRank, "Wins", ( getElementData ( pRank, "Wins" ) ) + 1 ) 
    end 
end 
addEventHandler("onClientResourceStart", getRootElement(), winHandler) 

Link to comment

Should work

Server side

------------------- 
----DEFINITION---- 
------------------- 
call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Wins", root, 3, .08 )-----| 
------------ 
---WINNER--- 
------------ 
function winHandler( rank,_ ) 
    if rank == 1 then 
        setElementData ( source, "Wins", tonumber( getElementData ( source, "Wins" ) or 0 ) + 1 ) 
    end     
end 
addEventHandler( "onPlayerFinish",root,winHandler ) 
  

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