Tete omar Posted June 14, 2012 Share Posted June 14, 2012 (edited) hey guys i created a bank script and i tried it and it works .. when i gone with my friend into his port server and clicked deposit & withdraw it says with deposit lua:30: ERROR: attempt to perform arithmetic on local 'jaws' (a boolean value' and with, withdraw lua:58: ERROR: attempt to compare number with nil Knowing it works with my server WHY ? here's the lua codes server side line :30: "deposit" lua:30: ERROR: attempt to perform arithmetic on local 'jaws' (a boolean value' addEvent("depositing", true) function jerocoleman(moneyyy) if not (tonumber(moneyyy) <= 0) then local jaws = getAccountData (getPlayerAccount (source), "tete&anad") takePlayerMoney(source, moneyyy) money1 = jaws + moneyyy -- here's line 30 what's the problem ??............ setAccountData (getPlayerAccount (source), "tete&anad", money1 ) outputChatBox("Your money in the bank: " .. money1 .. "$", source, 0, 255, 0) else outputChatBox("can't deposit" .. moneyyy .. "=]", source, 255, 0, 0) end end addEventHandler( "depositing", getRootElement(), jerocoleman ) client side addEvent("depositing", true) function deposittt(thisPlayer,button,state) local theePlayer = getLocalPlayer() local hismoney = getPlayerMoney(thisPlayer) local moneey= guiGetText(GUIEditor_Edit[1]) if( tonumber(hismoney) >= tonumber(moneey)) then triggerServerEvent ("depositing", getLocalPlayer(), moneey) else outputChatBox("you can't deposit more than you got", 255, 0, 0) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], deposittt, false) server side line :58: "withdraw" lua:58: ERROR: attempt to compare number with nil addEvent("withdrawnow", true) function withdrawww(moneyyy) local bankmoney = getAccountData (getPlayerAccount (source), "tete&anad") if (tonumber(moneyyy) <= tonumber(bankmoney)) then -- here's line 58 what's the problem :\ ????? if(tonumber(moneyyy) >= 1) then money1 = bankmoney-moneyyy setAccountData (getPlayerAccount (source), "tete&anad", money1) givePlayerMoney(source, moneyyy) outputChatBox("Your money in the bank: " .. money1 .. "$", source, 255, 255, 0) else outputChatBox("Cannot witdraw" .. moneyyy .. "$", source, 255, 0, 0) end else outputChatBox("you typed a nil number", source, 255, 0, 0) outputChatBox("Your Money is:" .. bankmoney .. "$", source, 255, 0, 0) end end addEventHandler( "withdrawnow", getRootElement(), withdrawww ) client side addEvent("withdrawnow", true) function withdrawww(button,state) local moneey = guiGetText(GUIEditor_Edit[1]) triggerServerEvent ("withdrawnow", getLocalPlayer(), moneey) end addEventHandler("onClientGUIClick", GUIEditor_Button[1], withdrawww, false) hope you got me guys thanks. Edited June 14, 2012 by Guest Link to comment
Tete omar Posted June 14, 2012 Author Share Posted June 14, 2012 oh sorry fixing this part hey guys i created a bank script and i tried it and it works i give the script to my friend, and when i gone with my friend....... Link to comment
TwiX! Posted June 14, 2012 Share Posted June 14, 2012 (edited) --client side function deposittt(thisPlayer,button,state) local theePlayer = getLocalPlayer() local hismoney = getPlayerMoney(theePlayer) local moneey = guiGetText(GUIEditor_Edit[1]) if( tonumber(hismoney) >= tonumber(moneey)) then triggerServerEvent ("depositing", theePlayer, moneey) else outputChatBox("you can't deposit more than you got", 255, 0, 0) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], deposittt, false) --server function jerocoleman(Money) if not (tonumber(Money) <= 0) then local jaws = getAccountData (getPlayerAccount (source), "tete&anad") takePlayerMoney(source, Money) jaws = tonumber(jaws) if not jaws < Money then money1 = jaws + Money setAccountData (getPlayerAccount (source), "tete&anad", money1 ) outputChatBox("Your money in the bank: " .. money1 .. "$", source, 0, 255, 0) end else outputChatBox("can't deposit" .. Money .. "=]", source, 255, 0, 0) end end addEvent("depositing", true) addEventHandler( "depositing", getRootElement(), jerocoleman ) --client side function withdrawww(button,state) local moneey = guiGetText(GUIEditor_Edit[1]) triggerServerEvent ("withdrawnow", getLocalPlayer(), moneey) end addEventHandler("onClientGUIClick", GUIEditor_Button[1], withdrawww, false) --server side function withdrawww(money) local bankmoney = getAccountData (getPlayerAccount (source), "tete&anad") bankmoney = tonumber(bankmoney) if (tonumber(money) <= bankmoney) then if(tonumber(money) >= 1) then money1 = bankmoney - money setAccountData (getPlayerAccount (source), "tete&anad", money1) givePlayerMoney(source, money) outputChatBox("Your money in the bank: " .. money1 .. "$", source, 255, 255, 0) else outputChatBox("Cannot witdraw" .. money .. "$", source, 255, 0, 0) end else outputChatBox("you typed a nil number", source, 255, 0, 0) outputChatBox("Your Money is:" .. bankmoney .. "$", source, 255, 0, 0) end end addEvent("withdrawnow", true) addEventHandler( "withdrawnow", getRootElement(), withdrawww ) Edited June 14, 2012 by Guest Link to comment
Castillo Posted June 14, 2012 Share Posted June 14, 2012 TwiX, did you read the arguments for getAccountData? because the first argument is not a player element, is an account. getAccountData ( account theAccount, string key ) Link to comment
TwiX! Posted June 14, 2012 Share Posted June 14, 2012 TwiX, did you read the arguments for getAccountData? because the first argument is not a player element, is an account. getAccountData ( account theAccount, string key ) I mixed up the function with a getElementData.. 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