DarkBeautyDZ Posted February 23, 2019 Share Posted February 23, 2019 (edited) 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 February 23, 2019 by DarkBeautyDZ Link to comment
Peti Posted February 23, 2019 Share Posted February 23, 2019 (edited) 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 February 23, 2019 by Peti Link to comment
DarkBeautyDZ Posted February 24, 2019 Author Share Posted February 24, 2019 (edited) 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 February 24, 2019 by DarkBeautyDZ Link to comment
Peti Posted February 24, 2019 Share Posted February 24, 2019 This is a server script, because it has server-only functions like: https://wiki.multitheftauto.com/wiki/GetPlayerAccount https://wiki.multitheftauto.com/wiki/SetAccountData Did you try both commands after being logged in into an account? https://wiki.multitheftauto.com/wiki/Account Link to comment
DarkBeautyDZ Posted March 2, 2019 Author Share Posted March 2, 2019 yes nvm this , i need help here this will solve my problem here Link to comment
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