Resto Posted January 21, 2016 Share Posted January 21, 2016 hi can anyone get me example how i can get number 1 to 5 only? i mean for w = 1,5 do but when i use this my outputchatbox is 5x i need to use here: local points = getElementData(player, "points") if (tostring(points) < "5") then Link to comment
KariiiM Posted January 21, 2016 Share Posted January 21, 2016 Explain more better and post a full code, As I see You want to check if the points are less than 5, so It should be like that local points = getElementData(player, "points") if (tonumber(points) < 5) then --your code end Link to comment
Resto Posted January 21, 2016 Author Share Posted January 21, 2016 Explain more better and post a full code,As I see You want to check if the points are less than 5, so It should be like that local points = getElementData(player, "points") if (tonumber(points) < 5) then --your code end Not that I do not want that the code can do what I have just me who points 1-5 others can not Link to comment
KariiiM Posted January 21, 2016 Share Posted January 21, 2016 Not that I do not want that the code can do what I have just me who points 1-5 others can not But why, What do you want to achive? Link to comment
Resto Posted January 21, 2016 Author Share Posted January 21, 2016 Not that I do not want that the code can do what I have just me who points 1-5 others can not But why, What do you want to achive? Because players what to 0 points can be abused my script and therefore we want to have protection for 1-5. And this should work? local points = tonumber(getElementData(player, "points")) if (points == 1) or (points == 2) or (points == 3) or (points == 4) or (points == 5) then Link to comment
KariiiM Posted January 21, 2016 Share Posted January 21, 2016 Yes, now I understand your problem, you can do it like that, local points = tonumber(getElementData(player, "points")) function() for i=1,5 do if ( points == tostring (i) ) then --your code end end end Link to comment
Resto Posted January 21, 2016 Author Share Posted January 21, 2016 Yes, now I understand your problem, you can do it like that, local points = tonumber(getElementData(player, "points")) function() for i=1,5 do if ( points == tostring (i) ) then --your code end end end My code work perfect and your code too work but outputChatBox will 5x. But thanks my problem is solved. Link to comment
SpecT Posted January 21, 2016 Share Posted January 21, 2016 Lol why do you use a loop for that? Use this instead: local points = tonumber(getElementData(player, "points")) function() if points > 1 and points < 5 then outputChatBox(points) -- your code else -- maybe abuse end end If you want to use the loop anyway put the outputChatBox out of the loop. Example: local number = 5 local justDoIt = false function() for i=1,15 do if number == i then justDoIt = true else justDoIt = false end end -- closing the loop if justDoIt then outputChatBox(number) -- that will show the message just once end end But seriously there is no need to use loop for such thing. 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