Jump to content

idk how to fix


Resto

Recommended Posts

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

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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...