Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: umar4911 on Jan 14, 2021, 09:14 AM

Title: SetSkin and onPlayerSkinChange
Post by: umar4911 on Jan 14, 2021, 09:14 AM
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) {
}
Title: Re: SetSkin and onPlayerSkinChange
Post by: Sebastian on Jan 14, 2021, 02:15 PM
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.