[SR]mR.EmiN Posted May 7, 2011 Posted May 7, 2011 function getPlayerPoints (thePlayer) local Points = loadPlayerData (thePlayer,"wins") if (Points <= 0 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 100 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <=250 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 500 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 1000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 2500 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 5000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 10000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 50000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points <= 1000000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) end end Line 3 error pls help attempt to compare number with error
proracer Posted May 7, 2011 Posted May 7, 2011 This is just ridicolous.We need loadPlayerData function and savePlayerData function. Did you mean getElementData and setElementData?
Jaysds1 Posted May 8, 2011 Posted May 8, 2011 I think you did this wrong (Points <= 0 ) Try this function getPlayerPoints (thePlayer) local Points = loadPlayerData (thePlayer,"wins") if (Points > 0 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 100 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 250 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 500 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 1000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 2500 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 5000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 10000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 50000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 1000000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) end end ,
NeXTreme Posted May 8, 2011 Posted May 8, 2011 Jaysds1 this will not work, because as long as you have more than 0 points, the IF statement will always pass at the first check. If you want to set ranks like this, the highest rank (1,000,000 points) needs to be the FIRST in the IF statement, then the 50,000 points rank, then the 10,000, etc. function getPlayerPoints (thePlayer) local Points = loadPlayerData (thePlayer,"wins") if (Points > 1000000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 50000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) elseif (Points > 10000 ) then savePlayerData (thePlayer,"rank",loadPlayerData(thePlayer,"rank") + 1) -- and so on.... The loadPlayerData and savePlayerData functions are from jasperNL's pointsystem resource on the community, which saves data to an XML file (unless he changed it). For a ranking system like this you should use a table to set the next rank instead of checking for points all the time. You will have to post the loadPlayerData function so we can see if you have an error in there. On the other hand, you could just have an error somewhere in the code. I never saw "attempt to compare error with a number" message in the debugging window.
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