Jump to content

Question


FuriouZ

Recommended Posts

Hey all!

I have problem, when player respawns, then only his money is saved, skin, weapon all other stuff is gone..

How to fix it ?

Save-system

  
 function savePlayerData () 
        if not (isGuestAccount (getPlayerAccount (source))) then 
        local playeraccount = getPlayerAccount ( source ) 
        if ( playeraccount ) then 
            local x,y,z = getElementPosition (source) 
            setAccountData (playeraccount, "save.MoneyInPocket", getPlayerMoney ( source ) ) 
            setAccountData (playeraccount, "save.skin", tostring (getPedSkin ( source))) 
            setAccountData (playeraccount, "save.x", x) 
            setAccountData (playeraccount, "save.y", y) 
            setAccountData (playeraccount, "save.z", z)  
            setAccountData (playeraccount, "save.int", getElementInterior ( source )) 
            setAccountData (playeraccount, "save.dim", getElementDimension ( source)) 
            setAccountData (playeraccount, "save.rot", getPedRotation ( source))             
            setAccountData (playeraccount, "save.weap0", getPedWeapon ( source, 0 )) 
            setAccountData (playeraccount, "save.weap1", getPedWeapon ( source, 1 )) 
            setAccountData (playeraccount, "save.weap2", getPedWeapon ( source, 2 )) 
            setAccountData (playeraccount, "save.ammo2", getPedTotalAmmo ( source, 2 )) 
            setAccountData (playeraccount, "save.weap3", getPedWeapon ( source, 3 )) 
            setAccountData (playeraccount, "save.ammo3", getPedTotalAmmo ( source, 3 )) 
            setAccountData (playeraccount, "save.weap4", getPedWeapon ( source, 4 )) 
            setAccountData (playeraccount, "save.ammo4", getPedTotalAmmo ( source, 4 )) 
            setAccountData (playeraccount, "save.weap5", getPedWeapon ( source, 5 )) 
            setAccountData (playeraccount, "save.ammo5", getPedTotalAmmo ( source, 5 )) 
            setAccountData (playeraccount, "save.weap6", getPedWeapon ( source, 6 )) 
            setAccountData (playeraccount, "save.ammo6", getPedTotalAmmo ( source, 6 )) 
            setAccountData (playeraccount, "save.weap7", getPedWeapon ( source, 7 )) 
            setAccountData (playeraccount, "save.ammo7", getPedTotalAmmo ( source, 7 )) 
            setAccountData (playeraccount, "save.weap8", getPedWeapon ( source, 8 )) 
            setAccountData (playeraccount, "save.ammo8", getPedTotalAmmo ( source, 8 )) 
            setAccountData (playeraccount, "save.weap9", getPedWeapon ( source, 9 )) 
            setAccountData (playeraccount, "save.ammo9", getPedTotalAmmo ( source, 9 )) 
            setAccountData (playeraccount, "save.weap10", getPedWeapon ( source, 10 )) 
            setAccountData (playeraccount, "save.weap11", getPedWeapon ( source, 11 )) 
            setAccountData (playeraccount, "save.weap12", getPedWeapon ( source, 12 )) 
            --# Skills 
            setAccountData (playeraccount, "save.Skill.Pistol", getPedStat( source, 69)) 
            setAccountData (playeraccount, "save.Skill.Silenced.Pistol", getPedStat( source, 70)) 
            setAccountData (playeraccount, "save.Skill.Desert.Eagle", getPedStat( source, 71)) 
            setAccountData (playeraccount, "save.Skill.Shotgun", getPedStat( source, 72)) 
            setAccountData (playeraccount, "save.Skill.Sawnoff.Shotgun", getPedStat( source, 73))        
            setAccountData (playeraccount, "save.Skill.SPAS12", getPedStat( source, 74))     
            setAccountData (playeraccount, "save.Skill.Uzi", getPedStat( source, 75))    
            setAccountData (playeraccount, "save.Skill.MP5", getPedStat( source, 76))    
            setAccountData (playeraccount, "save.Skill.AK47", getPedStat( source, 77)) 
            setAccountData (playeraccount, "save.Skill.M4", getPedStat( source, 78))     
            setAccountData (playeraccount, "save.Skill.Sniper.Rifle", getPedStat( source, 79)) 
            --# Classes 
            local isPlayerInClass = getPlayerTeam( source ) 
                if ( ( isPlayerInClass ) and not isGuestAccount( account ) ) then 
                    setAccountData(playeraccount, "save.Player.Class", getTeamName( isPlayerInClass )) 
                end          
      end 
      end 
    end 
    addEventHandler("onPlayerQuit", root, savePlayerData); 
    addEventHandler("onPlayerLogout", root, savePlayerData);     
  
  
  function loadPlayerData () 
    if not (isGuestAccount (getPlayerAccount (source))) then 
     local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playerMoneyInPocket = getAccountData ( playeraccount, "save.MoneyInPocket" ) 
            if ( playerMoneyInPocket ) then 
                  setPlayerMoney ( source, playerMoneyInPocket ) 
            end 
            local playerInt = getAccountData(playeraccount, "save.int") 
            local playerDim = getAccountData(playeraccount, "save.dim")   
            local playerSkin = getAccountData(playeraccount, "save.skin") 
            local playerX = getAccountData(playeraccount, "save.x") 
            local playerY = getAccountData(playeraccount, "save.y") 
            local playerZ = getAccountData(playeraccount, "save.z") 
            local playerRot = getAccountData(playeraccount, "save.rot") 
                spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
                fadeCamera (source, true) 
                setCameraTarget (source, source) 
            local weap0 = getAccountData(playeraccount, "save.weap0") 
            local weap1 = getAccountData(playeraccount, "save.weap1") 
            local weap2 = getAccountData(playeraccount, "save.weap2") 
            local ammo2 = getAccountData(playeraccount, "save.ammo2") 
            local weap3 = getAccountData(playeraccount, "save.weap3") 
            local ammo3 = getAccountData(playeraccount, "save.ammo3") 
            local weap4 = getAccountData(playeraccount, "save.weap4") 
            local ammo4 = getAccountData(playeraccount, "save.ammo4") 
            local weap5 = getAccountData(playeraccount, "save.weap5") 
            local ammo5 = getAccountData(playeraccount, "save.ammo5") 
            local weap6 = getAccountData(playeraccount, "save.weap6") 
            local ammo6 = getAccountData(playeraccount, "save.ammo6") 
            local weap7 = getAccountData(playeraccount, "save.weap7") 
            local ammo7 = getAccountData(playeraccount, "save.ammo7") 
            local weap8 = getAccountData(playeraccount, "save.weap8") 
            local ammo8 = getAccountData(playeraccount, "save.ammo8") 
            local weap9 = getAccountData(playeraccount, "save.weap9") 
            local ammo9 = getAccountData(playeraccount, "save.ammo9") 
            local weap10 = getAccountData(playeraccount, "save.weap10") 
            local weap11 = getAccountData(playeraccount, "save.weap11") 
            local weap12 = getAccountData(playeraccount, "save.weap12") 
                giveWeapon ( source, weap0, 1 ) 
                giveWeapon ( source, weap1, 1 ) 
                giveWeapon ( source, weap2, ammo2 ) 
                giveWeapon ( source, weap3, ammo3 ) 
                giveWeapon ( source, weap4, ammo4 ) 
                giveWeapon ( source, weap5, ammo5 ) 
                giveWeapon ( source, weap6, ammo6 ) 
                giveWeapon ( source, weap7, ammo7 ) 
                giveWeapon ( source, weap8, ammo8 ) 
                giveWeapon ( source, weap9, ammo9 ) 
                giveWeapon ( source, weap10, 1 ) 
                giveWeapon ( source, weap11, 1 ) 
                giveWeapon ( source, weap12, 1 ) 
            --# Skills               
            local Skill_Pistol = getAccountData(playeraccount, "save.Skill.Pistol")  
            local Skill_Silenced_Pistol = getAccountData(playeraccount, "save.Skill.Silenced.Pistol")    
            local Skill_Desert_Eagle = getAccountData(playeraccount, "save.Skill.Desert.Eagle")      
            local Skill_Shotgun = getAccountData(playeraccount, "save.Skill.Shotgun") 
            local Skill_Sawnoff_Shotgun = getAccountData(playeraccount, "save.Skill.Sawnoff.Shotgun") 
            local Skill_SPAS12 = getAccountData(playeraccount, "save.Skill.SPAS12")      
            local Skill_Uzi = getAccountData(playeraccount, "save.Skill.Uzi") 
            local Skill_MP5 = getAccountData(playeraccount, "save.Skill.MP5") 
            local Skill_AK47 = getAccountData(playeraccount, "save.Skill.AK47") 
            local Skill_M4 = getAccountData(playeraccount, "save.Skill.M4")  
            local Skill_Sniper_Rifle = getAccountData(playeraccount, "save.Skill.Sniper.Rifle")              
                setPedStat( source, 69, Skill_Pistol ) 
                setPedStat( source, 70, Skill_Silenced_Pistol ) 
                setPedStat( source, 71, Skill_Desert_Eagle ) 
                setPedStat( source, 72, Skill_Shotgun ) 
                setPedStat( source, 73, Skill_Sawnoff_Shotgun ) 
                setPedStat( source, 74, Skill_SPAS12 ) 
                setPedStat( source, 75, Skill_Uzi ) 
                setPedStat( source, 76, Skill_MP5 ) 
                setPedStat( source, 77, Skill_AK47 ) 
                setPedStat( source, 78, Skill_M4 ) 
                setPedStat( source, 79, Skill_Sniper_Rifle )     
            --# Classes 
            local isPedInClass = getAccountData (playeraccount, "save.Player.Class") 
                if ( ( isPedInClass ) and getTeamFromName( isPedInClass ) ) then 
                    setPlayerTeam(source, getTeamFromName( isPedInClass )) 
                end                      
      end 
      end 
  end 
  addEventHandler("onPlayerLogin", root, loadPlayerData) 
  addCommandHandler("loadSave", loadPlayerData)    
  

respawn

server:

addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        local playeraccount = getPlayerAccount ( source )        
        local playerSkin = getAccountData (playeraccount, "save.skin")   
            spawnPlayer( source, 1182.04358, -2223.13159, 43.62173, playerSkin ) 
         
    end 
) 

Link to comment
outputChatBox("playerAccount is:"..tostring(playeraccount).."Skin is"..tostring(playerSkin),source,0,255,0,true) 

put this on line 6, and see what will happen

playerAccount is:userdata: 02000039Skin is285 

As i understant, save system doesn't work or what ?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...