Best-Killer Posted January 14, 2016 Posted January 14, 2016 error : attempt to call a number value line : 9 function depoistMoney() local text = tonumber (guiGetText(GUIEditor.edit[2])) local text2 = tonumber(guiGetText(GUIEditor.edit[1])) if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then guiSetText(GUIEditor.edit[1],"Transferring...") setTimer(guiSetText,2000,1,GUIEditor.edit[1],tonumber(text + text2)) setTimer(takePlayerMoney,2000,1,tonumber(text)) exports['SAEGMessages']:sendClientMessage ( "You've deposited $"..tonumber(text)" from your bank account", source, 200, 200, 200 ) setElementData(localPlayer,"bankmoney",tonumber(text + text2)) elseif getPlayerMoney() == 0 then -- exports['SAEGMessages']:sendClientMessage ( "You don't have that ammount money in your bank", 255, 0, 0 ) elseif getPlayerMoney() < 0 then outputChatBox("You can't deposit negative numbers.") end end end
starksZ Posted January 15, 2016 Posted January 15, 2016 error : attempt to call a number valueline : 9 function depoistMoney() local text = tonumber (guiGetText(GUIEditor.edit[2])) local text2 = tonumber(guiGetText(GUIEditor.edit[1])) if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then guiSetText(GUIEditor.edit[1],"Transferring...") setTimer(guiSetText,2000,1,GUIEditor.edit[1],tonumber(text + text2)) setTimer(takePlayerMoney,2000,1,tonumber(text)) exports['SAEGMessages']:sendClientMessage ( "You've deposited $"..tostring(text)" from your bank account", source, 200, 200, 200 ) setElementData(localPlayer,"bankmoney",tonumber(text + text2)) elseif getPlayerMoney() == 0 then -- exports['SAEGMessages']:sendClientMessage ( "You don't have that ammount money in your bank", 255, 0, 0 ) elseif getPlayerMoney() < 0 then outputChatBox("You can't deposit negative numbers.") end end end Why you don't learn lua? You're abusing help forum. El unico limite en la vida, es tu imaginacion. Programar es la mejor forma de aprender a pensar.
Best-Killer Posted January 15, 2016 Author Posted January 15, 2016 error : attempt to call a number valueline : 9 function depoistMoney() local text = tonumber (guiGetText(GUIEditor.edit[2])) local text2 = tonumber(guiGetText(GUIEditor.edit[1])) if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then guiSetText(GUIEditor.edit[1],"Transferring...") setTimer(guiSetText,2000,1,GUIEditor.edit[1],tonumber(text + text2)) setTimer(takePlayerMoney,2000,1,tonumber(text)) exports['SAEGMessages']:sendClientMessage ( "You've deposited $"..tostring(text)" from your bank account", source, 200, 200, 200 ) setElementData(localPlayer,"bankmoney",tonumber(text + text2)) elseif getPlayerMoney() == 0 then -- exports['SAEGMessages']:sendClientMessage ( "You don't have that ammount money in your bank", 255, 0, 0 ) elseif getPlayerMoney() < 0 then outputChatBox("You can't deposit negative numbers.") end end end Why you don't learn lua? You're abusing help forum. are u kidding me ?? -.- who made the script then if i don't try to learn ?
Noki Posted January 15, 2016 Posted January 15, 2016 are u kidding me ?? -.- who made the script then if i don't try to learn ? You're not trying to learn though. Every time you encounter a problem you post it here instead of trying to solve it yourself.
Best-Killer Posted January 15, 2016 Author Posted January 15, 2016 are u kidding me ?? -.- who made the script then if i don't try to learn ? You're not trying to learn though. Every time you encounter a problem you post it here instead of trying to solve it yourself. function depoistMoney() local text = tonumber (guiGetText(GUIEditor.edit[2])) local text2 = convertNumber(guiGetText(GUIEditor.edit[1])) if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then guiSetText(GUIEditor.edit[1],"Transferring...") setTimer(guiSetText,2000,1,GUIEditor.edit[1],convertNumber(text + text2)) setTimer(takePlayerMoney,2000,1,convertNumber(text)) exports['SAEGMessages']:sendClientMessage ( "You've withdrawn $"..convertNumber(text)" from your bank account", source, 200, 200, 200 ) setElementData(localPlayer,"bankmoney",convertNumber(text + text2)) elseif getPlayerMoney() == 0 then -- exports['SAEGMessages']:sendClientMessage ( "You don't have that ammount money in your bank", 255, 0, 0 ) elseif getPlayerMoney() < 0 then outputChatBox("You can't deposit negative numbers.") end end end 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 GUIEditor.edit[1] = guiCreateEdit(11, 45, 444, 31,convertNumber(getElementData(localPlayer,"bankmoney")).."$", false, GUIEditor.window[1]) attempt to perform arithmetic on local 'text2' (a string value) (my problem i want add $ after the bank blance ) explain to me easy pls if u want help me cuz i'm fucking nab
Noki Posted January 15, 2016 Posted January 15, 2016 Line 7: setTimer(guiSetText,2000,1,GUIEditor.edit[1],convertNumber(text + text2)) convertNumber returns a string with commas in it. You'll have to use the unconverted number if you want to perform any math on it.
Best-Killer Posted January 15, 2016 Author Posted January 15, 2016 i won't math bro see what i want the script is bank system account blance showing like that : Account Blance : 42116 but me want it Account Blance : 5445$
tosfera Posted January 15, 2016 Posted January 15, 2016 If you want to combine a value and a string or what so ever, your first attempt was correct as in: GUIEditor.edit[1] = guiCreateEdit(11, 45, 444, 31,getElementData(localPlayer,"bankmoney") .."$", false, GUIEditor.window[1]) To combine 2 things, you just have to add the double dots there. If you're working towards a string though.. If you want to contact me directly concerning Advanced-Gaming, please contact me at [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