itHyperoX Posted March 23, 2017 Share Posted March 23, 2017 (edited) Hi, im trying to create my own level system, but i got some problem. I tried a few way, but always gettint debug errors and i dont know how to fix that. Debug error: sourceS: Line 8: attempt to compare boolean with number Here is the server side: exports.scoreboard:scoreboardAddColumn("Level") function setPlayerLEVEL(player) for _,player in ipairs(getElementsByType("player")) do local currentPlayerLevel = getElementData(player,"pLevel" or 0) if currentPlayerLevel < 5 then --- Line 8 setElementData(player,"Level",2) end if currentPlayerLevel >= 10 and currentPlayerLevel < 15 then setElementData(player,"Level",3) end if currentPlayerLevel >= 20 and currentPlayerLevel < 30 then setElementData(player,"Level",4) end if currentPlayerLevel >= 30 and currentPlayerLevel < 40 then setElementData(player,"Level",5) end end end setTimer(setPlayerLEVEL,500,0) Here is the client side: setTimer(function() if getElementData(localPlayer,"pLevel" or 0) then setElementData(localPlayer,"pLevel",getElementData(localPlayer,"pLevel") + 1) end end, 10*600, 0) Thanks any help. Or can i make it easier? Edited March 23, 2017 by TheMOG Link to comment
#BrosS Posted March 23, 2017 Share Posted March 23, 2017 (edited) you don't need to define player it's already in a loop Edited March 23, 2017 by #BrosS Link to comment
Addlibs Posted March 23, 2017 Share Posted March 23, 2017 --serverside, line 4: local currentPlayerLevel = getElementData(player,"pLevel" or 0) --should be: local currentPlayerLevel = tonumber(getElementData(player,"pLevel")) or 0 Link to comment
^iiEcoo'x_) Posted March 23, 2017 Share Posted March 23, 2017 if tonumber(currentPlayerLevel) < 5 then --- Line 8 Link to comment
itHyperoX Posted March 23, 2017 Author Share Posted March 23, 2017 (edited) LOL, now that broke what worked. client: setTimer(function() if getElementData(localPlayer,"pLevel" or 0) then setElementData(localPlayer,"pLevel",getElementData(localPlayer,"pLevel") + 1) outputChatBox(getElementData(localPlayer,"pLevel")) end end, 100, 0) I dont get anything from this. Whats happened with this? No debug error Edited March 23, 2017 by TheMOG Link to comment
NeXuS™ Posted March 23, 2017 Share Posted March 23, 2017 Change line nr. 2 to if (getElementData(localPlayer,"pLevel") or 0) then Btw, I dont understand that line at all. You could just do setTimer(function() setElementData(localPlayer, "pLevel", (getElementData(localPlayer, "pLevel") or 0) + 1) outputChatBox(getElementData(localPlayer, "pLevel")) end, 100, 0) Link to comment
itHyperoX Posted March 23, 2017 Author Share Posted March 23, 2017 Line 9 attempt to perform arthmetic on boolean value setTimer(function() if (getElementData(localPlayer,"pLevel") or 0) then setElementData(localPlayer,"pLevel",getElementData(localPlayer,"pLevel") + 1) --- Line 9 outputChatBox(getElementData(localPlayer,"pLevel")) end end, 100, 0) Link to comment
NeXuS™ Posted March 23, 2017 Share Posted March 23, 2017 (edited) Just see the edited post above. Do that one which I edited in. Edited March 23, 2017 by NeXuS™ Link to comment
itHyperoX Posted March 23, 2017 Author Share Posted March 23, 2017 i i just realised too. Sorry for this little problem ^.^. Thanks. 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