Jump to content

[Help] Rank System


CruzerGq

Recommended Posts

Hi all. I'm doing a rank system but it stays in the player's rank rutbe system visitors. The script scoreaboard. What is the fault of ?

function ranks()
for _,player in ipairs(getElementsByType("player")) do	
local getdatax = getElementData( player,"points" )	
if  getdatax  1000 then
setElementData(player,"Rank","Novice")
elseif getdatax >= 10000 then
setElementData(player,"Rank","Rookie")
elseif getdatax >= 100000 then
setElementData(player,"Rank","Active")
elseif getdatax >= 1000000 then
setElementData(player,"Rank","Scholar")
elseif getdatax >= 10000000 then
setElementData(player,"Rank","Master")
end
end
end
setTimer(ranks,500,0)

 

Link to comment
42 minutes ago, CruzerGq said:

Hi all. I'm doing a rank system but it stays in the player's rank rutbe system visitors. The script scoreaboard. What is the fault of ?


function ranks()
for _,player in ipairs(getElementsByType("player")) do	
local getdatax = getElementData( player,"points" )	
if  getdatax  1000 then
setElementData(player,"Rank","Novice")
elseif getdatax >= 10000 then
setElementData(player,"Rank","Rookie")
elseif getdatax >= 100000 then
setElementData(player,"Rank","Active")
elseif getdatax >= 1000000 then
setElementData(player,"Rank","Scholar")
elseif getdatax >= 10000000 then
setElementData(player,"Rank","Master")
end
end
end
setTimer(ranks,500,0)

function ranks()
for _,player in ipairs(getElementsByType("player")) do	
local getdatax = getElementData( player,"points" )	
if getdatax then
getdatax = tonumber(getdatax)
if  getdatax == 1000 then
setElementData(player,"Rank","Novice")
elseif getdatax >= 10000 then
setElementData(player,"Rank","Rookie")
elseif getdatax >= 100000 then
setElementData(player,"Rank","Active")
elseif getdatax >= 1000000 then
setElementData(player,"Rank","Scholar")
elseif getdatax >= 10000000 then
setElementData(player,"Rank","Master")
end
end
end
end
setTimer(ranks,500,0)

 

use my code :)

 

Edited by Ayush Rathore
Link to comment

try this 

 

addEventHandler("onElementDataChange",getRootElement(),
function (dataName,oldValue)
    if getElementType(source) == "player" then
        if dataName == "points" then
                for k, v in ipairs(getElementsByType("player")) do 
                   setElementData(player,"Rank","Novice")
                   elseif getdatax >= 10000 then
                   setElementData(player,"Rank","Rookie")
                   elseif getdatax >= 100000 then
                   setElementData(player,"Rank","Active")
                   elseif getdatax >= 1000000 then
                   setElementData(player,"Rank","Scholar")
                   elseif getdatax >= 10000000 then
                   setElementData(player,"Rank","Master")    
            end
        end
end)

 

Link to comment
2 hours ago, TheMOG said:

try this 

 


addEventHandler("onElementDataChange",getRootElement(),
function (dataName,oldValue)
    if getElementType(source) == "player" then
        if dataName == "points" then
                for k, v in ipairs(getElementsByType("player")) do 
                   setElementData(player,"Rank","Novice")
                   elseif getdatax >= 10000 then
                   setElementData(player,"Rank","Rookie")
                   elseif getdatax >= 100000 then
                   setElementData(player,"Rank","Active")
                   elseif getdatax >= 1000000 then
                   setElementData(player,"Rank","Scholar")
                   elseif getdatax >= 10000000 then
                   setElementData(player,"Rank","Master")    
            end
        end
end)

 

Where is getdatax in the scripts :P:) and btw why you used it for all players as it would increase performance and takes more memory and laggs

addEventHandler("onElementDataChange",getRootElement(),
function (dataName,getdatax)
    if getElementType(source) == "player" then
        local player = source
        if dataName == "points" then
                   if getdatax >= 10000 then
                   setElementData(player,"Rank","Novice")
                   elseif getdatax >= 100000 then
                   setElementData(player,"Rank","Active")
                   elseif getdatax >= 1000000 then
                   setElementData(player,"Rank","Scholar")
                   elseif getdatax >= 10000000 then
                   setElementData(player,"Rank","Master")    
                   end
        end
end)

 

Edited by Ayush Rathore
Link to comment
  1. addEventHandler("onElementDataChange",getRootElement(),
    function (dataName,getdatax)
    if getElementType(source) == "player" then
    local player = source
    if dataName == "points" then
    if getdatax =< 10000 then
    setElementData(player,"Rank","Novice")
    elseif getdatax =< 100000 then
    setElementData(player,"Rank","Active")
    elseif getdatax =< 1000000 then
    setElementData(player,"Rank","Scholar")
    elseif getdatax =< 10000000 then
    setElementData(player,"Rank","Master")
    end
    end
    end)
    This is correct.
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...