Daunii Posted March 29, 2012 Share Posted March 29, 2012 Hey, I'm back, with a short Request because I didn't found any working script here about it. What I think: - When I buy a weapon and ammo it's automatic safe it when I log out - When I connect to the Server it load my weapon. This one didn't worked: viewtopic.php?f=91&t=39910&p=405274&hilit=weapon+save#p405274 Link to comment
sckatchof Posted March 29, 2012 Share Posted March 29, 2012 i think this can help u : https://community.multitheftauto.com/index.php?p=resources&s=details&id=3940 Link to comment
-ffs-Sniper Posted March 29, 2012 Share Posted March 29, 2012 First of all, do not rape your caps. Using capital letters in your title only makes you look like an idiot (sorry for the hard word). Request? Maybe you should consult https://wiki.multitheftauto.com and read one of those LUA tutorials. A small hind: "onPlayerLogin" setAccountData "onPlayerQuit"/"onPlayerLogout" getAccountData giveWeapon This one didn't worked:viewtopic.php?f=91&t=39910&p=405274&hilit=weapon+save#p405274 Did you know it that it just saves the weapon stat, not the weapon? Link to comment
Daunii Posted March 30, 2012 Author Share Posted March 30, 2012 (edited) trying.. Edited April 1, 2012 by Guest Link to comment
Daunii Posted April 1, 2012 Author Share Posted April 1, 2012 Hey, function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) setAccountData (playeraccount, "s.int", getElementInterior (source)) setAccountData (playeraccount, "s.dim", getElementDimension (source)) setAccountData (playeraccount, "s.rot", getPedRotation (source)) setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogout ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) setAccountData (playeraccount, "s.int", getElementInterior (source)) setAccountData (playeraccount, "s.dim", getElementDimension (source)) setAccountData (playeraccount, "s.rot", getPedRotation (source)) setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) local root = getRootElement() addEventHandler("onPlayerLogin", root, function() local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "s.HandMoney" ) if ( playermoney ) then setPlayerMoney ( source, playermoney ) end local playerInt = getAccountData (playeraccount, "s.int") local playerDim = getAccountData (playeraccount, "s.dim") local playerSkin = getAccountData (playeraccount, "s.skin") local playerRot = getAccountData (playeraccount, "s.rot") local weap0 = getAccountData(playeraccount, "s.weap0") local weap1 = getAccountData(playeraccount, "s.weap1") local weap2 = getAccountData(playeraccount, "s.weap2") local ammo2 = getAccountData(playeraccount, "s.ammo2") local weap3 = getAccountData(playeraccount, "s.weap3") local ammo3 = getAccountData(playeraccount, "s.ammo3") local weap4 = getAccountData(playeraccount, "s.weap4") local ammo4 = getAccountData(playeraccount, "s.ammo4") local weap5 = getAccountData(playeraccount, "s.weap5") local ammo5 = getAccountData(playeraccount, "s.ammo5") local weap6 = getAccountData(playeraccount, "s.weap6") local ammo6 = getAccountData(playeraccount, "s.ammo6") local weap7 = getAccountData(playeraccount, "s.weap7") local ammo7 = getAccountData(playeraccount, "s.ammo7") local weap8 = getAccountData(playeraccount, "s.weap8") local ammo8 = getAccountData(playeraccount, "s.ammo8") local weap9 = getAccountData(playeraccount, "s.weap9") local ammo9 = getAccountData(playeraccount, "s.ammo9") local weap10 = getAccountData(playeraccount, "s.weap10") local weap11 = getAccountData(playeraccount, "s.weap11") local weap12 = getAccountData(playeraccount, "s.weap12") giveWeapon ( source, weap0, 1 ) giveWeapon ( source, weap1, 1 ) giveWeapon ( source, weap2, ammo2 ) giveWeapon ( source, weap3, ammo3 ) giveWeapon ( source, weap4, ammo4 ) giveWeapon ( source, weap5, ammo5 ) giveWeapon ( source, weap6, ammo6 ) giveWeapon ( source, weap7, ammo7 ) giveWeapon ( source, weap8, ammo8 ) giveWeapon ( source, weap9, ammo9 ) giveWeapon ( source, weap10, 1 ) giveWeapon ( source, weap11, 1 ) giveWeapon ( source, weap12, 1 ) end end ) Why this now don't work? Link to comment
Absence2 Posted April 1, 2012 Share Posted April 1, 2012 function saveWeapons(player, account) if player and account then for i=0,12 do local weapon = getPedWeapon(player, i) local ammo = getPedTotalAmmo(player, i) setAccountData(account,"w"..tonumber(i), weapon) setAccountData(account,"a"..tonumber(i), ammo) end takeAllWeapons(player) end end addEventHandler("onPlayerQuit",root,function () saveWeapons(source, getPlayerAccount(source)) end) addEventHandler("onPlayerLogout",root,function(prev) saveWeapons(source, prev) end) addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if not account or isGuestAccount(account) then return end for i=0,12 do local weapon = getAccountData(account,"w"..tonumber(i)) local ammo = getAccountData(account,"a"..tonumber(i)) if weapon and ammo then setTimer(giveWeapon, 1000, 1, source, tonumber(weapon), tonumber(ammo), true) end end end) I found this on the forums, I don't remember where though, I think it's Kenix's or Solidsnake's script. That should work, plus it's a LOT shorter, It's only to save guns Link to comment
Jaysds1 Posted April 1, 2012 Share Posted April 1, 2012 function saveWeapons(player, account) if player and account then for i=0,12 do local weapon = getPedWeapon(player, i) local ammo = getPedTotalAmmo(player, i) setAccountData(account,"w"..tonumber(i), weapon) setAccountData(account,"a"..tonumber(i), ammo) end takeAllWeapons(player) end end addEventHandler("onPlayerQuit",root,function () saveWeapons(source, getPlayerAccount(source)) end) addEventHandler("onPlayerLogout",root,function(prev) saveWeapons(source, prev) end) addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if not account or isGuestAccount(account) then return end for i=0,12 do local weapon = getAccountData(account,"w"..tonumber(i)) local ammo = getAccountData(account,"a"..tonumber(i)) if weapon and ammo then setTimer(giveWeapon, 1000, 1, source, tonumber(weapon), tonumber(ammo), true) end end end) I found this on the forums, I don't remember where though, I think it's Kenix's or Solidsnake's script. That should work, plus it's a LOT shorter, It's only to save guns Wow, I never thought of that 1 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