Jump to content

save/load skin slot with a bind key


DarkBeautyDZ

Recommended Posts

Hi guys i'm trying to make a save system to save and load skin on command , i have another script but i don't know how to add a command handler to it :

function onPlayerSpawn ( )
      local playeraccount = getPlayerAccount ( source )
      if ( playeraccount ) then
            local playerskin = getAccountData ( playeraccount, "skin1" )
            if ( playerskin ) then
            setPedSkin ( source, playerskin )
            end
      end
end

function onPlayerWasted ( )
      local playeraccount = getPlayerAccount ( source )
      if ( playeraccount ) then
            local playerskin = getPedSkin ( source )
            setAccountData ( playeraccount, "skin1", playerskin )
      end
end 

addEventHandler ( "onPlayerSpawn", getRootElement ( ), onPlayerSpawn )
addEventHandler ( "onPlayerWasted", getRootElement ( ), onPlayerWasted )

..............................

PS. i want to control it more by command and not an event .

Edited by DarkBeautyDZ
Link to comment

https://forum.multitheftauto.com/topic/113331-skins-save-system-resource-script-need-help/?tab=comments#comment-938686

 

getPedSkin is deprecated, please use this: https://wiki.multitheftauto.com/wiki/GetElementModel

And setPedSkin is deprecated too, use this instead: https://wiki.multitheftauto.com/wiki/SetElementModel

If you want commands, you should know how addCommandHandler works: https://wiki.multitheftauto.com/wiki/AddCommandHandler

function onPlayerSpawn ( player )
      local playeraccount = getPlayerAccount ( player )
      if ( playeraccount ) then
            local playerskin = getAccountData ( playeraccount, "skin1" )
            if ( playerskin ) then
            setElementModel ( source, playerskin )
            end
      end
end
addCommandHandler('save', onPlayerSpawn, false, false)

function onPlayerWasted ( player )
      local playeraccount = getPlayerAccount ( source )
      if ( playeraccount ) then
            local playerskin = getElementModel ( source )
            setAccountData ( playeraccount, "skin1", playerskin )
      end
end 
addCommandHandler('load', onPlayerWasted, false, false)

 

Edited by Peti
Link to comment
6 hours ago, Peti said:

https://forum.multitheftauto.com/topic/113331-skins-save-system-resource-script-need-help/?tab=comments#comment-938686

 

getPedSkin is deprecated, please use this: https://wiki.multitheftauto.com/wiki/GetElementModel

And setPedSkin is deprecated too, use this instead: https://wiki.multitheftauto.com/wiki/SetElementModel

If you want commands, you should know how addCommandHandler works: https://wiki.multitheftauto.com/wiki/AddCommandHandler


function onPlayerSpawn ( player )
      local playeraccount = getPlayerAccount ( player )
      if ( playeraccount ) then
            local playerskin = getAccountData ( playeraccount, "skin1" )
            if ( playerskin ) then
            setElementModel ( source, playerskin )
            end
      end
end
addCommandHandler('save', onPlayerSpawn, false, false)

function onPlayerWasted ( player )
      local playeraccount = getPlayerAccount ( source )
      if ( playeraccount ) then
            local playerskin = getElementModel ( source )
            setAccountData ( playeraccount, "skin1", playerskin )
      end
end 
addCommandHandler('load', onPlayerWasted, false, false)

 

it didn't work for me and , it's not metter for the save and load to be related to respawning or player wasted just commands and to be able to use them any time.e
ps. when i changed it to client lua it loaded on respawn another skin that it has been saved from the script i posted previously.

 

Edited by DarkBeautyDZ
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...