zombienation Posted January 30, 2012 Share Posted January 30, 2012 hello, i was looking for something that saves the weapons when a player die and spawns, i know how to add weapons when they die and spawn, but i cant find it to make it save.. can anyone help me pls? thx Link to comment
Castillo Posted January 30, 2012 Share Posted January 30, 2012 You can check this topic: viewtopic.php?f=91&t=38456&p=400211 Link to comment
Evil-Cod3r Posted January 30, 2012 Share Posted January 30, 2012 Look Befoure You Ask ! https://community.multitheftauto.com/index.php?p= ... ls&id=2240 Link to comment
zombienation Posted January 31, 2012 Author Share Posted January 31, 2012 that is in my gamemode script, and weapons dont save after death, i wont ask it here if i know about the resource and if it would work with my mode, but thx for showing the weblink ! it do saves when u have weapons and reconnect Link to comment
Klesh Posted January 31, 2012 Share Posted January 31, 2012 Could you post the code if you have trouble with it? Link to comment
Castillo Posted January 31, 2012 Share Posted January 31, 2012 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 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