SetSkin and onPlayerSkinChange

Started by umar4911, Jan 14, 2021, 09:14 AM

Previous topic - Next topic

umar4911

if you change your skin using player.Skin = skin; your weapon resets. In order to avoid that, add this in your script:

function CPlayer::SetSkin(skin) {
    local slot = this.Slot;
    this.Skin = skin;
    this.Slot = slot;
}

Now use:
player.SetSkin(skinid)


onPlayerSkinChange
If you want this event, use:

function CPlayer::SetSkin(skin) {
    local slot = this.Slot, oldskin = this.Skin;
    this.Skin = skin;
    this.Slot = slot;
  onPlayerSkinChange(this, oldskin, skin)
}

Event:
function onPlayerSkinChange(player, OldSkin, NewSkin) {
}
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

Sebastian

Just a note: no matter what,  because of the weapon change,  event onPlayerWeaponChange will be called.
(so be aware of that if you have code in that event)

Btw,  player.Pos also calls the event. At least,  that one puts back the weapon in your hand.