Jump to content

attempt to call a number value


Best-Killer

Recommended Posts

Posted

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 

Posted
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 $"..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.

Posted
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 $"..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 ?

Posted
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.

Posted
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

Posted

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.

Posted

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..

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

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...