Jump to content

Help please


Best-Killer

Recommended Posts

attempt to compare number with nill

function depoistMoney() 
local text = guiGetText(GUIEditor.label[2]) 
local text2 = guiGetText(GUIEditor.edit[2]) 
if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then 
if tonumber(text) and getPlayerMoney(localPlayer) >= tonumber(text) and tonumber(text) >= 0 then 
guiSetText(cashLabel,"Transferring...") 
setTimer(guiSetText,2000,1,cashLabel,""..tostring(text + text2)) 
setTimer(takePlayerMoney,2000,1,tonumber(text)) 
setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
elseif getPlayerMoney(localPlayer) < tonumber(text) then 
outputChatBox("You don't have enough money.") 
elseif tonumber(text) < 0 then 
outputChatBox("You can't deposit negative numbers.") 
end 
end 
end 

Line 10

Link to comment
function depoistMoney() 
    local text = guiGetText(GUIEditor.label[2]) 
    local text2 = guiGetText(GUIEditor.edit[2]) 
    if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then 
        if tonumber(text) and getPlayerMoney(localPlayer) >= tonumber(text) and tonumber(text) >= 0 then 
        guiSetText(cashLabel,"Transferring...") 
        setTimer(guiSetText,2000,1,cashLabel,tostring(text + text2)) 
        setTimer(takePlayerMoney,2000,1,tonumber(text)) 
        setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
        elseif getPlayerMoney() < tonumber(text) then -- getPlayerMoney in client-side dont need arguments 
            outputChatBox("You don't have enough money.") 
        elseif tonumber(text) < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 

Link to comment

thanks bro :)

function depoistMoney() 
    local text = guiGetText(GUIEditor.label[2]) 
    local text2 = guiGetText(GUIEditor.edit[2]) 
    if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then 
        if tonumber(text) and getPlayerMoney(localPlayer) >= tonumber(text) and tonumber(text) >= 0 then 
        guiSetText(cashLabel,"Transferring...") 
        setTimer(guiSetText,2000,1,cashLabel,tostring(text + text2)) 
        setTimer(takePlayerMoney,2000,1,tonumber(text)) 
        setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
        elseif getPlayerMoney() then --  
            outputChatBox("You don't have enough money.") 
        elseif tonumber(text) < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 

now work but when click deposit it's says You don't have enough money

and i have money what is the problem

Link to comment
  
function depoistMoney() 
    local text = guiGetText(GUIEditor.label[2]) 
    local text2 = guiGetText(GUIEditor.edit[2]) 
    if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then 
        if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then 
        guiSetText(cashLabel,"Transferring...") 
        setTimer(guiSetText,2000,1,cashLabel,tostring(text + text2)) 
        setTimer(takePlayerMoney,2000,1,tonumber(text)) 
        setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
        elseif getPlayerMoney() == 0 then -- 
            outputChatBox("You don't have enough money.") 
        elseif getPlayerMoney() < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 
  

Link to comment
elseif tonumber( getPlayerMoney() < text ) then 

nothing shoing

  
function depoistMoney() 
    local text = guiGetText(GUIEditor.label[2]) 
    local text2 = guiGetText(GUIEditor.edit[2]) 
    if (guiRadioButtonGetSelected(GUIEditor.radiobutton[1])) then 
        if tonumber(text) and getPlayerMoney() >= tonumber(text) and tonumber(text) >= 0 then 
        guiSetText(cashLabel,"Transferring...") 
        setTimer(guiSetText,2000,1,cashLabel,tostring(text + text2)) 
        setTimer(takePlayerMoney,2000,1,tonumber(text)) 
        setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
        elseif getPlayerMoney() == 0 then -- 
            outputChatBox("You don't have enough money.") 
        elseif getPlayerMoney() < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 
  

nothing shoing same problem

0 errors 0 warnings

Link to comment

server side :

function onPlayerLogin(per,cur) 
name = getAccountName(cur) 
money = getAccountData(account,"bank.money") 
setElementData(source,"bank.money",money) 
setElementData(source,"account",cur) 
setElementData(source,"accountName",name) 
end 
addEventHandler("onPlayerLogin",root,onPlayerLogin) 
  
function onPlayerLogout() 
account = getPlayerAccount(source) 
money = getElementData(source,"bank.money") 
setAccountData(account,"bank.money",money) 
end 
addEventHandler("onPlayerQuit",root,onPlayerLogout) 
  
function giveMoneyOnLog() 
local bankmoney = getElementData(source,"bank.money") 
local playermoney = getPlayerMoney(source) 
if bankmoney == "0" and playermoney == 0 then 
setElementData(source,"bank.money","5000") 
outputChatBox("Your current bank balance: $"..getElementData(source,"bank.money"),source) 
end 
end 
addEventHandler("onPlayerLogin",root,giveMoneyOnLog) 

Link to comment
function depoistMoney() 
    local text = guiGetText(GUIEditor.edit[2]) 
    local text2 = 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],tostring(text + text2)) 
        setTimer(takePlayerMoney,2000,1,tonumber(text)) 
        setElementData(localPlayer,"bank.money",tonumber(text + text2)) 
        elseif getPlayerMoney() == 0 then -- 
            outputChatBox("You don't have enough money.") 
        elseif getPlayerMoney() < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 

line 7 ( attempt to perform arithmetic on local 'text2' ( a string value)

Link to comment
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)) 
        setElementData(localPlayer,"bankmoney",tonumber(text + text2)) 
        elseif getPlayerMoney() == 0 then -- 
            outputChatBox("You don't have enough money.") 
        elseif getPlayerMoney() < 0 then 
            outputChatBox("You can't deposit negative numbers.") 
        end 
    end 
end 

same problem

please guys explain to me easy :'( i'm learning

attempt to perform arithmetic on local 'text2' ( a nill value)

Link to comment

You need to understand that you CAN'T add string values like "0$". It MUST be a number like 0. Your GUI labels contain data as strings so when you try to retrieve data from them it will be in a string format, not number. After that you add string to another string, but it's impossible. So convert your string to number with:

tonumber(myString) 

Link to comment
You need to understand that you CAN'T add string values like "0$". It MUST be a number like 0. Your GUI labels contain data as strings so when you try to retrieve data from them it will be in a string format, not number. After that you add string to another string, but it's impossible. So convert your string to number with:
tonumber(myString) 

ye ye thanks u really u helped me alot <3

Thanks All

Link to comment
function withdrawMoney() 
local text = tonumber guiGetText(GUIEditor.edit[2]) 
local text2 = tonumber guiGetText(GUIEditor.edit[1]) 
if (guiRadioButtonGetSelected(GUIEditor.radiobutton[2])) then 
if tonumber(text2) >= tonumber(text) and tonumber(text) > 0 then 
guiSetText(GUIEditor.edit[1],"Transferring...") 
setTimer(guiSetText,2000,1,GUIEditor.edit[1],tonumber(text + text2)) 
setTimer(givePlayerMoney,2000,1,tonumber(text)) 
setElementData(localPlayer,"bankmoney",tonumber(text2 - text)) 
elseif tonumber(text2) < tonumber(text) then 
outputChatBox("You don't have enough money at bank.") 
elseif tonumber(text) < 0 then 
outputChatBox("You can't withdraw negative numbers.") 
       end 
    end 
end 

line 5

attempt to compare two nill values

Link to comment
function depoistMoney() 
    local text = tonumber (guiGetText(GUIEditor.edit[2])) 
    local text2 = tonumber(guiGetText(GUIEditor.edit[1])) 
    mb = text + text2 
    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],mb) 
        triggerServerEvent ("depoist", getLocalPlayer(), text) 
        setAccountData(localPlayer,"bankmoney",mb) 
        end 
    end 
end 

now code but same problem

Link to comment
function depoistMoney() 
    local text = tonumber (guiGetText(GUIEditor.edit[2])) 
    local text2 = tonumber(guiGetText(GUIEditor.edit[1])) 
    mb = text + text2 
    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],mb) 
        triggerServerEvent ("depoist", getLocalPlayer(), text) 
        setAccountData(localPlayer,"bankmoney",mb) 
        end 
    end 
end 

now code but same problem

setAccountData is server-side function.

Link to comment
function depoistMoney() 
    local text = tonumber (guiGetText(GUIEditor.edit[2])) 
    local text2 = tonumber(guiGetText(GUIEditor.edit[1])) 
    mb = text + text2 
    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],mb) 
        triggerServerEvent ("depoist", getLocalPlayer(), text) 
        setAccountData(localPlayer,"bankmoney",mb) 
        end 
    end 
end 

now code but same problem

setAccountData is server-side function.

already i did xD check this : https://forum.multitheftauto.com/viewtopic.php?f=91&t=95922

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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