Klesh Posted January 8, 2012 Share Posted January 8, 2012 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
Castillo Posted January 8, 2012 Share Posted January 8, 2012 function(player) local pRank = exports["race"]:getPlayerRank(player) if (pRank == "1" or pRank == 1) then setPlayerMoney(player, 1000)----Its only an example, i need how to call the player rank when its 1. end end Link to comment
Klesh Posted January 9, 2012 Author Share Posted January 9, 2012 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
Castillo Posted January 9, 2012 Share Posted January 9, 2012 That's just a mess. You want to set +1 win point to the player with rank #1? Link to comment
Klesh Posted January 9, 2012 Author Share Posted January 9, 2012 I want to set +1 win then add to scoreboard, the save system i will do by myself. Link to comment
Castillo Posted January 9, 2012 Share Posted January 9, 2012 Well, I suggest you to think when you're scripting, because you're just trying to set/get element data into a string, number value. Link to comment
Klesh Posted January 9, 2012 Author Share Posted January 9, 2012 Thanks, now i do scripts and fixing them by myself, takes time, but i do it, and helping others i learn more. Link to comment
Kenix Posted January 9, 2012 Share Posted January 9, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now