/// <summary> /// Create a new player state object for a PC. It is assumed that /// there is no pre-existing state object for the PC yet. /// </summary> /// <param name="PlayerObjectId">Supplies the PC object id to create /// the state object for.</param> private void CreatePlayerState(uint PlayerObjectId) { PlayerState NewPlayerState = new PlayerState(PlayerObjectId, this); PlayerStateTable.Add(PlayerObjectId, NewPlayerState); }
/// <summary> /// This method is called when a portal transition has been committed /// to send a player to a remote server. /// </summary> /// <param name="State">Supplies the local state for the player that is /// committed to a portal transition. /// </param> /// <param name="Server">Supplies the destination server for the portal /// event.</param> /// <param name="Script">Supplies the script object.</param> public static void SendGUIStateToServer(PlayerState State, GameServer Server, ACR_ServerCommunicator Script) { // // Build the resynchronization command. The resynchronization // command is parsed by HandleGUIResync(). Note that the remote // and local servers may not be of the same version, i.e. the // remote server may not understand fields that are created by the // local server if it is of a newer version. // ResyncState ResyncInfo = new ResyncState(State.PlayerId, 0); if (State.ChatSelectGUIExpanded) ResyncInfo.ResyncFlags |= RESYNC_FLAG_CHAT_SELECT_EXPANDED; // // Dispatch the resync script execution request to the remote // server. The remote server will process it when the request has // been received. // Script.RunScriptOnServer(Server.ServerId, "acr_resync_gui", ResyncInfo.ToString()); }
/// <summary> /// Dispatch the event (in a script context). /// </summary> /// <param name="Script">Supplies the script object.</param> /// <param name="Database">Supplies the database connection.</param> public void DispatchEvent(ACR_ServerCommunicator Script, ALFA.Database Database) { // // If the event was for a player logging on to the local server, // then don't re-broadcast it. // foreach (uint PlayerObject in Script.GetPlayers(true)) { PlayerState Player = Script.TryGetPlayerState(PlayerObject); if (Player == null) { continue; } if (!Player.CharacterIdsShown.Contains(Character.CharacterId)) { string sPlayerListBox = ""; if (Server.ServerId == Script.GetDatabase().ACR_GetServerID() || Script.GetLocalInt(PlayerObject, "chatselect_expanded") == 0) { if (IsDM == true) { sPlayerListBox = "LocalDMList"; Player.ChatSelectLocalDMsShown += 1; } else { sPlayerListBox = "LocalPlayerList"; Player.ChatSelectLocalPlayersShown += 1; } if (Server.ServerId == Script.GetDatabase().ACR_GetServerID()) { Script.AddListBoxRow(Player.ObjectId, "ChatSelect", sPlayerListBox, Character.CharacterName, "RosterData=/t \"" + Character.CharacterName + "\"", "", "5=/t \"" + Character.CharacterName + "\" ", ""); } else { if (Player.Flags.HasFlag(PlayerStateFlags.ChatSelectShowLocalPlayersOnlyWhenCollapsed)) { continue; } Script.AddListBoxRow(Player.ObjectId, "ChatSelect", sPlayerListBox, Character.CharacterName, "RosterData=#t \"" + Character.CharacterName + "\"", "", "5=#t \"" + Character.CharacterName + "\" ", ""); } } else { if (IsDM == true) { sPlayerListBox = "RemoteDMList"; Player.ChatSelectRemoteDMsShown += 1; } else { sPlayerListBox = "RemotePlayerList"; Player.ChatSelectRemotePlayersShown += 1; } Script.AddListBoxRow(Player.ObjectId, "ChatSelect", sPlayerListBox, Character.CharacterName, "RosterData=#t \"" + Character.CharacterName + "\"", "", "5=#t \"" + Character.CharacterName + "\" ", ""); } Player.CharacterIdsShown.Add(Character.CharacterId); Player.UpdateChatSelectGUIHeaders(); } } if (Database.ACR_GetServerID() == Server.ServerId) { return; } string Message = String.Format( "{0}<c=#FFA500>{1} ({2}) joined {3}.</c>", // <c=Orange...> IsDM ? "<c=#99CCFF>[DM] </c>": "", Character.Name, Character.Player.Name, Server.Name); string ChatMessage = "</c>" + Message; foreach (uint PlayerObject in Script.GetPlayers(true)) { PlayerState Player = Script.TryGetPlayerState(PlayerObject); if (Player == null) { continue; } if (!Script.IsCrossServerNotificationEnabled(PlayerObject)) { continue; } if ((Player.Flags & PlayerStateFlags.SendCrossServerNotificationsToCombatLog) != 0) { Script.SendMessageToPC(PlayerObject, Message); } else { Script.SendChatMessage( CLRScriptBase.OBJECT_INVALID, PlayerObject, CLRScriptBase.CHAT_MODE_SERVER, ChatMessage, CLRScriptBase.FALSE); } } #if DEBUG_MODE Script.WriteTimestampedLogEntry(Message); #endif }