1LoL1 Posted February 27, 2016 Posted February 27, 2016 Hello, i tried save and load with executeSQLQuery but idk why not work. Errors / Warnings: Warning: Bad argument @ 'getAccountName' [Expected account at argument 1, got player] Error: Database query failed: no such column: false addEventHandler("onPlayerQuit", getRootElement(), function () if isGuestAccount(getPlayerAccount(source)) then return end local account = getAccountName(getPlayerAccount(source)) local TEST1 = (getElementData(source, "TEST1") or 0) local TEST2 = (getElementData(source, "TEST2") or 0) local TEST3 = (getElementData(source, "TEST3") or 0) local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) if #searchForAPlayer == 0 then executeSQLQuery("INSERT INTO Avengers (Account, TEST1, TEST2, TEST3) VALUES (?, ?, ?, ?)", account, TEST1, TEST2, TEST13) else executeSQLQuery("UPDATE Avengers SET TEST1 = ?, TEST2 = ?, TEST3 = ? WHERE Account = ?", TEST1, TEST2, TEST3, account) end end) addEventHandler ("onPlayerLogin", getRootElement(), function () local account = getAccountName(source) local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) if #searchForAPlayer == 1 then setElementData(source, "TEST1", searchForAPlayer["TEST1"]) setElementData(source, "TEST2", searchForAPlayer["TEST2"]) setElementData(source, "TEST3", searchForAPlayer["TEST3"]) end end)
Mr.Aleks Posted February 27, 2016 Posted February 27, 2016 You first have to get the account with getPlayerAccount. Then use getAccountName to get the account name from the account you got with getPlayerAccount. You can't use getAccountName with the player element because an account is required in that function.
ozulus Posted February 27, 2016 Posted February 27, 2016 Just use event parameter for get the account addEventHandler ("onPlayerLogin", getRootElement(), function ( _, currentAccount ) local account = getAccountName(currentAccount) local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) if #searchForAPlayer == 1 then setElementData(source, "TEST1", searchForAPlayer["TEST1"]) setElementData(source, "TEST2", searchForAPlayer["TEST2"]) setElementData(source, "TEST3", searchForAPlayer["TEST3"]) end end)
1LoL1 Posted February 27, 2016 Author Posted February 27, 2016 Just use event parameter for get the account addEventHandler ("onPlayerLogin", getRootElement(), function ( _, currentAccount ) local account = getAccountName(currentAccount) local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) if #searchForAPlayer == 1 then setElementData(source, "TEST1", searchForAPlayer["TEST1"]) setElementData(source, "TEST2", searchForAPlayer["TEST2"]) setElementData(source, "TEST3", searchForAPlayer["TEST3"]) end end) i used this too but save or load not work
1LoL1 Posted February 27, 2016 Author Posted February 27, 2016 You first have to get the account with getPlayerAccount. Then use getAccountName to get the account name from the account you got with getPlayerAccount. You can't use getAccountName with the player element because an account is required in that function. Where?
Tox Posted February 27, 2016 Posted February 27, 2016 setElementData(source, "TEST1", searchForAPlayer[1]["TEST1"])
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