Jump to content

Weapon save and load onPlayerSpawn


Recommended Posts

function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function dead( account ) 
        spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
  
    local stats = getAccountData( account, "account.stats" ) 
     
    if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
         
    local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
end 
addEventHandler ("onPlayerWasted", root, dead) 
  

Still not working.

Error: 64:74: Bad argument @ 'getAccountData' [Expected account at argument 1, got number '0']

Read my message above. That explains why it isn't working.

Link to comment

Try this one

function saveAccount() 
    local account = getPlayerAccount( source ) 
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function dead() 
    spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
    local account = getPlayerAccount(source) 
    local stats = getAccountData( account, "account.stats" ) 
    if ( stats ) then 
            stats = fromJSON( stats ) 
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
    local weapons = getAccountData( account, "account.weapons" ) 
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
end 
addEventHandler ("onPlayerWasted", root, dead) 

Link to comment
Try this one
function saveAccount() 
    local account = getPlayerAccount( source ) 
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function dead() 
    spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
    local account = getPlayerAccount(source) 
    local stats = getAccountData( account, "account.stats" ) 
    if ( stats ) then 
            stats = fromJSON( stats ) 
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
    local weapons = getAccountData( account, "account.weapons" ) 
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
end 
addEventHandler ("onPlayerWasted", root, dead) 

Im stucked in spawnpoint

Link to comment
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
        fadeCamera(source, false) 
        setTimer(spawnPlayer, 1500, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
        setTimer(fadeCamera, 1500, 1, source, true) 
        setTimer(setCameraTarget, 2000, 1, source, source) 
        setTimer(takeAllWeapons, 2000, 1, source) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Link to comment
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
        fadeCamera(source, false) 
        setTimer(spawnPlayer, 1500, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
        setTimer(fadeCamera, 1500, 1, source, true) 
        setTimer(setCameraTarget, 2000, 1, source, source) 
        setTimer(takeAllWeapons, 2000, 1, source) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Working. But takeAllWeapons isnt my request HAHA. I want to load the previous weapon I had onPlayerSpawn

Link to comment
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
       local theWeapon = getPedWeapon(source) 
       local weaponAmmo = getPedTotalAmmo(source) 
       fadeCamera(source, false) 
       setTimer(spawnPlayer, 1500, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
       setTimer(fadeCamera, 1500, 1, source, true) 
       setTimer(setCameraTarget, 2000, 1, source, source) 
       setTimer(giveWeapon, 2000, 1, source, theWeapon, weaponAmmo) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Link to comment
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
       local theWeapon = getPedWeapon(source) 
       local weaponAmmo = getPedTotalAmmo(source) 
       fadeCamera(source, false) 
       setTimer(spawnPlayer, 1500, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
       setTimer(fadeCamera, 1500, 1, source, true) 
       setTimer(setCameraTarget, 2000, 1, source, source) 
       setTimer(giveWeapon, 2000, 1, source, theWeapon, weaponAmmo) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Its not loading weapons :(

Link to comment
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
       local theWeapon = getPedWeapon(source) 
       local weaponAmmo = getPedTotalAmmo(source) 
       fadeCamera(source, false) 
       setTimer(spawnPlayer, 1000, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
       setTimer(setCameraTarget, 1250, 1, source, source) 
       setTimer(fadeCamera, 2000, 1, source, true) 
       setTimer(giveWeapon, 2000, 1, source, theWeapon, weaponAmmo, true) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Edited by Guest
Link to comment
Its just the weapons thats not working. It still keeps on not loading any weapons. But no debugerrors and others works fine

You mus use sth like this

-- Give player weapons

addEventHandler("onPlayerSpawn", root, 
function ( ) 
    local account = getPlayerAccount(source) 
    if (account) and not (isGuestAccount(account)) then 
        local weapons = getAccountData(account, "weapons") 
        if (weapons) then 
            takeAllWeapons(source) 
            for weapon, ammo in pairs(fromJSON(weapons)) do 
                giveWeapon(source, weapon, ammo, true) 
            end 
        end 
    end  
end) 

-- Save player weapons when he die

addEventHandler("onPlayerWasted", root, 
function ( ) 
    local account = getPlayerAccount(source) 
    if (account) and not (isGuestAccount(account)) then 
        local weapons = getAllPedWeapon(source) 
        setAccountData(account, "weapons", toJSON(weapons)) 
    end 
end) 

-- check all player weapons

function getAllPedWeapon(thePed) 
    if (isPedDead(source)) then return end 
    local weapons = { } 
    for slot=1, 12 do 
        local weapon = getPedWeapon(thePed, slot) 
        local ammo = getPedTotalAmmo(thePed, slot) 
        if (weapon > 0) and (ammo > 0) then 
            weapons[weapon] = ammo 
        end 
    end 
    return weapons 
end 

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function onWasted(totalAmmo, killer, killerWeapon, bodypart , stealth) 
    if not isGuestAccount(getPlayerAccount(source)) then 
       local theWeapon = getPedWeapon(source) 
       local weaponAmmo = getPedTotalAmmo(source) 
       fadeCamera(source, false) 
       setTimer(spawnPlayer, 1500, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
       setTimer(fadeCamera, 1500, 1, source, true) 
       setTimer(setCameraTarget, 2000, 1, source, source) 
       setTimer(giveWeapon, 2000, 1, source, data.weapon, data.ammo) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

Ive changed theWeapon -->>data.weapon and weaponAmmo to data.ammo

and this errors show:69: attempt to index global 'data' (a nil value)

Link to comment
addEventHandler("onPlayerSpawn", root, 
function ( ) 
    local account = getPlayerAccount(source) 
    if (account) and not (isGuestAccount(account)) then 
        local weapons = getAccountData(account, "weapons") 
        if (weapons) then 
            takeAllWeapons(source) 
            for weapon, ammo in pairs(fromJSON(weapons)) do 
                giveWeapon(source, weapon, ammo, true) 
            end 
        end 
    end 
end) 
addEventHandler("onPlayerWasted", root, 
function ( ) 
    local account = getPlayerAccount(source) 
    if (account) and not (isGuestAccount(account)) then 
        local weapons = getAllPedWeapon(source) 
        setAccountData(account, "weapons", toJSON(weapons)) 
        fadeCamera(source, false) 
       setTimer(spawnPlayer, 1000, 1 , source, 2485, -1665, 13.5, 0, getPedSkin(source), 0 ,0) 
       setTimer(setCameraTarget, 1250, 1, source, source) 
       setTimer(fadeCamera, 2000, 1, source, true) 
    end 
end) 
function getAllPedWeapon(thePed) 
    if (isPedDead(source)) then return end 
    local weapons = { } 
    for slot=1, 12 do 
        local weapon = getPedWeapon(thePed, slot) 
        local ammo = getPedTotalAmmo(thePed, slot) 
        if (weapon > 0) and (ammo > 0) then 
            weapons[weapon] = ammo 
        end 
    end 
    return weapons 
end 

Here the code u gave. I just added spawn function upon onPlayerWasted. And this error shows

:8: bad argument #1 to 'pairs' (table expected, got nil)

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function onWasted() 
    spawnPlayer( source, 2485, -1665, 13.5) 
    if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
addEventHandler ("onPlayerWasted", root, onWasted) 

Can anyone pls help me with this. onWasted. It doesnt load any of my weapons but no error in debug.

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        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 
  
  
  
     

Can anyone pls help me with this. No error in debugscript but doesnt save skin , load weapons on death

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...