2k2k Posted August 4, 2016 Posted August 4, 2016 Any scripts that "Save skin when disconnecting > Reconnecting" I got it to save when you get killed but when I join the server I get a random skin any scripts that set you a speciffic skiN?
Walid Posted August 4, 2016 Posted August 4, 2016 Any scripts that "Save skin when disconnecting > Reconnecting" I got it to save when you get killed but when I join the server I get a random skin any scripts that set you a speciffic skiN? do it by yourself. -- Functions getElementModel() getPlayerAccount() isGuestAccount() setAccountData() getAccountData() -- Events "onPlayerQuit" "onPlayerLogin"
Bonus Posted August 4, 2016 Posted August 4, 2016 Depends on how you want to save it. Accountdata (when someone uses /login)? MySQL? File (save by serial or name) clientsided file
KariiiM Posted August 4, 2016 Posted August 4, 2016 I suggest you to start with account data's functions or xml for now.
2k2k Posted August 4, 2016 Author Posted August 4, 2016 I am stil learning lua as we speak and I kinda understand how to do this get get player acc > get his skin > save it to his acc. local playeraccount = getPlayerAccount ( source ) What do I need to put in the source is that where its gona put the account name? if so do I need to add something like accounts.txt?
KariiiM Posted August 4, 2016 Posted August 4, 2016 This line only just returning player's account element, go to wiki and learn about setAccountData and getAccountData functions. You don't need any file to save into it, account data functions already saving your data into a sqlite file.
2k2k Posted August 4, 2016 Author Posted August 4, 2016 I found a code on MTA wiki basicly for storing money I remade it to store skins this is my first script I do atend a computer school so by the code it looks pretty logical if you got any fixes bugs you see please lmk. function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( Acc ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerskin = getElementModel ( Skin ) setAccountData ( playeraccount, "player.skin", playerskin ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playerskin = getAccountData ( playeraccount, "player.skin" ) if ( playerskin ) then setElementModel ( Acc, Skin ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )
2k2k Posted August 4, 2016 Author Posted August 4, 2016 Its working but where will the players skin be saved on the serrver or on the client?
Walid Posted August 4, 2016 Posted August 4, 2016 Its working but where will the players skin be saved on the serrver or on the client? function onPlayerQuit ( ) local playeraccount = getPlayerAccount (source) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerskin = getElementModel (source) setAccountData (playeraccount, "player.skin", playerskin ) end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) function onPlayerLogin (_, playeraccount ) local playerskin = getAccountData ( playeraccount, "player.skin" ) if (playerskin) then setElementModel (source, tonumber(playerskin)) end end addEventHandler ( "onPlayerLogin", root, onPlayerLogin )
Bonus Posted August 4, 2016 Posted August 4, 2016 Sry, but how can this work? Are Acc and Skin the new source? function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) -- source instead of Acc if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local playerskin = getElementModel ( source ) -- source instead of Acc setAccountData ( playeraccount, "player.skin", playerskin ) end end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local playerskin = getAccountData ( playeraccount, "player.skin" ) if ( playerskin ) then setElementModel ( source, playerskin ) -- source instead of Acc end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) This code should work ... The skins will be saved in the account database of your server. Edit: Walid was faster
Bonus Posted August 4, 2016 Posted August 4, 2016 @Bonus in your code Skin is not defined here This time I was faster edited already
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