Baseplate Posted September 28, 2013 Share Posted September 28, 2013 addEventHandler ("onResourceStart", root, function() executeSQLQuery("CREATE TABLE IF NOT EXISTS players(account STRING, skin STRING, x STRING, y STRING, z STRING, int STRING, dim STRING, wanted STRING, money STRING, occupation STRING, team STRING)") executeSQLQuery("CREATE TABLE IF NOT EXISTS weapons(account STRING,playerWeaponID0 STRING,playerWeaponID1 STRING,playerWeaponID2 STRING,playerWeaponID3 STRING,playerWeaponID4 STRING,playerWeaponID5 STRING,playerWeaponID6 STRING,playerWeaponID7 STRING,playerWeaponID8 STRING,playerWeaponID9 STRING,playerWeaponID10 STRING,playerWeaponID11 STRING,playerWeaponID12 STRING,playerWeaponAmmo0 STRING,playerWeaponAmmo1 STRING,playerWeaponAmmo2 STRING,playerWeaponAmmo3 STRING,playerWeaponAmmo4 STRING,playerWeaponAmmo5 STRING,playerWeaponAmmo6 STRING,playerWeaponAmmo7 STRING,playerWeaponAmmo8 STRING,playerWeaponAmmo9 STRING,playerWeaponAmmo10 STRING,playerWeaponAmmo11 STRING,playerWeaponAmmo12 STRING,pistolstat STRING,silencedstat STRING,desertstat STRING,shotgunstat STRING,sawnoffstat STRING,spazstat STRING,microstat STRING,mp5stat STRING,akstat STRING,m4stat STRING,sniperstat STRING)") end ) function saveThings() local acc = getAccountName(getPlayerAccount(source)) local x, y, z = getElementPosition(source) --Weps executeSQLQuery("UPDATE weapons SET playerWeaponID0=? WHERE account=?", getPedWeapon(source,0), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID1=? WHERE account=?", getPedWeapon(source,1), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID2=? WHERE account=?", getPedWeapon(source,2), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID3=? WHERE account=?", getPedWeapon(source,3), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID4=? WHERE account=?", getPedWeapon(source,4), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID5=? WHERE account=?", getPedWeapon(source,5), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID6=? WHERE account=?", getPedWeapon(source,6), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID7=? WHERE account=?", getPedWeapon(source,7), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID8=? WHERE account=?", getPedWeapon(source,8), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID9=? WHERE account=?", getPedWeapon(source,9), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID10=? WHERE account=?", getPedWeapon(source,10), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID11=? WHERE account=?", getPedWeapon(source,11), acc) executeSQLQuery("UPDATE weapons SET playerWeaponID12=? WHERE account=?", getPedWeapon(source,12), acc) --Wep Ammo executeSQLQuery("UPDATE weapons SET playerWeaponAmmo0=? WHERE account=?", getPedTotalAmmo(source, 0), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo1=? WHERE account=?", getPedTotalAmmo(source, 1), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo2=? WHERE account=?", getPedTotalAmmo(source, 2), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo3=? WHERE account=?", getPedTotalAmmo(source, 3), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo4=? WHERE account=?", getPedTotalAmmo(source, 4), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo5=? WHERE account=?", getPedTotalAmmo(source, 5), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo6=? WHERE account=?", getPedTotalAmmo(source, 6), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo7=? WHERE account=?", getPedTotalAmmo(source, 7), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo8=? WHERE account=?", getPedTotalAmmo(source, -- s8) -->, acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo9=? WHERE account=?", getPedTotalAmmo(source, 9), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo10=? WHERE account=?", getPedTotalAmmo(source, 10), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo11=? WHERE account=?", getPedTotalAmmo(source, 11), acc) executeSQLQuery("UPDATE weapons SET playerWeaponAmmo12=? WHERE account=?", getPedTotalAmmo(source, 12), acc) --Wep Stats executeSQLQuery("UPDATE weapons SET pistolstat=? WHERE account=?", getPedStat(source,69), acc) executeSQLQuery("UPDATE weapons SET silencedstat=? WHERE account=?", getPedStat(source,70), acc) executeSQLQuery("UPDATE weapons SET desertstat=? WHERE account=?", getPedStat(source,71), acc) executeSQLQuery("UPDATE weapons SET shotgunstat=? WHERE account=?", getPedStat(source,72), acc) executeSQLQuery("UPDATE weapons SET sawnoffstat=? WHERE account=?", getPedStat(source,73), acc) executeSQLQuery("UPDATE weapons SET spazstat=? WHERE account=?", getPedStat(source,74), acc) executeSQLQuery("UPDATE weapons SET microstat=? WHERE account=?", getPedStat(source,75), acc) executeSQLQuery("UPDATE weapons SET mp5stat=? WHERE account=?", getPedStat(source,76), acc) executeSQLQuery("UPDATE weapons SET akstat=? WHERE account=?", getPedStat(source,77), acc) executeSQLQuery("UPDATE weapons SET m4stat=? WHERE account=?", getPedStat(source,78), acc) executeSQLQuery("UPDATE weapons SET sniperstat=? WHERE account=?", getPedStat(source,79), acc) --Players executeSQLQuery("UPDATE players SET skin=? WHERE account=?", getElementModel(source), acc) executeSQLQuery("UPDATE players SET x=? WHERE account=?", x, acc) executeSQLQuery("UPDATE players SET y=? WHERE account=?", y, acc) executeSQLQuery("UPDATE players SET z=? WHERE account=?", z, acc) executeSQLQuery("UPDATE players SET int=? WHERE account=?", getElementInterior(source), acc) executeSQLQuery("UPDATE players SET dim=? WHERE account=?", getElementDimension(source), acc) executeSQLQuery("UPDATE players SET wanted=? WHERE account=?", getPlayerWantedLevel(source), acc) executeSQLQuery("UPDATE players SET money=? WHERE account=?", getPlayerMoney(source), acc) executeSQLQuery("UPDATE players SET occupation=? WHERE account=?", getElementData(source, "Occupation"), acc) executeSQLQuery("UPDATE players SET team=? WHERE account=?", getTeamName(getPlayerTeam(source)), acc) end addEventHandler("onPlayerLogout", root, saveThings) I'm currently experiencing some problems with this script, it does update the weapons and weapons stats, but it doesn't update the players table... Please note, that this is only a part of the script, I didn't want to post the full code and there is no errors on debugscript. Link to comment
Sasu Posted September 28, 2013 Share Posted September 28, 2013 Are you sure that the account was registered in account column? Because if it doesn't exist, you will have to create it with "INSERT INTO" Link to comment
Baseplate Posted September 28, 2013 Author Share Posted September 28, 2013 Are you sure that the account was registered in account column? Because if it doesn't exist, you will have to create it with "INSERT INTO" I did make it like, if there is no data on login, it will insert some data, but yet, nothing happens. Link to comment
Castillo Posted September 28, 2013 Share Posted September 28, 2013 Why do you execute that many queries? you can do it all on just one. Link to comment
myonlake Posted September 28, 2013 Share Posted September 28, 2013 Why do you execute that many queries? you can do it all on just one. Exactly. Additionally, there is a limit of queries or connections allowed at the same time. You should really try to squeeze them all into one big query, which may even fix the issue. Link to comment
Baseplate Posted September 28, 2013 Author Share Posted September 28, 2013 executeSQLQuery("UPDATE players SET skin=?, x=?, y=?, z=?, int=?, dim=?, wanted=?, money=?, occupation=?, team=? WHERE account=?", getElementModel(source), x, y, z, getElementInterior(source), getElementDimension(source), getPlayerWantedLevel(source), getPlayerMoney(source), getElementData(source, "Occupation"), getTeamName(getPlayerTeam(source)), acc) Nothing happens.. Link to comment
Baseplate Posted September 29, 2013 Author Share Posted September 29, 2013 Let's just bump this to make people look into my problem.... Link to comment
Castillo Posted September 29, 2013 Share Posted September 29, 2013 executeSQLQuery("UPDATE players SET skin=?, x=?, y=?, z=?, int=?, dim=?, wanted=?, money=?, occupation=?, team=? WHERE account=?", getElementModel(source), x, y, z, getElementInterior(source), getElementDimension(source), getPlayerWantedLevel(source), getPlayerMoney(source), getElementData(source, "Occupation"), getTeamName(getPlayerTeam(source)), acc) Nothing happens.. What does that mean? Link to comment
Baseplate Posted September 29, 2013 Author Share Posted September 29, 2013 executeSQLQuery("UPDATE players SET skin=?, x=?, y=?, z=?, int=?, dim=?, wanted=?, money=?, occupation=?, team=? WHERE account=?", getElementModel(source), x, y, z, getElementInterior(source), getElementDimension(source), getPlayerWantedLevel(source), getPlayerMoney(source), getElementData(source, "Occupation"), getTeamName(getPlayerTeam(source)), acc) Nothing happens.. What does that mean? I didn't get your point... Link to comment
Castillo Posted September 29, 2013 Share Posted September 29, 2013 I'm asking, what do you mean by "nothing happens"? Link to comment
Baseplate Posted September 29, 2013 Author Share Posted September 29, 2013 Ah, it doesn't update anything on logout, no errors on debug, yet it updates weapons and weps stats... 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