[ModAPI] Scripts attached to Character are lost when player respawns
Outdated
Here's the issue:
I have a modapi gamelogic script attached to the player's character (IMyCharacter).
When spawning in, the script is properly attached, however if the player respawn, the script is not re-attached to the new entity.
STR:
- Load into world with script mod (place medbay if there isn't one).
- Notice message displayed on screen from mod
- Press backspace and respawn
- Select medbay and respawn.
- Wait about 15 seconds (for old body to disappear), and notice the message just stops.
The script should be recreated and attached to any subsequent entity that matches automatically, just like any other entity (blocks, for example).
I've attached the mod, but the script is super simple:
using Sandbox.Definitions; using Sandbox.ModAPI; using VRage.Game; using VRage.Game.Components; using VRage.ModAPI; using VRage.ObjectBuilders; namespace Phoenix.TeamColors { [MyEntityComponentDescriptor(typeof(MyObjectBuilder_Character), false)] public class PlayerSkin : MyGameLogicComponent { public override void Init(MyObjectBuilder_EntityBase objectBuilder) { NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; } public override void UpdateBeforeSimulation100() { var character = (Container.Entity as VRage.Game.ModAPI.IMyCharacter); if (character != null) { MyAPIGateway.Utilities.ShowNotification($"Character: {(character.Definition as MyCharacterDefinition).Id}"); } } } }
Files:
TeamColors.zip
Hello, Engineer!
Thank you for your feedback! Your topic has been added between considered issues.Please keep voting for the issue as it will help us to identify the most serious bugs.
We really appreciate your patience.
Kind Regards
Keen Software House: QA Department
Hello, Engineer!
Thank you for your feedback! Your topic has been added between considered issues.Please keep voting for the issue as it will help us to identify the most serious bugs.
We really appreciate your patience.
Kind Regards
Keen Software House: QA Department
Replies have been locked on this page!