Annas Posted February 15, 2016 Share Posted February 15, 2016 How can i add player last name to the database i tried this , but it's not working function saveData() local account = getPlayerAccount(source) if (not account or isGuestAccount(account)) then return end local lastname = getPlayerName(source) -- Last name dbExec(db, "UPDATE banking (name, lastname) VALUES(?)", account, lastname) end addEventHandler("onPlayerQuit", root, saveData) addEventHandler("onPlayerLogout", root, saveData) Sorry if it's wrong board HELP ME PLEASE Link to comment
Mann56 Posted February 15, 2016 Share Posted February 15, 2016 dbExec(db, "UPDATE banking SET lastname=? WHERE name=? ", lastname, account) Link to comment
KariiiM Posted February 15, 2016 Share Posted February 15, 2016 Hey, what you have coded was totally, wrong, try that function saveData() local account = getPlayerAccount(source) if (not account or isGuestAccount(account)) then return end local lastname = getPlayerName(source) -- Last name dbExec(db, "UPDATE banking SET lastname=? WHERE name='"..tostring(account).."'LIMIT 1", lastname) end addEventHandler("onPlayerQuit", root, saveData) addEventHandler("onPlayerLogout", root, saveData) Link to comment
Mann56 Posted February 15, 2016 Share Posted February 15, 2016 Hey, what you have coded was totally, wrong, try that function saveData() local account = getPlayerAccount(source) if (not account or isGuestAccount(account)) then return end local lastname = getPlayerName(source) -- Last name dbExec(db, "UPDATE banking SET lastname=? WHERE name='"..tostring(account).."'LIMIT 1", lastname) end addEventHandler("onPlayerQuit", root, saveData) addEventHandler("onPlayerLogout", root, saveData) Ah i forgot the tostring() Btw dude, i think he has set variable account with name and not lastname Link to comment
KariiiM Posted February 15, 2016 Share Posted February 15, 2016 By the way, It won't works, if your table is empty. Link to comment
TAPL Posted February 15, 2016 Share Posted February 15, 2016 getPlayerAccount does not return account name, you must use getAccountName to get the account name. 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