_Vodka_ Posted March 3, 2014 Posted March 3, 2014 Boas a todos, eu precisava de um save system que funcione ja usei muitos saver's daqui da comunidade e nenhum funciono corretamente nao sei se e devido a versão nova do mta, mesmo assim preciso de um urgente porque no meu sv não salva armas, nem skin, nem dinheiro, nem mesmo ao fazer quit e ao entrar.
Stanley Sathler Posted March 3, 2014 Posted March 3, 2014 Se nenhum existente funciona, faça-os, Vodka. Eventos onPlayerLogin onPlayerQuit Funções setAccountData() // ou, em alguns casos setElementData()
_Vodka_ Posted March 3, 2014 Author Posted March 3, 2014 Obg por ter respondido, e sim vou tentar criar o meu proprio mais uma vez muito obrigado stanley
_Vodka_ Posted March 3, 2014 Author Posted March 3, 2014 Fiz um pequeno save so para armas mas nao sei porque que nao funciona peco ajuda a pessoas experientes para me ajudarem ou ao menos diserem onde esta o erro: localPlayerWeapons = { } addEventHandler ( "onPlayerWasted", Root , function () Local = getPedWeapon [source] ) then PlayerWeapon [source] = { } end local weapon = getPedWeapon (source, slot ) PlayerWeapons [source] [weapon] = ammo end end end ) addEventHandler ( "onPlayerSpawn", root, function () if playerWeapons [source] then (playerWeapons [source] ) do giveweapon (source, tonumber ( weapon ), tonumber (ammo ) ) end end playerWeapons [source] = nil end ) obrigado
DNL291 Posted March 3, 2014 Posted March 3, 2014 Se você usasse a barra de pesquisa ia encontrar isto: 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 ) Se você quer que a arma seja salva quando sair do servidor, precisará editar, usando as funções citadas acima.
_Vodka_ Posted March 4, 2014 Author Posted March 4, 2014 Não funciono não percebo porquê que não funciona já tentei com o seu DNL, mas também não funciono, já não sei o que fazer Esta tudo direito como deveria, mas não percebo o porque de não estar a funcionar
manawydan Posted March 4, 2014 Posted March 4, 2014 voce deve usa as funçoes citadas "setAccountData" para guardar uma data na conta de um jogador, porque o código só salva quando morre.
_Vodka_ Posted March 4, 2014 Author Posted March 4, 2014 nem ao morrer e ao fazer spawn salva ai esta o meu problema tambem.. por favor ajudem aqui :l
DNL291 Posted March 4, 2014 Posted March 4, 2014 Tente isto. Eu não testei. local playerWeapons = { } local onDeath = false 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 onDeath = true end end end end ) addEventHandler( "onPlayerQuit", root, function () local account = getPlayerAccount(source) if (account) and not isGuestAccount(account) then savePlayerWeapons(source, account) end if playerWeapons[source] then playerWeapons[source] = nil end end ) function savePlayerWeapons(player, account) if not player then return false end local tWeapons = {} for slot=0, 12 do local weapon = getPedWeapon(player, slot) local ammo = getPedTotalAmmo(player, slot) if (ammo > 0) then tWeapons[weapon] = ammo end end if account then setAccountData(account, "playerWeapons", toJSON(tWeapons)) end return toJSON(tWeapons) end function loadPlayerWeapons(player, onDeath, account) if not player then return false end if (onDeath == true) then if playerWeapons[player] then for weapon, ammo in pairs(playerWeapons[player]) do giveWeapon(player, weapon, ammo) end end return end if not account then return false end local weapons = getAccountData(account, "playerWeapons") if (weapons) then for weapon, ammo in pairs(fromJSON(weapons)) do giveWeapon(player, weapon, ammo, true) end end return weapons end addEventHandler( "onPlayerLogout", root, function (prevAcc) if savePlayerWeapons(source, prevAcc) then takeAllWeapons(source) end onDeath = false end ) addEventHandler( "onPlayerSpawn", root, function () local account = getPlayerAccount(source) if (account and isGuestAccount(account)) or (onDeath) then account = false end loadPlayerWeapons(source, onDeath, account) end )
_Vodka_ Posted March 5, 2014 Author Posted March 5, 2014 Muito obrigado agora salva as armas quando se morre e quando se sai muito obrigado DNL
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