BorderLine Posted August 2, 2012 Share Posted August 2, 2012 Hi everyone. Well i have a problem Im using solid code to save your weapons on dead My problem is. Why when a zombie killme and i have a weapon in my hand, then wen i spawn again i losse my weapons but when zombie killme when i dont have a weapon on slot then save weapons addEventHandler("onPlayerWasted", root, function() local weapons = convertWeaponsToJSON(source) setElementData(source,"tempWeapons",weapons) end ) addEventHandler("onPlayerSpawn", root, function () local weapons = getElementData(source,"tempWeapons") if (weapons) then giveWeaponsFromJSON(source, weapons) end end ) function convertWeaponsToJSON(player) local weaponSlots = 12 local weaponsTable = {} for slot=1 weaponSlots do local weapon = getPedWeapon( source, slot ) local ammo = getPedTotalAmmo( source, slot ) if (weapon > 0 and ammo > 0) then weaponsTable[weapon] = ammo end end return toJSON(weaponsTable) end function giveWeaponsFromJSON(player, weapons) if (weapons and weapons ~= "") then for weapon, ammo in pairs(fromJSON(weapons)) do if (weapon and ammo) then giveWeapon(player, tonumber(weapon), tonumber(ammo)) end end end end If anyone know about it Thanks for your time Link to comment
Jaysds1 Posted August 2, 2012 Share Posted August 2, 2012 try this and please read the comments: http://pastebin.com/JXU34cfT 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