zombienation Posted January 30, 2012 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
Castillo Posted January 30, 2012 Posted January 30, 2012 You can check this topic: viewtopic.php?f=91&t=38456&p=400211 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Evil-Cod3r Posted January 30, 2012 Posted January 30, 2012 Look Befoure You Ask ! https://community.multitheftauto.com/index.php?p= ... ls&id=2240 My in-game nick is |['Dev-PoinT_SA']| addEventHandler ( "onPlayerSpawn", getRootElement(), function() if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then triggerClientEvent("BlaBlaBla",getRootElement()) DxDrawText("Hi Dev-PoinT") end end)
zombienation Posted January 31, 2012 Author 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
Klesh Posted January 31, 2012 Posted January 31, 2012 Could you post the code if you have trouble with it? My resources : playerpartFromName: Exported function.
Castillo Posted January 31, 2012 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 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