Jump to content

[HELP] skin system


Agon

Recommended Posts

Hi I made this script with kenix but it doesn't work anymore. there is no debug error and i don't know what the error is. hope you help.

*In first function, you can save your skin to your account with /skinsave (if you are cj, your clothes will be saved).

*In second function, when you log in, your skin will change to your account's skin (so will your cj clothes).

*In third function, when you die, you'll be spawned on the same position you died with your account's skin. If you don't have a skin in your account nor you are not logged in, you will be spawned on the same position with a random skin.

function changeTheSkin( source ) 
    local playerAccount = getPlayerAccount( source ) 
    local mySkin = getElementModel(source) 
    if playerAccount and not isGuestAccount( playerAccount ) then 
        for i = 0,17 do 
            local arg1,arg2 = getPedClothes( source, i ) 
            setAccountData( playerAccount, "player.clothes."..tostring( i ),tostring( arg1 )..","..tostring( arg2 ) ) 
        end 
        setAccountData( playerAccount, "player.skin", mySkin ) 
    end 
end 
addCommandHandler( "skinsave", changeTheSkin ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( ) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                setElementModel( source, playerSkin ) 
                for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                    if not acc:find 'false'  then 
                        addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                    end 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        x, y, z = getElementPosition(source) 
        local playerAccount = getPlayerAccount( source ) 
        if playerAccount then 
            local playerSkin = getAccountData( playerAccount, "player.skin" ) 
            if playerSkin then 
                spawnPlayer(source, x, y, z, 0, playerSkin) 
                    for i = 0,17 do 
                    local acc = getAccountData( playerAccount, 'player.clothes.'..i ) 
                        if not acc:find 'false'  then 
                            addPedClothes( source,acc:sub( 1,acc:find( ',' ) - 1 ),acc:sub( acc:find( ',' ) + 1,acc:len( ) ),i ) 
                        end 
                    end 
                else spawnPlayer(source, x, y, z, 0, math.random(0, 288)) 
            end 
        end 
    end 
) 
  

Damn It is working :shock: how stupid i am. Btw how can i spawnPlayer a little bit later? When i die, it immediately spawns me. I want to see my body lying on the floor when the camera going up while shaking. I mean a little bit later :P

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