public void RequestNewNpcIdentity() { var msg = new NewNpcIdentityMsg(); Sync.Layer.SendMessageToServer(ref msg); }
static void OnNpcIdentityRequest(ref NewNpcIdentityMsg msg, MyNetworkClient sender) { string npcName = "NPC " + MyRandom.Instance.Next(1000, 9999); var identity = Sync.Players.CreateNewNpcIdentity(npcName); if (identity != null) { msg.IdentityId = identity.IdentityId; Sync.Layer.SendMessage(ref msg, sender.SteamUserId, MyTransportMessageEnum.Success); } }
static void OnNpcIdentitySuccess(ref NewNpcIdentityMsg msg, MyNetworkClient sender) { var identity = Sync.Players.TryGetIdentity(msg.IdentityId); Debug.Assert(identity != null, "Server told me identity was created, but I cannot find it!"); if (identity == null) return; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( buttonType: MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionInfo), messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.NPCIdentityAdded), identity.DisplayName))); }