Monument Posted June 22, 2021 Share Posted June 22, 2021 setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') else outputChatBox('false') end end end,1000,1) this is my code when first the condition will output 'true' but when output 'true' be repetitive any help to be 1 time only with out repet Link to comment
RavenLoad Posted June 22, 2021 Share Posted June 22, 2021 outputChatBox("true") outputChatBox("false") Link to comment
βurak Posted June 22, 2021 Share Posted June 22, 2021 (edited) If I'm not mistaken, you want to exit the loop when the condition is met, if so, you can exit the loop with the return command. if you want to continue the code from the bottom line you can also use break command setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') return else outputChatBox('false') end end end,1000,1) Edited June 22, 2021 by Burak5312 Link to comment
Monument Posted June 22, 2021 Author Share Posted June 22, 2021 42 minutes ago, Burak5312 said: If I'm not mistaken, you want to exit the loop when the condition is met, if so, you can exit the loop with the return command. if you want to continue the code from the bottom line you can also use break command setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') return else outputChatBox('false') end end end,1000,1) done but same thing i want when output be without spam only 1 output now its with more 10 output Link to comment
Monument Posted June 22, 2021 Author Share Posted June 22, 2021 8 minutes ago, Burak5312 said: can you show the full code? it's in 1 function timer with table Table = { {"1","2","3"} } setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') return else outputChatBox('false') end end end,1000,1) 1 minute ago, Monument said: it's in 1 function timer with table Table = { {"1","2","3"} } setTimer(function() for i,v in ipairs(Table) do if (T1== v[1] and T2 == v[2] and T3 == v[3]) then outputChatBox('true') return else outputChatBox('false') end end end,1000,1) 10 minutes ago, Burak5312 said: can you show the full code? reason is the ipairs but how fix it i don't know Link to comment
βurak Posted June 22, 2021 Share Posted June 22, 2021 are you sure no other resource is causing this because only this code is not causing something like this I don't know what you are trying to do but you can do this code without a for loop Link to comment
Monument Posted June 23, 2021 Author Share Posted June 23, 2021 12 hours ago, Burak5312 said: are you sure no other resource is causing this because only this code is not causing something like this I don't know what you are trying to do but you can do this code without a for loop i try to do it as if T1 == "1" and T2 =="2" and T3 =="3" then the output only 1 message but i have alot of data in table i can't do all as if Link to comment
SpecT Posted June 23, 2021 Share Posted June 23, 2021 Hey, This is a way to prevent the spam: setTimer(function() local found = false for i,v in ipairs(Table) do if (T1 == v[1] and T2 == v[2] and T3 == v[3]) then found = true break end end if found then outputChatBox('true') else outputChatBox('false') end end,1000,1) Link to comment
Monument Posted June 23, 2021 Author Share Posted June 23, 2021 2 hours ago, SpecT said: Hey, This is a way to prevent the spam: setTimer(function() local found = false for i,v in ipairs(Table) do if (T1 == v[1] and T2 == v[2] and T3 == v[3]) then found = true break end end if found then outputChatBox('true') else outputChatBox('false') end end,1000,1) thx its work good thx for all 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