mjau Posted January 20, 2013 Share Posted January 20, 2013 ok i got a problem when trying to get a vlue from db, and show it in label. SQL function function getBankMoney(acccountName) local money = executeSQLSelect("players", "bankMoney", "accName = '"..accountName.."'") return money[1]['bankMoney'] end Clientside functions in the script calling export function updateMoney(balance) guiSetText (GUIEditor.label[1], "Current Balance: "..balance) end addEvent("updateMoney", true) addEventHandler("updateMoney", localPlayer, updateMoney) function getMoney() triggerServerEvent ( "getMoney", getLocalPlayer()) end serverside function in the script calling the export function getMoney() local account = getPlayerAccount(source) local accountName = getAccountName(account) money = exports["SQL"]:getBankMoney(accountName) triggerClientEvent ("updateMoney", source, money) end addEvent("getMoney", true) addEventHandler("getMoney", getRootElement(), getMoney) and now the error: [2013-01-19 22:44:32] ERROR: [RLR]\SQL\main_S.lua:33: attempt to concatenate global 'accountName' (a nil value) [2013-01-19 22:44:32] ERROR: call: failed to call 'SQL:getBankMoney' [string "?"] Link to comment
Castillo Posted January 20, 2013 Share Posted January 20, 2013 Seems like "accountName" is returning nil at getBankMoney. Link to comment
mjau Posted January 20, 2013 Author Share Posted January 20, 2013 which means that it didnt get the account ?, but how is that possible, the player is the source... Link to comment
Castillo Posted January 20, 2013 Share Posted January 20, 2013 Try this and see what it outputs: function getBankMoney ( acccountName ) if ( accountName ) then local money = executeSQLSelect ( "players", "bankMoney", "accName = '".. accountName .."'" ) return money [ 1 ] [ 'bankMoney' ] else outputChatBox ( "No account name" ) end end Link to comment
mjau Posted January 20, 2013 Author Share Posted January 20, 2013 It outputs "No Account Name" Link to comment
Scripting Moderators Sarrum Posted January 20, 2013 Scripting Moderators Share Posted January 20, 2013 kimmis9, change 'acccountName' on 'accountName' in function arguments. Link to comment
mjau Posted January 20, 2013 Author Share Posted January 20, 2013 Ahh tnx, another typo lol. the sql script is something i never finished and started to use now. anyways ty 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