Gravestone Posted September 5, 2016 Posted September 5, 2016 I am trying to check a global variable but everytime it is returning false. something1 = false something2 = false something3 = false something4 = false something5 = false function checksomething(_, _, ...) local d = table.concat({...}, " ") if tostring(d) == true then outputChatBox("true") return true else outputChatBox("false") return false end end addCommandHandler("checks", checksomething) But if I do it in this way: something1 = false something2 = false something3 = false something4 = false something5 = false function checksomething(_, _, ...) local d = table.concat({...}, " ") if something1 == true then outputChatBox("true") return true else outputChatBox("false") return false end end addCommandHandler("checks", checksomething) then it will return true. Any ideas how to fix this?
MTA Team botder Posted September 5, 2016 MTA Team Posted September 5, 2016 if _G[tostring(d)] == true then _G is the global table.
Walid Posted September 5, 2016 Posted September 5, 2016 (edited) @Gravestone, _G predefined variable it returns a table of all global variables. Edited September 5, 2016 by Walid
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