Jump to content

Save skin when disconnecting > Reconnecting


2k2k

Recommended Posts

Posted

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?

Posted
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" 
  

Posted

Depends on how you want to save it.

Accountdata (when someone uses /login)?

MySQL?

File (save by serial or name)

clientsided file

Posted

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?

Posted

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.

Posted

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 ) 
  

Posted
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 ) 

Posted

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

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