2k2k Posted August 4, 2016 Share 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? Link to comment
Walid Posted August 4, 2016 Share 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" Link to comment
Bonus Posted August 4, 2016 Share 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 Link to comment
KariiiM Posted August 4, 2016 Share Posted August 4, 2016 I suggest you to start with account data's functions or xml for now. Link to comment
2k2k Posted August 4, 2016 Author Share 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? Link to comment
KariiiM Posted August 4, 2016 Share 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. Link to comment
2k2k Posted August 4, 2016 Author Share 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 ) Link to comment
2k2k Posted August 4, 2016 Author Share Posted August 4, 2016 Its working but where will the players skin be saved on the serrver or on the client? Link to comment
KariiiM Posted August 4, 2016 Share Posted August 4, 2016 The code must be in server side Link to comment
Walid Posted August 4, 2016 Share 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 ) Link to comment
Bonus Posted August 4, 2016 Share 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 Link to comment
Walid Posted August 4, 2016 Share Posted August 4, 2016 @Bonus in your code Skin is not defined here Link to comment
Bonus Posted August 4, 2016 Share Posted August 4, 2016 @Bonus in your code Skin is not defined here This time I was faster edited already 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