CruzerGq Posted March 23, 2017 Share Posted March 23, 2017 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
Ayush Rathore Posted March 23, 2017 Share Posted March 23, 2017 (edited) 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 March 23, 2017 by Ayush Rathore Link to comment
Gordon_G Posted March 23, 2017 Share Posted March 23, 2017 It'll not work. You should pute =< Instead of >= Else, it'll always put the Novice rank. Link to comment
xeon17 Posted March 23, 2017 Share Posted March 23, 2017 Instead of a timer use onElementDataChange, better for performance. Link to comment
itHyperoX Posted March 23, 2017 Share Posted March 23, 2017 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
Ayush Rathore Posted March 23, 2017 Share Posted March 23, 2017 (edited) 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 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 March 23, 2017 by Ayush Rathore Link to comment
Gordon_G Posted March 23, 2017 Share Posted March 23, 2017 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
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