Jump to content

Convert number problem


Best-Killer

Recommended Posts

Posted

Line 78 : bad argument #1 to 'gsub' (string expected, got nil)

 

  GUIEditor = {  
 edit = {},  
 button = {}, 
 window = {},  
 label = {},   
 radiobutton = {} }
 addEventHandler("onClientResourceStart", resourceRoot,     function()  
 GUIEditor.window[1] = guiCreateWindow(433, 249, 464, 265, "SAEG:RPG Bank System", false) 
 guiWindowSetSizable(GUIEditor.window[1], false)         guiSetAlpha(GUIEditor.window[1], 0.80)  
 GUIEditor.label[1] = guiCreateLabel(10, 25, 96, 15, "Account Balance:", false, GUIEditor.window[1])   
 guiLabelSetColor(GUIEditor.label[1], 76, 183, 70)       
 GUIEditor.edit[1] = guiCreateEdit(11, 45, 444, 31,"$0", false, GUIEditor.window[1]) 
 GUIEditor.label[2] = guiCreateLabel(10, 80, 96, 15, "Amount:", false, GUIEditor.window[1]) 
 GUIEditor.edit[2] = guiCreateEdit(11, 97, 444, 31, "", false, GUIEditor.window[1])    
 GUIEditor.radiobutton[1] = guiCreateRadioButton(11, 135, 16, 15, "", false, GUIEditor.window[1])  
 GUIEditor.label[3] = guiCreateLabel(27, 135, 55, 15, "Deposit", false, GUIEditor.window[1])      
 guiLabelSetColor(GUIEditor.label[3], 254, 0, 0)    
 GUIEditor.radiobutton[2] = guiCreateRadioButton(83, 135, 16, 15, "", false, GUIEditor.window[1])  
 guiRadioButtonSetSelected(GUIEditor.radiobutton[2], true)   
 GUIEditor.label[4] = guiCreateLabel(100, 135, 55, 15, "Withdraw", false, GUIEditor.window[1])  
 guiLabelSetColor(GUIEditor.label[4], 76, 183, 70)     
 GUIEditor.button[1] = guiCreateButton(330, 157, 121, 51, "HACK", false, GUIEditor.window[1])     
 guiSetFont(GUIEditor.button[1], "clear-normal")  
 guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFE0000")    
 GUIEditor.button[2] = guiCreateButton(9, 156, 20, 25, "1", false, GUIEditor.window[1])    
 GUIEditor.button[3] = guiCreateButton(29, 156, 20, 25, "2", false, GUIEditor.window[1])    
 GUIEditor.button[4] = guiCreateButton(49, 156, 20, 25, "3", false, GUIEditor.window[1])     
 GUIEditor.button[5] = guiCreateButton(69, 156, 20, 25, "4", false, GUIEditor.window[1])     
 GUIEditor.button[6] = guiCreateButton(89, 156, 20, 25, "5", false, GUIEditor.window[1])       
 GUIEditor.button[7] = guiCreateButton(9, 181, 20, 25, "6", false, GUIEditor.window[1])      
 GUIEditor.button[8] = guiCreateButton(29, 181, 20, 25, "7", false, GUIEditor.window[1])       
 GUIEditor.button[9] = guiCreateButton(49, 181, 20, 25, "8", false, GUIEditor.window[1])       
 GUIEditor.button[10] = guiCreateButton(69, 181, 20, 25, "9", false, GUIEditor.window[1])      
 GUIEditor.button[11] = guiCreateButton(89, 181, 20, 25, "0", false, GUIEditor.window[1])      
 GUIEditor.button[12] = guiCreateButton(336, 218, 112, 35, "Cancel", false, GUIEditor.window[1])     
 GUIEditor.button[13] = guiCreateButton(9, 218, 100, 38, "Enter", false, GUIEditor.window[1])         
 guiSetVisible(GUIEditor.window[1],false)         
 showCursor(false)              
 guiEditSetReadOnly( GUIEditor.edit[1], true ) 
 end )
 
addEventHandler("onClientGUIClick",root,
	function ()
		if ( source == GUIEditor.button[12] ) then
			guiSetVisible(GUIEditor.window[1],false)         
            showCursor(false) 
	end
	end
)
currentPosition = {}

function createatm()
local x,y,z = getElementPosition (getLocalPlayer())
local r = getPlayerRotation (getLocalPlayer())
currentPosition = {x,y,z,r}
local send = {
	[1] = currentPosition[1], [2] = currentPosition[2], 
	[3] = currentPosition[3], [4] = currentPosition[4], 
	}
triggerServerEvent("Createatm", localPlayer, unpack(send))
end
addCommandHandler ( "atmc", createatm )


addEvent( 'markerhit', true )
addEventHandler( 'markerhit', root,
function ()
 if ( not exports.saeglogin:isClientLoggedin ( ) ) then return end
 guiSetText ( GUIEditor.edit[1], "$"..convertNumber ( money ) )
 guiSetVisible(GUIEditor.window[1],true)         
 showCursor(true) 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 function depoistMoney ( ) 
 local text = tonumber ( guiGetText ( GUIEditor.edit[2] ) ) or 0 
 local text2 = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) or 0  
 if guiRadioButtonGetSelected ( GUIEditor.radiobutton[1] ) then    
 if ( text and getPlayerMoney ( ) >= text and text >= 0 ) then     
 guiSetText ( GUIEditor.edit[1], "Transferring..." )        
 setTimer ( guiSetText, 2000, 1, GUIEditor.edit[1], tostring ( text + text2 ) ) 
 triggerServerEvent ( "bank_deposit", localPlayer, text )    
 end    
 end 
 end   
 function withdrawMoney ( )  
 local text = tonumber ( guiGetText ( GUIEditor.edit[2] ) ) or 0 
 local text2 = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) or 0 
 if guiRadioButtonGetSelected ( GUIEditor.radiobutton[2] ) then    
 if ( text2 >= text and text > 0 ) then       
 guiSetText ( GUIEditor.edit[1], "Transferring..." )          
 setTimer ( guiSetText, 2000, 1, GUIEditor.edit[1], tostring ( text2 - text ) )  
 triggerServerEvent ( "bank_withdraw", localPlayer, text )  
 end    
 end 
 end       

 

Posted

money: not defined here

 guiSetText ( GUIEditor.edit[1], "$"..convertNumber (money))

in this part

addEvent( 'markerhit', true )
addEventHandler( 'markerhit', root,
function ()
   if ( not exports.saeglogin:isClientLoggedin ( ) ) then return end
       guiSetText ( GUIEditor.edit[1], "$"..convertNumber ( money ) )
       guiSetVisible(GUIEditor.window[1],true)         
       showCursor(true) 
   end
)

 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...