Request for an OnItemSkinned hook. Something like the following:
Written up by a friend so it may have mistakes. General idea is to allow a plugin to set a custom skin value and it would reskin as well as prevent reskinning by returning anything other than a ulong/null.Code:[global::BaseEntity.RPC_Server] public void ChangeSkin(global::BaseEntity.RPCMessage msg) { if (UnityEngine.Time.realtimeSinceStartup < this.nextSkinChangeTime) { return; } global::BasePlayer player = msg.player; int num = msg.read.Int32(); global::Item slot = this.inventory.GetSlot(0); if (slot == null) { return; } if (num != 0 && !player.blueprints.steamInventory.HasItem(num)) { this.debugprint("RepairBench.ChangeSkin player does not have item :" + num + ":"); return; } object obj = Interface.CallHook("OnItemSkinned ", new object[] { player, num }); if (obj is ulong) { num = (ulong)obj; } else if (obj != null) return; ulong num2 = 0uL; Facepunch.Steamworks.Inventory.Definition definition = Rust.Global.SteamServer.Inventory.FindDefinition(num); if (definition != null) { num2 = definition.GetProperty<ulong>("workshopdownload"); string property = definition.GetProperty<string>("itemshortname"); if (num != 0 && property != slot.info.shortname && property != slot.info.name) { return; } } if (num2 == 0uL) { num2 = (ulong)((long)num); } if (num2 == slot.skin) { this.debugprint(string.Concat(new object[] { "RepairBench.ChangeSkin cannot apply same skin twice : ", num2, ": ", slot.skin })); return; } this.nextSkinChangeTime = UnityEngine.Time.realtimeSinceStartup + 0.75f; slot.skin = num2; slot.MarkDirty(); global::BaseEntity heldEntity = slot.GetHeldEntity(); if (heldEntity != null) { heldEntity.skinID = num2; heldEntity.SendNetworkUpdate(global::BasePlayer.NetworkQueue.Update); } if (this.skinchangeEffect.isValid) { global::Effect.server.Run(this.skinchangeEffect.resourcePath, this, 0u, new Vector3(0f, 1.5f, 0f), Vector3.zero, null, false); } }
Request OnItemSkinned hook (Rust)
Discussion in 'Feature Suggestions' started by GoDANKorGoHOME, Dec 20, 2017.