[SR]mR.EmiN Posted May 7, 2011 Share 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 Link to comment
proracer Posted May 7, 2011 Share Posted May 7, 2011 This is just ridicolous.We need loadPlayerData function and savePlayerData function. Did you mean getElementData and setElementData? Link to comment
[SR]mR.EmiN Posted May 8, 2011 Author Share Posted May 8, 2011 I think set function for SQL Link to comment
Castillo Posted May 8, 2011 Share Posted May 8, 2011 What do you mean? i don't get you. Link to comment
Jaysds1 Posted May 8, 2011 Share 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 , Link to comment
NeXTreme Posted May 8, 2011 Share 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. Link to comment
Castillo Posted May 9, 2011 Share Posted May 9, 2011 I suposed they we're from Jasper's resource 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