roaddog Posted June 12, 2014 Share Posted June 12, 2014 hello community I have a problem on this weapon saver, the problem is when the skin changed, all weapons gone. I really need help, since i had no idea how it came, sometime its saved, sometime its not 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 addEventHandler("onPlayerWasted", root, function() local weapons = convertWeaponsToJSON(source) setElementData(source,"tempWeapons",weapons) takeAllWeapons ( source ) 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 addEventHandler("onPlayerSpawn", root, function () local weapons = getElementData(source,"tempWeapons") if (weapons) then giveWeaponsFromJSON(source, weapons) removeElementData ( source, "tempWeapons" ) end end ) Link to comment
TAPL Posted June 12, 2014 Share Posted June 12, 2014 Maybe you have another resource that uses the event onElementModelChange. Link to comment
roaddog Posted June 12, 2014 Author Share Posted June 12, 2014 Ohh, I see. Im changing skin using admin panel, so it might use that event, Thankyou, I can fix it. Link to comment
TAPL Posted June 12, 2014 Share Posted June 12, 2014 Admin panel don't use the event onElementModelChange, it's use the function spawnPlayer to set your skin. 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