Jump to content

Skin-money-weapon spawn system


Agon

Recommended Posts

Hello I made this (1 or 2 months ago i think) with big helps of community scripters and I edited it recently. Hope you got what i'm trying to do but it gives errors. Line 4 expected account @ getPlayerAccount

Line 3 expected element @ getAccountData..

Hope you understood me :)

addEventHandler("onPlayerWasted", getRootElement(),  
function(source) 
local playerSkin = getAccountData( playerAccount, "player.skin" ) 
local playerAccount = getPlayerAccount( source ) 
if playerAccount then 
spawnPlayer(2155, -99, 3, 0, playerSkin) 
for i = 0,17 do 
local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
if not acc:find 'false'  then 
addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
  
      local playerMoney = getAccountData( playerAccount, "player.money" ) 
      local playerWeaponID0 = getAccountData (playerAccount, "player.weaponID0") 
      local playerWeaponID1 = getAccountData (playerAccount, "player.weaponID1") 
      local playerWeaponID2 = getAccountData (playerAccount, "player.weaponID2") 
      local playerWeaponID3 = getAccountData (playerAccount, "player.weaponID3") 
      local playerWeaponID4 = getAccountData (playerAccount, "player.weaponID4") 
      local playerWeaponID5 = getAccountData (playerAccount, "player.weaponID5") 
      local playerWeaponID6 = getAccountData (playerAccount, "player.weaponID6") 
      local playerWeaponID7 = getAccountData (playerAccount, "player.weaponID7") 
      local playerWeaponID8 = getAccountData (playerAccount, "player.weaponID8") 
      local playerWeaponID9 = getAccountData (playerAccount, "player.weaponID9") 
      local playerWeaponID10 = getAccountData (playerAccount, "player.weaponID10") 
      local playerWeaponID11 = getAccountData (playerAccount, "player.weaponID11") 
      local playerWeaponID12 = getAccountData (playerAccount, "player.weaponID12") 
      local playerWeaponAmmo0 = getAccountData (playerAccount, "player.weaponAmmo0") 
      local playerWeaponAmmo1 = getAccountData (playerAccount, "player.weaponAmmo1") 
      local playerWeaponAmmo2 = getAccountData (playerAccount, "player.weaponAmmo2") 
      local playerWeaponAmmo3 = getAccountData (playerAccount, "player.weaponAmmo3") 
      local playerWeaponAmmo4 = getAccountData (playerAccount, "player.weaponAmmo4") 
      local playerWeaponAmmo5 = getAccountData (playerAccount, "player.weaponAmmo5") 
      local playerWeaponAmmo6 = getAccountData (playerAccount, "player.weaponAmmo6") 
      local playerWeaponAmmo7 = getAccountData (playerAccount, "player.weaponAmmo7") 
      local playerWeaponAmmo8 = getAccountData (playerAccount, "player.weaponAmmo8") 
      local playerWeaponAmmo9 = getAccountData (playerAccount, "player.weaponAmmo9") 
      local playerWeaponAmmo10 = getAccountData (playerAccount, "player.weaponAmmo10") 
      local playerWeaponAmmo11 = getAccountData (playerAccount, "player.weaponAmmo11") 
      local playerWeaponAmmo12 = getAccountData (playerAccount, "player.weaponAmmo12") 
      setAccountData( playerAccount, "player.money", playerMoney ) 
      setAccountData (playerAccount, "player.weaponID0", getPedWeapon (source, 0)) 
      setAccountData (playerAccount, "player.weaponID1", getPedWeapon (source, 1)) 
      setAccountData (playerAccount, "player.weaponID2", getPedWeapon (source, 2)) 
      setAccountData (playerAccount, "player.weaponID3", getPedWeapon (source, 3)) 
      setAccountData (playerAccount, "player.weaponID4", getPedWeapon (source, 4)) 
      setAccountData (playerAccount, "player.weaponID5", getPedWeapon (source, 5)) 
      setAccountData (playerAccount, "player.weaponID6", getPedWeapon (source, 6)) 
      setAccountData (playerAccount, "player.weaponID7", getPedWeapon (source, 7)) 
      setAccountData (playerAccount, "player.weaponID8", getPedWeapon (source, 8 )) 
      setAccountData (playerAccount, "player.weaponID9", getPedWeapon (source, 9)) 
      setAccountData (playerAccount, "player.weaponID10", getPedWeapon (source, 10)) 
      setAccountData (playerAccount, "player.weaponID11", getPedWeapon (source, 11)) 
      setAccountData (playerAccount, "player.weaponID12", getPedWeapon (source, 12)) 
      setAccountData (playerAccount, "player.weaponAmmo0", getPedTotalAmmo (source, 0)) 
      setAccountData (playerAccount, "player.weaponAmmo1", getPedTotalAmmo (source, 1)) 
      setAccountData (playerAccount, "player.weaponAmmo2", getPedTotalAmmo (source, 2)) 
      setAccountData (playerAccount, "player.weaponAmmo3", getPedTotalAmmo (source, 3)) 
      setAccountData (playerAccount, "player.weaponAmmo4", getPedTotalAmmo (source, 4)) 
      setAccountData (playerAccount, "player.weaponAmmo5", getPedTotalAmmo (source, 5)) 
      setAccountData (playerAccount, "player.weaponAmmo6", getPedTotalAmmo (source, 6)) 
      setAccountData (playerAccount, "player.weaponAmmo7", getPedTotalAmmo (source, 7)) 
      setAccountData (playerAccount, "player.weaponAmmo8", getPedTotalAmmo (source, 8 )) 
      setAccountData (playerAccount, "player.weaponAmmo9", getPedTotalAmmo (source, 9)) 
      setAccountData (playerAccount, "player.weaponAmmo10", getPedTotalAmmo (source, 10)) 
      setAccountData (playerAccount, "player.weaponAmmo11", getPedTotalAmmo (source, 11)) 
      setAccountData (playerAccount, "player.weaponAmmo12", getPedTotalAmmo (source, 12)) 
      giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
else spawnPlayer(2155, -99, 3, 0, math.random(0, 258)) 
          end 
      end 
   end 
end 
) 
  
  
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 
  
  
  
addEventHandler( "onPlayerQuit", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerMoney = getPlayerMoney( source ) 
      setAccountData (playerAccount, "player.weaponID0", getPedWeapon (source, 0)) 
      setAccountData (playerAccount, "player.weaponID1", getPedWeapon (source, 1)) 
      setAccountData (playerAccount, "player.weaponID2", getPedWeapon (source, 2)) 
      setAccountData (playerAccount, "player.weaponID3", getPedWeapon (source, 3)) 
      setAccountData (playerAccount, "player.weaponID4", getPedWeapon (source, 4)) 
      setAccountData (playerAccount, "player.weaponID5", getPedWeapon (source, 5)) 
      setAccountData (playerAccount, "player.weaponID6", getPedWeapon (source, 6)) 
      setAccountData (playerAccount, "player.weaponID7", getPedWeapon (source, 7)) 
      setAccountData (playerAccount, "player.weaponID8", getPedWeapon (source, 8 )) 
      setAccountData (playerAccount, "player.weaponID9", getPedWeapon (source, 9)) 
      setAccountData (playerAccount, "player.weaponID10", getPedWeapon (source, 10)) 
      setAccountData (playerAccount, "player.weaponID11", getPedWeapon (source, 11)) 
      setAccountData (playerAccount, "player.weaponID12", getPedWeapon (source, 12)) 
      setAccountData (playerAccount, "player.weaponAmmo0", getPedTotalAmmo (source, 0)) 
      setAccountData (playerAccount, "player.weaponAmmo1", getPedTotalAmmo (source, 1)) 
      setAccountData (playerAccount, "player.weaponAmmo2", getPedTotalAmmo (source, 2)) 
      setAccountData (playerAccount, "player.weaponAmmo3", getPedTotalAmmo (source, 3)) 
      setAccountData (playerAccount, "player.weaponAmmo4", getPedTotalAmmo (source, 4)) 
      setAccountData (playerAccount, "player.weaponAmmo5", getPedTotalAmmo (source, 5)) 
      setAccountData (playerAccount, "player.weaponAmmo6", getPedTotalAmmo (source, 6)) 
      setAccountData (playerAccount, "player.weaponAmmo7", getPedTotalAmmo (source, 7)) 
      setAccountData (playerAccount, "player.weaponAmmo8", getPedTotalAmmo (source, 8 )) 
      setAccountData (playerAccount, "player.weaponAmmo9", getPedTotalAmmo (source, 9)) 
      setAccountData (playerAccount, "player.weaponAmmo10", getPedTotalAmmo (source, 10)) 
      setAccountData (playerAccount, "player.weaponAmmo11", getPedTotalAmmo (source, 11)) 
      setAccountData (playerAccount, "player.weaponAmmo12", getPedTotalAmmo (source, 12)) 
      setAccountData( playerAccount, "player.money", playerMoney ) 
        end 
    end 
)    
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
      local playerWeaponID0 = getAccountData (playerAccount, "player.weaponID0") 
      local playerWeaponID1 = getAccountData (playerAccount, "player.weaponID1") 
      local playerWeaponID2 = getAccountData (playerAccount, "player.weaponID2") 
      local playerWeaponID3 = getAccountData (playerAccount, "player.weaponID3") 
      local playerWeaponID4 = getAccountData (playerAccount, "player.weaponID4") 
      local playerWeaponID5 = getAccountData (playerAccount, "player.weaponID5") 
      local playerWeaponID6 = getAccountData (playerAccount, "player.weaponID6") 
      local playerWeaponID7 = getAccountData (playerAccount, "player.weaponID7") 
      local playerWeaponID8 = getAccountData (playerAccount, "player.weaponID8") 
      local playerWeaponID9 = getAccountData (playerAccount, "player.weaponID9") 
      local playerWeaponID10 = getAccountData (playerAccount, "player.weaponID10") 
      local playerWeaponID11 = getAccountData (playerAccount, "player.weaponID11") 
      local playerWeaponID12 = getAccountData (playerAccount, "player.weaponID12") 
      local playerWeaponAmmo0 = getAccountData (playerAccount, "player.weaponAmmo0") 
      local playerWeaponAmmo1 = getAccountData (playerAccount, "player.weaponAmmo1") 
      local playerWeaponAmmo2 = getAccountData (playerAccount, "player.weaponAmmo2") 
      local playerWeaponAmmo3 = getAccountData (playerAccount, "player.weaponAmmo3") 
      local playerWeaponAmmo4 = getAccountData (playerAccount, "player.weaponAmmo4") 
      local playerWeaponAmmo5 = getAccountData (playerAccount, "player.weaponAmmo5") 
      local playerWeaponAmmo6 = getAccountData (playerAccount, "player.weaponAmmo6") 
      local playerWeaponAmmo7 = getAccountData (playerAccount, "player.weaponAmmo7") 
      local playerWeaponAmmo8 = getAccountData (playerAccount, "player.weaponAmmo8") 
      local playerWeaponAmmo9 = getAccountData (playerAccount, "player.weaponAmmo9") 
      local playerWeaponAmmo10 = getAccountData (playerAccount, "player.weaponAmmo10") 
      local playerWeaponAmmo11 = getAccountData (playerAccount, "player.weaponAmmo11") 
      local playerWeaponAmmo12 = getAccountData (playerAccount, "player.weaponAmmo12") 
      setPlayerMoney( source, playerMoney ) 
      giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
  
            end 
        end  
) 

Edited by Guest
Link to comment

first you need to get the player acco8unt and after it you can edit it you firs't wanna edit it and only after to get the account

and the source is comming whit onPlayerWasted you don't need to define it in the function

Try this i don't look at the full code i only fix the error in line 3,4

addEventHandler("onPlayerWasted", getRootElement(), 
function() 
local playerAccount = getPlayerAccount( source ) 
if playerAccount then 
local playerSkin = getAccountData( playerAccount, "player.skin" ) 
spawnPlayer(2155, -99, 3, 0, playerSkin) 
for i = 0,17 do 
local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
if not acc:find 'false'  then 
addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
  
      local playerMoney = getAccountData( playerAccount, "player.money" ) 
      local playerWeaponID0 = getAccountData (playerAccount, "player.weaponID0") 
      local playerWeaponID1 = getAccountData (playerAccount, "player.weaponID1") 
      local playerWeaponID2 = getAccountData (playerAccount, "player.weaponID2") 
      local playerWeaponID3 = getAccountData (playerAccount, "player.weaponID3") 
      local playerWeaponID4 = getAccountData (playerAccount, "player.weaponID4") 
      local playerWeaponID5 = getAccountData (playerAccount, "player.weaponID5") 
      local playerWeaponID6 = getAccountData (playerAccount, "player.weaponID6") 
      local playerWeaponID7 = getAccountData (playerAccount, "player.weaponID7") 
      local playerWeaponID8 = getAccountData (playerAccount, "player.weaponID8") 
      local playerWeaponID9 = getAccountData (playerAccount, "player.weaponID9") 
      local playerWeaponID10 = getAccountData (playerAccount, "player.weaponID10") 
      local playerWeaponID11 = getAccountData (playerAccount, "player.weaponID11") 
      local playerWeaponID12 = getAccountData (playerAccount, "player.weaponID12") 
      local playerWeaponAmmo0 = getAccountData (playerAccount, "player.weaponAmmo0") 
      local playerWeaponAmmo1 = getAccountData (playerAccount, "player.weaponAmmo1") 
      local playerWeaponAmmo2 = getAccountData (playerAccount, "player.weaponAmmo2") 
      local playerWeaponAmmo3 = getAccountData (playerAccount, "player.weaponAmmo3") 
      local playerWeaponAmmo4 = getAccountData (playerAccount, "player.weaponAmmo4") 
      local playerWeaponAmmo5 = getAccountData (playerAccount, "player.weaponAmmo5") 
      local playerWeaponAmmo6 = getAccountData (playerAccount, "player.weaponAmmo6") 
      local playerWeaponAmmo7 = getAccountData (playerAccount, "player.weaponAmmo7") 
      local playerWeaponAmmo8 = getAccountData (playerAccount, "player.weaponAmmo8") 
      local playerWeaponAmmo9 = getAccountData (playerAccount, "player.weaponAmmo9") 
      local playerWeaponAmmo10 = getAccountData (playerAccount, "player.weaponAmmo10") 
      local playerWeaponAmmo11 = getAccountData (playerAccount, "player.weaponAmmo11") 
      local playerWeaponAmmo12 = getAccountData (playerAccount, "player.weaponAmmo12") 
      setAccountData( playerAccount, "player.money", playerMoney ) 
      setAccountData (playerAccount, "player.weaponID0", getPedWeapon (source, 0)) 
      setAccountData (playerAccount, "player.weaponID1", getPedWeapon (source, 1)) 
      setAccountData (playerAccount, "player.weaponID2", getPedWeapon (source, 2)) 
      setAccountData (playerAccount, "player.weaponID3", getPedWeapon (source, 3)) 
      setAccountData (playerAccount, "player.weaponID4", getPedWeapon (source, 4)) 
      setAccountData (playerAccount, "player.weaponID5", getPedWeapon (source, 5)) 
      setAccountData (playerAccount, "player.weaponID6", getPedWeapon (source, 6)) 
      setAccountData (playerAccount, "player.weaponID7", getPedWeapon (source, 7)) 
      setAccountData (playerAccount, "player.weaponID8", getPedWeapon (source, -- s8) -->) 
      setAccountData (playerAccount, "player.weaponID9", getPedWeapon (source, 9)) 
      setAccountData (playerAccount, "player.weaponID10", getPedWeapon (source, 10)) 
      setAccountData (playerAccount, "player.weaponID11", getPedWeapon (source, 11)) 
      setAccountData (playerAccount, "player.weaponID12", getPedWeapon (source, 12)) 
      setAccountData (playerAccount, "player.weaponAmmo0", getPedTotalAmmo (source, 0)) 
      setAccountData (playerAccount, "player.weaponAmmo1", getPedTotalAmmo (source, 1)) 
      setAccountData (playerAccount, "player.weaponAmmo2", getPedTotalAmmo (source, 2)) 
      setAccountData (playerAccount, "player.weaponAmmo3", getPedTotalAmmo (source, 3)) 
      setAccountData (playerAccount, "player.weaponAmmo4", getPedTotalAmmo (source, 4)) 
      setAccountData (playerAccount, "player.weaponAmmo5", getPedTotalAmmo (source, 5)) 
      setAccountData (playerAccount, "player.weaponAmmo6", getPedTotalAmmo (source, 6)) 
      setAccountData (playerAccount, "player.weaponAmmo7", getPedTotalAmmo (source, 7)) 
      setAccountData (playerAccount, "player.weaponAmmo8", getPedTotalAmmo (source, -- s8) -->) 
      setAccountData (playerAccount, "player.weaponAmmo9", getPedTotalAmmo (source, 9)) 
      setAccountData (playerAccount, "player.weaponAmmo10", getPedTotalAmmo (source, 10)) 
      setAccountData (playerAccount, "player.weaponAmmo11", getPedTotalAmmo (source, 11)) 
      setAccountData (playerAccount, "player.weaponAmmo12", getPedTotalAmmo (source, 12)) 
      giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
else spawnPlayer(2155, -99, 3, 0, math.random(0, 258)) 
          end 
      end 
   end 
end 
) 
  
  
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 
  
  
  
addEventHandler( "onPlayerQuit", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerMoney = getPlayerMoney( source ) 
      setAccountData (playerAccount, "player.weaponID0", getPedWeapon (source, 0)) 
      setAccountData (playerAccount, "player.weaponID1", getPedWeapon (source, 1)) 
      setAccountData (playerAccount, "player.weaponID2", getPedWeapon (source, 2)) 
      setAccountData (playerAccount, "player.weaponID3", getPedWeapon (source, 3)) 
      setAccountData (playerAccount, "player.weaponID4", getPedWeapon (source, 4)) 
      setAccountData (playerAccount, "player.weaponID5", getPedWeapon (source, 5)) 
      setAccountData (playerAccount, "player.weaponID6", getPedWeapon (source, 6)) 
      setAccountData (playerAccount, "player.weaponID7", getPedWeapon (source, 7)) 
      setAccountData (playerAccount, "player.weaponID8", getPedWeapon (source, -- s8) -->) 
      setAccountData (playerAccount, "player.weaponID9", getPedWeapon (source, 9)) 
      setAccountData (playerAccount, "player.weaponID10", getPedWeapon (source, 10)) 
      setAccountData (playerAccount, "player.weaponID11", getPedWeapon (source, 11)) 
      setAccountData (playerAccount, "player.weaponID12", getPedWeapon (source, 12)) 
      setAccountData (playerAccount, "player.weaponAmmo0", getPedTotalAmmo (source, 0)) 
      setAccountData (playerAccount, "player.weaponAmmo1", getPedTotalAmmo (source, 1)) 
      setAccountData (playerAccount, "player.weaponAmmo2", getPedTotalAmmo (source, 2)) 
      setAccountData (playerAccount, "player.weaponAmmo3", getPedTotalAmmo (source, 3)) 
      setAccountData (playerAccount, "player.weaponAmmo4", getPedTotalAmmo (source, 4)) 
      setAccountData (playerAccount, "player.weaponAmmo5", getPedTotalAmmo (source, 5)) 
      setAccountData (playerAccount, "player.weaponAmmo6", getPedTotalAmmo (source, 6)) 
      setAccountData (playerAccount, "player.weaponAmmo7", getPedTotalAmmo (source, 7)) 
      setAccountData (playerAccount, "player.weaponAmmo8", getPedTotalAmmo (source, -- s8) -->) 
      setAccountData (playerAccount, "player.weaponAmmo9", getPedTotalAmmo (source, 9)) 
      setAccountData (playerAccount, "player.weaponAmmo10", getPedTotalAmmo (source, 10)) 
      setAccountData (playerAccount, "player.weaponAmmo11", getPedTotalAmmo (source, 11)) 
      setAccountData (playerAccount, "player.weaponAmmo12", getPedTotalAmmo (source, 12)) 
      setAccountData( playerAccount, "player.money", playerMoney ) 
        end 
    end 
)   
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
      local playerWeaponID0 = getAccountData (playerAccount, "player.weaponID0") 
      local playerWeaponID1 = getAccountData (playerAccount, "player.weaponID1") 
      local playerWeaponID2 = getAccountData (playerAccount, "player.weaponID2") 
      local playerWeaponID3 = getAccountData (playerAccount, "player.weaponID3") 
      local playerWeaponID4 = getAccountData (playerAccount, "player.weaponID4") 
      local playerWeaponID5 = getAccountData (playerAccount, "player.weaponID5") 
      local playerWeaponID6 = getAccountData (playerAccount, "player.weaponID6") 
      local playerWeaponID7 = getAccountData (playerAccount, "player.weaponID7") 
      local playerWeaponID8 = getAccountData (playerAccount, "player.weaponID8") 
      local playerWeaponID9 = getAccountData (playerAccount, "player.weaponID9") 
      local playerWeaponID10 = getAccountData (playerAccount, "player.weaponID10") 
      local playerWeaponID11 = getAccountData (playerAccount, "player.weaponID11") 
      local playerWeaponID12 = getAccountData (playerAccount, "player.weaponID12") 
      local playerWeaponAmmo0 = getAccountData (playerAccount, "player.weaponAmmo0") 
      local playerWeaponAmmo1 = getAccountData (playerAccount, "player.weaponAmmo1") 
      local playerWeaponAmmo2 = getAccountData (playerAccount, "player.weaponAmmo2") 
      local playerWeaponAmmo3 = getAccountData (playerAccount, "player.weaponAmmo3") 
      local playerWeaponAmmo4 = getAccountData (playerAccount, "player.weaponAmmo4") 
      local playerWeaponAmmo5 = getAccountData (playerAccount, "player.weaponAmmo5") 
      local playerWeaponAmmo6 = getAccountData (playerAccount, "player.weaponAmmo6") 
      local playerWeaponAmmo7 = getAccountData (playerAccount, "player.weaponAmmo7") 
      local playerWeaponAmmo8 = getAccountData (playerAccount, "player.weaponAmmo8") 
      local playerWeaponAmmo9 = getAccountData (playerAccount, "player.weaponAmmo9") 
      local playerWeaponAmmo10 = getAccountData (playerAccount, "player.weaponAmmo10") 
      local playerWeaponAmmo11 = getAccountData (playerAccount, "player.weaponAmmo11") 
      local playerWeaponAmmo12 = getAccountData (playerAccount, "player.weaponAmmo12") 
      setPlayerMoney( source, playerMoney ) 
      giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
  
            end 
        end 
) 

Link to comment

Try

addEventHandler("onPlayerWasted", root, 
    function() 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer( 2155, -99, 3, 0, tonumber( playerSkin ) ) 
            else  
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
  
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 
  
  
addEventHandler( "onPlayerQuit", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerMoney = getPlayerMoney( source ) 
            setAccountData( playerAccount, "player.money", playerMoney ) 
            for i = 1,12 do 
                setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
                setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
            end 
        end 
    end 
)   
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo or 0 ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
        end 
    end 
) 

Link to comment
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
  
function fLogout( ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount then 
        local playerMoney = getPlayerMoney( source ) 
        --local nSkin = getElementModel( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
        --setAccountData( playerAccount, "player.skin", nSkin ) 
        for i = 1,12 do 
            setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
            setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
        end 
    end 
end 
addEventHandler( 'onPlayerLogout', root, fLogout ) 
addEventHandler( 'onPlayerQuit', root, fLogout ) 
  
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ),tonumber( playerSkin ) ) 
            else  
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 

Updated.

Link to comment
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
  
function fLogout (account) 
    if (account and type(account) == "string") then 
        playerAccount = getPlayerAccount( source ) 
    elseif (type(account) == "userdata") then 
        playerAccount = account 
    end 
    if playerAccount then 
        local playerMoney = getPlayerMoney( source ) 
        --local nSkin = getElementModel( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
        --setAccountData( playerAccount, "player.skin", nSkin ) 
        for i = 1,12 do 
            setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
            setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
        end 
    end 
end 
addEventHandler( 'onPlayerLogout', root, fLogout ) 
addEventHandler( 'onPlayerQuit', root, fLogout ) 
  
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ),tonumber( playerSkin ) ) 
            else 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 

I've tested it and works, it saves on quit and logout.

Link to comment

When a player logs out, getPlayerAccount will return as "Guest", you have to use the "previous account" argument, that's what I've changed.

if (account and type(account) == "string") then 
        playerAccount = getPlayerAccount( source ) 
    elseif (type(account) == "userdata") then 
       playerAccount = account 
end 

Link to comment

Oh ye, little mistake.

You can create only one condition.

if not isGuestAccount( playerAccount ) then 

It's better

function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
  
function fLogout ( uLastAccount ) 
    local playerAccount  = uLastAccount and type( uLastAccount ) == "userdata" and uLastAccount or getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        local playerMoney = getPlayerMoney( source ) 
        --local nSkin = getElementModel( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
        --setAccountData( playerAccount, "player.skin", nSkin ) 
        for i = 1,12 do 
            setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
            setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
        end 
    end 
end 
addEventHandler( 'onPlayerLogout', root, fLogout ) 
addEventHandler( 'onPlayerQuit', root, fLogout ) 
  
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount and not isGuestAccount( playerAccount ) then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ),tonumber( playerSkin ) ) 
            else 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 

Edited by Guest
Link to comment
 local playerAccount  = uLastAccount and type( uLastAccount ) == "userdata" and uLastAccount or getPlayerAccount( source ) 

It's better.

If you not see.

You think it wrong?

For you.

  
local var = 0 
return var == 0 and 'ye' or 'bad' --> ye 
  

Also

  
local var = 0 
return var == 0 --> true ( If not, it return false. ) 
  

Link to comment

Sorry for double post but i just found out that when i die, it doesn't give me my weapons. It spawn with my skin but doesn't give my weapons :( i tried giving weapons after spawning (yours gives before spawning) but didn't work :(

Link to comment
local uTimers = { } 
  
function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
  
function fLogout ( uLastAccount ) 
    local playerAccount  = uLastAccount and type( uLastAccount ) == "userdata" and uLastAccount or getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        local playerMoney = getPlayerMoney( source ) 
        --local nSkin = getElementModel( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
        --setAccountData( playerAccount, "player.skin", nSkin ) 
        for i = 1,12 do 
            setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
            setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
        end 
    end 
    uTimers[ source ] = nil 
end 
addEventHandler( 'onPlayerLogout', root, fLogout ) 
addEventHandler( 'onPlayerQuit', root, fLogout ) 
  
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount and not isGuestAccount( playerAccount ) then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ),tonumber( playerSkin ) ) 
            else 
                spawnPlayer( 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
addEventHandler( 'onPlayerSpawn', root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount and not isGuestAccount( playerAccount ) then 
            if isTimer( uTimers[ source ] ) then 
                killTimer( uTimers[ source ] ) 
            end 
            uTimers[ source ] = setTimer( 
                function( source, playerAccount ) 
                    for i = 1,12 do 
                        local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                        local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                        giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
                    end 
                end, 
            1000, 
            1, source, playerAccount )   
        end  
    end 
)    
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 

Sorry for double post but i just found out that when i die, it doesn't give me my weapons. It spawn with my skin but doesn't give my weapons i tried giving weapons after spawning (yours gives before spawning) but didn't work

Yeah, because it not write in code.

Maybe, you yourself create it in next time?

P.S It's not good ask members of the forum, they wrote for you. You need write yourself.

Link to comment

no way it doesn't give me weapons..

Yeah, because it not write in code.

Maybe, you yourself create it in next time?

P.S It's not good ask members of the forum, they wrote for you. You need write yourself.

I didn't want anybody to make script for me.. I just wanted them to correct my script errors :|

Link to comment

it doesn't.. and i tried this: this is what i've come with your helps.. (I added the weapon thingy) but can't get the weapons.

function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", getElementModel( source ) ) 
        outputChatBox("#FF0000*INFO: #0095FFYour skin was successfully saved!", source, 0, 255, 0, true) 
    end 
end 
  
function fLogout (account) 
    if (account and type(account) == "string") then 
        playerAccount = getPlayerAccount( source ) 
    elseif (type(account) == "userdata") then 
        playerAccount = account 
    end 
    if playerAccount then 
        local playerMoney = getPlayerMoney( source ) 
        local nSkin = getElementModel( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
        setAccountData( playerAccount, "player.skin", nSkin ) 
        for i = 1,12 do 
            setAccountData ( playerAccount, "player.weaponID" .. tostring( i ), getPedWeapon ( source, i ) ) 
            setAccountData ( playerAccount, "player.weaponAmmo" .. tostring( i ), getPedTotalAmmo ( source, i ) ) 
        end 
    end 
end 
addEventHandler( 'onPlayerLogout', root, fLogout ) 
addEventHandler( 'onPlayerQuit', root, fLogout ) 
  
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
        local playerMoney = getPlayerMoney( source ) 
        setAccountData( playerAccount, "player.money", playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer(source, 2155, -99, 3, 0, tonumber( playerSkin ) ) 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            else 
                spawnPlayer(source, 2155, -99, 3, 0, math.random( 0, 258 ) ) 
            end 
        end 
    end 
) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            for i = 1,12 do 
                local nWeapon = getAccountData ( playerAccount, "player.weaponID" ..tostring( i ) ) 
                local nAmmo = getAccountData ( playerAccount, "player.weaponAmmo" ..tostring( i ) ) 
                giveWeapon( source, tonumber( nWeapon ), tonumber( nAmmo ), tonumber ( nWeapon ) == 1 ) 
            end 
            local playerMoney = getAccountData( playerAccount, "player.money" ) 
            setPlayerMoney( source, playerMoney ) 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 

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