Jockie Posted September 18, 2010 Posted September 18, 2010 I have this realy small problem, but I can't fix it.. Always says Base out of range. tonumber(string.gsub("$900","$", "")) and also tonumber(string.gsub("$900","$", ""),2) Both returns with nil.
dzek (varez) Posted September 18, 2010 Posted September 18, 2010 http://www.lua.org/manual/5.1/manual.html It says all. $ is special character, and you have to escape it with % tonumber(string.gsub("$900","%$", "")) Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
50p Posted September 20, 2010 Posted September 20, 2010 http://www.lua.org/manual/5.1/manual.html#pdf-tonumber You don't want to change the base parameter but string.gsub returns 2 values. One being the substring and the other the place (integer) at which the sub string starts. Both of these values are passed to your tonumber and it causes the error. Why? Because your base will be 1 (where $ is found), but you can't pass a value smaller than 2 and larger than 35. If you expect $ to be anywhere else than at start then you want to assign the first returned value from string.gsub to a variable and pass it to tonumber later but if you expect the $ to be as the first character then you can use this method instead: tonumber( string.sub( "$900", 2, -1 ) ) - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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