MajdMTA Posted February 18, 2016 Share Posted February 18, 2016 Hello.. Some for this stupid thing, I tried to convert gridList number, Example my one is 5000 I wanna it 5,000, can someone gimme a function? and I'll put it. Link to comment
knightscript Posted February 18, 2016 Share Posted February 18, 2016 you mean you want to convert any number that has 3 digits or more? Link to comment
MajdMTA Posted February 18, 2016 Author Share Posted February 18, 2016 you mean you want to convert any number that has 3 digits or more? In my vehicle script grid list the price for Faggio-car is 5000 I wanna it 5,000 Link to comment
bebo1king Posted February 18, 2016 Share Posted February 18, 2016 I think That's what you mean https://wiki.multitheftauto.com/wiki/ConvertNumber Link to comment
MajdMTA Posted February 18, 2016 Author Share Posted February 18, 2016 I think That's what you meanhttps://wiki.multitheftauto.com/wiki/ConvertNumber Yes.. but i tried.. didn't work Link to comment
bebo1king Posted February 18, 2016 Share Posted February 18, 2016 Post code and i will try to help you Link to comment
MajdMTA Posted February 18, 2016 Author Share Posted February 18, 2016 Post code and i will try to help you "Try" words didn't work with me. Link to comment
knightscript Posted February 18, 2016 Share Posted February 18, 2016 You have the simplest example on the website: function convertPlayerMoney() local pMoney = getPlayerMoney() --get the players money local convertedMoney = convertNumber(pMoney) --converts it and saves it in variable outputChatBox(convertedMoney) --outputs it end addCommandHandler("money", convertPlayerMoney) You would just have to change the local pMoney to get the value of the vehicle, and that would be it, but if you need more help you can post the code, Link to comment
knightscript Posted February 18, 2016 Share Posted February 18, 2016 Post code and i will try to help you "Try" words didn't work with me. He is gonna try to help you, he doesnt have an obligation to do it, so if "try" doesnt work for you then hire a scripter Link to comment
bebo1king Posted February 18, 2016 Share Posted February 18, 2016 Post code and i will try to help you "Try" words didn't work with me. Bro i am here for help not fight , So please calm down Link to comment
MajdMTA Posted February 18, 2016 Author Share Posted February 18, 2016 local carCost = guiGridListGetItemText (carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carCost) local carprice = guiGridListGetItemText(carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carprice) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end So tell me where's the bug? Link to comment
bebo1king Posted February 18, 2016 Share Posted February 18, 2016 (edited) local carCost = guiGridListGetItemText (carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carCost) local carprice = guiGridListGetItemText(carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carprice) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end So tell me where's the bug? You made the prices in table then loop it ? Edited February 18, 2016 by Guest Link to comment
knightscript Posted February 18, 2016 Share Posted February 18, 2016 Any errors on debugscript? What im thinking is maybe you can move the convertNumber function over the rest of the script, Link to comment
MajdMTA Posted February 18, 2016 Author Share Posted February 18, 2016 Any errors on debugscript? What im thinking is maybe you can move the convertNumber function over the rest of the script, No error's. Link to comment
MIKI785 Posted February 18, 2016 Share Posted February 18, 2016 local carCost = guiGridListGetItemText (carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carCost) local carprice = guiGridListGetItemText(carGrid, guiGridListGetSelectedItem(carGrid), 2) local convertedMoney = convertNumber(carprice) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end So tell me where's the bug? That has to throw an error since you're trying to call function 'convertNumber' that is nil. It is nil because it wasn't defined yet until few lines later. You have to put the function definition outside of this function (I assume it is a function called by some event handler). 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