Karuzo Posted August 10, 2014 Posted August 10, 2014 Hey Guys, I wanted to ask if there is a possibility to check if a text from an edit box is a number and not a string. But as guiGetText retursn the text as a string idk how to solve this. I think i could do it with a table which is filled with numbers and check if its a number. But is there no other way to do this?
xXMADEXx Posted August 10, 2014 Posted August 10, 2014 (edited) You can just simply use tonumber. Example: if ( not tonumber ( guiGetText ( myEdit ) ) ) then return outputChatBox ( "Invalid number" ) end Edited August 10, 2014 by Guest The Ultimate Lua Tutorial! | MTA PHP SDK
Castillo Posted August 10, 2014 Posted August 10, 2014 local number = tonumber ( guiGetText ( myGUIElement ) ) if ( number ) then -- is a number end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Et-win Posted August 10, 2014 Posted August 10, 2014 http://www.lua.org/manual/5.1/manual.html#pdf-tonumber 'tonumber' returns 'nil' if the given string is not a number. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Karuzo Posted August 10, 2014 Author Posted August 10, 2014 Ah yeah, that i didn't come up with this idea Thanks.
#DRAGON!FIRE Posted August 10, 2014 Posted August 10, 2014 also u can use "onClientGUIChanged" and Cheek if the text not number return end To Contact Me at Skype : [email protected]
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