Destroyer.- Posted July 15, 2016 Share Posted July 15, 2016 Hola, encontre en el foro algo que deberia guardar al morir, guarda, pero si estoy muerto y me desconecto, se me va todas las armas, nose como podria reparar esto aca dejo el codigo local playerWeapons = { } addEventHandler ( "onPlayerWasted", root, function ( ) if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end end ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( playerWeapons [ source ] ) then for weapon, ammo in pairs ( playerWeapons [ source ] ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ) end end playerWeapons [ source ] = nil end ) 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("onPlayerWasted",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) Link to comment
Captain Cody Posted July 15, 2016 Share Posted July 15, 2016 (edited) Por favor, después de la sección española (Please post in spanish section) Edited July 15, 2016 by Guest Link to comment
Et-win Posted July 15, 2016 Share Posted July 15, 2016 Speak English in this section. Link to comment
Destroyer.- Posted July 16, 2016 Author Share Posted July 16, 2016 uff sorry, I was asleep when I made it. I'll open one in Spanish section, Close Please 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