Jump to content

Skin changes after I die.


Recommended Posts

try that:

didn't test it

function saveSkin( daPlayer ) 
    setAccountData( getPlayerAccount( daPlayer ), "save-skin", getElementModel( daPlayer ) ) 
end 
addEventHandler("onPlayerWasted", getRootElement(), saveSkin ) 
  
function setSkin( daPlayer ) 
    setElementModel( daPlayer, getAccountData( getPlayerAccount( daPlayer ) ), "save-skin" ) 
end 
addEventHandler("onPlayerSpawn", getRootElement(), setSkin ) 
  

Link to comment

You have an error at line 7, and no need for account data, element data would be better.

function saveSkin( player ) 
    setElementData(  player , "save-skin", getElementModel(player) ) 
end 
addEventHandler("onPlayerWasted", root, saveSkin ) 
  
function setSkin( player ) 
    setElementModel( player, getElementData(player, "save-skin") ) 
end 
addEventHandler("onPlayerSpawn", root, setSkin ) 
  

Link to comment

Alpha, blazy both code is wrong.

Read wiki better.

onPlayerSpawn-> first argument is position axis x ( not element )

onPlayerWasted-> first argument is killer( but we not needed killer. Only wasted player we need )

local function Skin( ) 
    if eventName == 'onPlayerSpawn' then 
        local nData = getElementData( source, 'save-skin' ) 
        if nData then 
            setElementModel( source, nData ) 
        end 
    else 
        setElementData( source, 'save-skin', getElementModel( source ) ) 
    end 
end 
addEventHandler( 'onPlayerWasted', root, Skin ) 
addEventHandler( 'onPlayerSpawn', root, Skin )  

Edited by Guest
Link to comment
Guest Guest4401
addEventHandler("onPlayerWasted",root, 
    function() 
        setElementData(source,"save-skin",getElementModel(source)) 
    end 
) 
  
addEventHandler("onPlayerSpawn",root, 
    function() 
        setTimer(setElementModel, 100, 1, source,(getElementData(source,"save-skin") or 0)) 
    end 
) 

Link to comment
  
addEventHandler("onPlayerDamage",root,function() 
    setElementData(source,"skin",getElementModel(source) or 0 ) 
end ) 
addEventHandler("onPlayerWasted",root,function() 
    setElementData(source,"skin",getElementModel(source) or 0 ) 
end ) 
addEventHandler("onPlayerSpawn",root,function() 
    setElementModel(source,getElementData(source,"skin") or 0 ) 
end ) 
  

Link to comment
  • Scripting Moderators

spawnPlayer, 6 argument = getElementModel

Example:

addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        spawnPlayer ( source, 0, 0, 3, 0, getElementModel ( source ) ) 
    end 
) 

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