//When a client wants to enter the game world, we need to send them a bunch of information to set up their game world before they can enter public static void HandleEnterWorldRequest(int ClientID, ref NetworkPacket Packet) { CommunicationLog.LogIn(ClientID + " enter world request"); //Read the characters name the player is going to use, use it to fetch the rest of the characters data from the database string CharacterName = Packet.ReadString(); CharacterData CharacterData = CharactersDatabase.GetCharacterData(CharacterName); //Fetch this ClientConnection and make sure they were able to be found ClientConnection Client = ConnectionManager.GetClient(ClientID); if (Client == null) { MessageLog.Print("ERROR: Client not found, unable to handle enter world request."); return; } //Store the character data in the client Client.Character = CharacterData; //Send the clients lists of other players, AI entities, item pickups, inventory contents, equipped items and socketed actionbar abilities GameWorldStatePacketSender.SendActivePlayerList(ClientID); GameWorldStatePacketSender.SendActiveEntityList(ClientID); GameWorldStatePacketSender.SendActiveItemList(ClientID); GameWorldStatePacketSender.SendInventoryContents(ClientID, CharacterName); GameWorldStatePacketSender.SendEquippedItems(ClientID, CharacterName); GameWorldStatePacketSender.SendSocketedAbilities(ClientID, CharacterName); }
public string ThirdCharacterName = ""; //Name of the third character /// <summary> /// Returns a new CharacterData object containing all of that characters data /// </summary> /// <param name="CharacterNumber">The character slot to get data from (1,2 or 3)</param> /// <returns></returns> public CharacterData GetCharactersData(int CharacterNumber) { //Make sure the character who's data is being requested exists if (CharacterNumber == 1 && FirstCharacterName == "") { MessageLog.Print("ERROR: This account doesnt have a 1st character, so its data cannot be provded."); return(null); } if (CharacterNumber == 2 && SecondCharacterName == "") { MessageLog.Print("ERROR: This account doesnt have a 2nd character, so its data cannot be provided."); return(null); } if (CharacterNumber == 3 && ThirdCharacterName == "") { MessageLog.Print("ERROR: This account doesnt have a 3rd character, so its data cannot be provided."); return(null); } //Fetch the characters data and return it return(CharactersDatabase.GetCharacterData( CharacterNumber == 1 ? FirstCharacterName : CharacterNumber == 2 ? SecondCharacterName : ThirdCharacterName)); }
//Tries using the command arguments for performing a character info search private void TryCharacterInfoSearch(string[] Input) { //Get the characters name string CharacterName = Input[1]; //Make sure the character exists if (!CharactersDatabase.DoesCharacterExist(CharacterName)) { //Say the character doesnt exist and exit the function MessageLog.Print("No character named " + CharacterName + " exists, couldnt look up their info."); return; } //Characters Data will be stored here once we acquire it Server.Data.CharacterData Data; //Find the client currently controlling this character ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName); //If no client was found then we want to get the characters info from the database if (Client == null) { Data = CharactersDatabase.GetCharacterData(CharacterName); } //Otherwise we get the currently live data from the client who is currently using the character else { Data = Client.Character; } //Define some nicely formatted strings containing all the characters data string CharacterInfo = CharacterName + " level " + Data.Level + (Data.IsMale ? " male." : "female.") + " with " + Data.CurrentHealth + "/" + Data.MaxHealth + " HP."; string CharacterPosition = "Position: " + "(" + Data.Position.X + "," + Data.Position.Y + "," + Data.Position.Z + ")."; string CharacterRotation = "Rotation: (" + Data.Rotation.X + "," + Data.Rotation.Y + "," + Data.Rotation.Z + "," + Data.Rotation.W + ")."; string CharacterCamera = "Camera: Zoom:" + Data.CameraZoom + " XRot:" + Data.CameraXRotation + " YRot:" + Data.CameraYRotation + "."; //Display all the information to the message window MessageLog.Print(CharacterInfo); MessageLog.Print(CharacterPosition); MessageLog.Print(CharacterRotation); MessageLog.Print(CharacterCamera); }