Baseplate Posted January 26, 2013 Posted January 26, 2013 Is it possible to use setAccountData and getAccountData on player's death? if no, then how can I save weapons on player's death
Castillo Posted January 26, 2013 Posted January 26, 2013 Why wouldn't it be possible? save them on death, then load on spawn. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted January 26, 2013 Author Posted January 26, 2013 I dunno, as everyone is using those functions on login and logout only made me a bit confused. Thanks mate addEventHandler("onPlayerWasted", root, function() if (account) then setAccountData(account, "save-wep0", getPedWeapon(source, 0)) setAccountData (account, "save-ammo0", getPedTotalAmmo (source, 0)) setAccountData(account, "save-wep1", getPedWeapon(source, 1)) setAccountData (account, "save-ammo1", getPedTotalAmmo (source, 1)) setAccountData(account, "save-wep2", getPedWeapon(source, 2)) setAccountData (account, "save-ammo2", getPedTotalAmmo (source, 2)) setAccountData(account, "save-wep3", getPedWeapon(source, 3)) setAccountData (account, "save-ammo3", getPedTotalAmmo (source, 3)) setAccountData(account, "save-wep4", getPedWeapon(source, 4)) setAccountData (account, "save-ammo4", getPedTotalAmmo (source, 4)) setAccountData(account, "save-wep5", getPedWeapon(source, 5)) setAccountData (account, "save-ammo5", getPedTotalAmmo (source, 5)) setAccountData(account, "save-wep6", getPedWeapon(source, 6)) setAccountData (account, "save-ammo6", getPedTotalAmmo (source, 6)) setAccountData(account, "save-wep7", getPedWeapon(source, 7)) setAccountData (account, "save-ammo7", getPedTotalAmmo (source, 7)) setAccountData(account, "save-wep8", getPedWeapon(source, -- s8) -->) setAccountData (account, "save-ammo8", getPedTotalAmmo (source, -- s8) -->) setAccountData(account, "save-wep9", getPedWeapon(source, 9)) setAccountData (account, "save-ammo9", getPedTotalAmmo (source, 9)) setAccountData(account, "save-wep10", getPedWeapon(source, 10)) setAccountData (account, "save-ammo10", getPedTotalAmmo (source, 10)) setAccountData(account, "save-wep11", getPedWeapon(source, 11)) setAccountData (account, "save-ammo11", getPedTotalAmmo (source, 11)) setAccountData(account, "save-wep12", getPedWeapon(source, 12)) setAccountData (account, "save-ammo12", getPedTotalAmmo (source, 12)) end end end ) addEventHandler("onPlayerSpawn", root, function() local account = getPlayerAccount(source) if not (isGuestAccount (getPlayerAccount (source))) then local wep1 = getAccountData(theCurrentAccount, "save-wep1") local ammo1 = getAccountData(theCurrentAccount, "save-ammo1") local wep2 = getAccountData(theCurrentAccount, "save-wep2") local ammo2 = getAccountData(theCurrentAccount, "save-ammo2") local wep3 = getAccountData(theCurrentAccount, "save-wep3") local ammo3 = getAccountData(theCurrentAccount, "save-ammo3") local wep4 = getAccountData(theCurrentAccount, "save-wep4") local ammo4 = getAccountData(theCurrentAccount, "save-ammo4") local wep5 = getAccountData(theCurrentAccount, "save-wep5") local ammo5 = getAccountData(theCurrentAccount, "save-ammo5") local wep6 = getAccountData(theCurrentAccount, "save-wep6") local ammo6 = getAccountData(theCurrentAccount, "save-ammo6") local wep7 = getAccountData(theCurrentAccount, "save-wep7") local ammo7 = getAccountData(theCurrentAccount, "save-ammo7") local wep8 = getAccountData(theCurrentAccount, "save-wep8") local ammo8 = getAccountData(theCurrentAccount, "save-ammo8") local wep9 = getAccountData(theCurrentAccount, "save-wep9") local ammo9 = getAccountData(theCurrentAccount, "save-ammo9") local wep10 = getAccountData(theCurrentAccount, "save-wep10") local ammo10 = getAccountData(theCurrentAccount, "save-ammo10") local wep11 = getAccountData(theCurrentAccount, "save-wep11") local ammo11 = getAccountData(theCurrentAccount, "save-ammo11") local wep12 = getAccountData(theCurrentAccount, "save-wep12") local ammo12 = getAccountData(theCurrentAccount, "save-ammo12") setElementData(source, "Occupation", occupation) spawnPlayer(source, x, y, z, interior, dimension) setElementHealth(source, health) setElementModel(source, skin) setPlayerTeam(source, getTeamFromName(team)) setPlayerMoney(source, money) setPedArmor(source, armor) setPlayerWantedLevel(source, wanted) giveWeapon(source, wep1, ammo1) giveWeapon(source, wep2, ammo2) giveWeapon(source, wep3, ammo3) giveWeapon(source, wep4, ammo4) giveWeapon(source, wep5, ammo5) giveWeapon(source, wep6, ammo6) giveWeapon(source, wep7, ammo7) giveWeapon(source, wep8, ammo8) giveWeapon(source, wep9, ammo9) giveWeapon(source, wep10, ammo10) giveWeapon(source, wep11, ammo11) giveWeapon(source, wep12, ammo12) end end ) Will this work?
Anderl Posted January 26, 2013 Posted January 26, 2013 Why don't you simply use arrays and JSON with account data? It's much easier. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Castillo Posted January 26, 2013 Posted January 26, 2013 I remember when I used account data long ago, I stored weapons as JSON string, it ended cutting the string because of limit. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted January 26, 2013 Posted January 26, 2013 Well, never heard about that string limit. Seems like it gotta be done that way then ( unless there's some other way I'm not remembering ). "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Lloyd Logan Posted January 26, 2013 Posted January 26, 2013 I remember when I used account data long ago, I stored weapons as JSON string, it ended cutting the string because of limit. Well, never heard about that string limit. Seems like it gotta be done that way then ( unless there's some other way I'm not remembering ). What is JSON? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Anderl Posted January 26, 2013 Posted January 26, 2013 http://en.wikipedia.org/wiki/JSON "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Jullul7000 Posted January 26, 2013 Posted January 26, 2013 http://www.mediafire.com/?lqq6gnd2hh8q54b Its from Solidsnake
Lloyd Logan Posted January 26, 2013 Posted January 26, 2013 http://en.wikipedia.org/wiki/JSON Thanks! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 27, 2013 Posted January 27, 2013 http://www.mediafire.com/?lqq6gnd2hh8q54bIts from Solidsnake That's only temporary saver. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted January 27, 2013 Author Posted January 27, 2013 I dunno, as everyone is using those functions on login and logout only made me a bit confused. Thanks mate addEventHandler("onPlayerWasted", root, function() if (account) then setAccountData(account, "save-wep0", getPedWeapon(source, 0)) setAccountData (account, "save-ammo0", getPedTotalAmmo (source, 0)) setAccountData(account, "save-wep1", getPedWeapon(source, 1)) setAccountData (account, "save-ammo1", getPedTotalAmmo (source, 1)) setAccountData(account, "save-wep2", getPedWeapon(source, 2)) setAccountData (account, "save-ammo2", getPedTotalAmmo (source, 2)) setAccountData(account, "save-wep3", getPedWeapon(source, 3)) setAccountData (account, "save-ammo3", getPedTotalAmmo (source, 3)) setAccountData(account, "save-wep4", getPedWeapon(source, 4)) setAccountData (account, "save-ammo4", getPedTotalAmmo (source, 4)) setAccountData(account, "save-wep5", getPedWeapon(source, 5)) setAccountData (account, "save-ammo5", getPedTotalAmmo (source, 5)) setAccountData(account, "save-wep6", getPedWeapon(source, 6)) setAccountData (account, "save-ammo6", getPedTotalAmmo (source, 6)) setAccountData(account, "save-wep7", getPedWeapon(source, 7)) setAccountData (account, "save-ammo7", getPedTotalAmmo (source, 7)) setAccountData(account, "save-wep8", getPedWeapon(source, -- s8) -->) setAccountData (account, "save-ammo8", getPedTotalAmmo (source, -- s8) -->) setAccountData(account, "save-wep9", getPedWeapon(source, 9)) setAccountData (account, "save-ammo9", getPedTotalAmmo (source, 9)) setAccountData(account, "save-wep10", getPedWeapon(source, 10)) setAccountData (account, "save-ammo10", getPedTotalAmmo (source, 10)) setAccountData(account, "save-wep11", getPedWeapon(source, 11)) setAccountData (account, "save-ammo11", getPedTotalAmmo (source, 11)) setAccountData(account, "save-wep12", getPedWeapon(source, 12)) setAccountData (account, "save-ammo12", getPedTotalAmmo (source, 12)) end end end ) addEventHandler("onPlayerSpawn", root, function() local account = getPlayerAccount(source) if not (isGuestAccount (getPlayerAccount (source))) then local wep1 = getAccountData(theCurrentAccount, "save-wep1") local ammo1 = getAccountData(theCurrentAccount, "save-ammo1") local wep2 = getAccountData(theCurrentAccount, "save-wep2") local ammo2 = getAccountData(theCurrentAccount, "save-ammo2") local wep3 = getAccountData(theCurrentAccount, "save-wep3") local ammo3 = getAccountData(theCurrentAccount, "save-ammo3") local wep4 = getAccountData(theCurrentAccount, "save-wep4") local ammo4 = getAccountData(theCurrentAccount, "save-ammo4") local wep5 = getAccountData(theCurrentAccount, "save-wep5") local ammo5 = getAccountData(theCurrentAccount, "save-ammo5") local wep6 = getAccountData(theCurrentAccount, "save-wep6") local ammo6 = getAccountData(theCurrentAccount, "save-ammo6") local wep7 = getAccountData(theCurrentAccount, "save-wep7") local ammo7 = getAccountData(theCurrentAccount, "save-ammo7") local wep8 = getAccountData(theCurrentAccount, "save-wep8") local ammo8 = getAccountData(theCurrentAccount, "save-ammo8") local wep9 = getAccountData(theCurrentAccount, "save-wep9") local ammo9 = getAccountData(theCurrentAccount, "save-ammo9") local wep10 = getAccountData(theCurrentAccount, "save-wep10") local ammo10 = getAccountData(theCurrentAccount, "save-ammo10") local wep11 = getAccountData(theCurrentAccount, "save-wep11") local ammo11 = getAccountData(theCurrentAccount, "save-ammo11") local wep12 = getAccountData(theCurrentAccount, "save-wep12") local ammo12 = getAccountData(theCurrentAccount, "save-ammo12") setElementData(source, "Occupation", occupation) spawnPlayer(source, x, y, z, interior, dimension) setElementHealth(source, health) setElementModel(source, skin) setPlayerTeam(source, getTeamFromName(team)) setPlayerMoney(source, money) setPedArmor(source, armor) setPlayerWantedLevel(source, wanted) giveWeapon(source, wep1, ammo1) giveWeapon(source, wep2, ammo2) giveWeapon(source, wep3, ammo3) giveWeapon(source, wep4, ammo4) giveWeapon(source, wep5, ammo5) giveWeapon(source, wep6, ammo6) giveWeapon(source, wep7, ammo7) giveWeapon(source, wep8, ammo8) giveWeapon(source, wep9, ammo9) giveWeapon(source, wep10, ammo10) giveWeapon(source, wep11, ammo11) giveWeapon(source, wep12, ammo12) end end ) Will this work?
Castillo Posted January 27, 2013 Posted January 27, 2013 What stops you from testing it? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 27, 2013 Posted January 27, 2013 What stops you from testing it? Haha, good point! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Baseplate Posted January 27, 2013 Author Posted January 27, 2013 I don't have MTA as my PC is totally fucked and doesn't meet reqruitements to run GTA SA
Castillo Posted January 27, 2013 Posted January 27, 2013 at "onPlayerWasted" event you forgot to define 'account', I've changed your script a bit: addEventHandler ( "onPlayerWasted", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then for slot = 1, 12 do setAccountData ( account, "save-wep".. slot, getPedWeapon ( source, slot ) ) setAccountData ( account, "save-ammo".. slot, getPedTotalAmmo ( source, slot ) ) end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) local account = getPlayerAccount ( source ) if ( account and not isGuestAccount ( account ) ) then setElementData ( source, "Occupation", occupation ) spawnPlayer ( source, x, y, z, interior, dimension ) setElementHealth ( source, health ) setElementModel ( source, skin ) setPlayerTeam ( source, getTeamFromName(team) ) setPlayerMoney ( source, money ) setPedArmor ( source, armor ) setPlayerWantedLevel ( source, wanted ) for slot = 1, 12 do local wep = getAccountData ( account, "save-wep".. slot ) local ammo = getAccountData ( account, "save-ammo".. slot ) giveWeapon ( source, wep, ammo ) end end end ) It works ( tested ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Baseplate Posted January 28, 2013 Author Posted January 28, 2013 Alright, thanks and I apologize cause it's just my PC became a total shit.
Castillo Posted January 28, 2013 Posted January 28, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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