internal static void Party_PlayerLeave(int index) { int partyNum; int i; partyNum = modTypes.TempPlayer[index].InParty; if (partyNum > 0) { // find out how many members we have Party_CountMembers(partyNum); // make sure there's more than 2 people if (Party[partyNum].MemberCount > 2) { // check if leader if (Party[partyNum].Leader == index) { // set next person down as leader for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++) { if (Party[partyNum].Member[i] > 0 && Party[partyNum].Member[i] != index) { Party[partyNum].Leader = Party[partyNum].Member[i]; PartyMsg(partyNum, string.Format("{0} is now the party leader.", S_Players.GetPlayerName(i))); break; } } // leave party PartyMsg(partyNum, string.Format("{0} has left the party.", S_Players.GetPlayerName(index))); Party_RemoveFromParty(index, partyNum); } else { // not the leader, just leave PartyMsg(partyNum, string.Format("{0} has left the party.", S_Players.GetPlayerName(index))); Party_RemoveFromParty(index, partyNum); } } else { // find out how many members we have Party_CountMembers(partyNum); // only 2 people, disband PartyMsg(partyNum, "The party has been disbanded."); // clear out everyone's party for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++) { index = Party[partyNum].Member[i]; // player exist? if (index > 0) { Party_RemoveFromParty(index, partyNum); } } // clear out the party itself ClearParty(partyNum); } } }
public static void AddAuction(int Index, int ItemNum, int Amount, int Min, int Max) { int i; string Filename = ""; int Unused = 0; // Find a empty auction slot. for (i = 1; i <= 100; i++) { if (Auction[i].Owner == string.Empty) { Unused = i; break; } } // i Auction[Unused].Owner = S_Players.GetPlayerName(Index); Auction[Unused].OwnerID = Index; Auction[Unused].Item = ItemNum; Auction[Unused].Amount = Amount; Auction[Unused].Price = Min; Auction[Unused].MaxBid = Max; Auction[Unused].Date = String.Format(DateTime.Today.ToString(), "m/d/yyyy"); Auction[Unused].EndDate = 31; modDatabase.SaveAuction(Unused); S_NetworkSend.SendAuctions(); }
public static void SendTimeTo(int index) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.STime); buffer.WriteByte((byte)Time.Instance.TimeOfDay); S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); S_General.AddDebug("Sent SMSG: STime"); S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " Time Of Day: " + Time.Instance.TimeOfDay); buffer.Dispose(); }
public static void SendGameClockTo(int index) { ByteStream buffer = new ByteStream(4); buffer.WriteInt32((int)Packets.ServerPackets.SClock); buffer.WriteInt32((int)Time.Instance.GameSpeed); buffer.WriteBytes(BitConverter.GetBytes(Time.Instance._Time.Ticks)); S_NetworkConfig.Socket.SendDataTo(index, buffer.Data, buffer.Head); S_General.AddDebug("Sent SMSG: SClock"); S_General.AddDebug(" Player: " + S_Players.GetPlayerName(index) + " : " + " GameSpeed: " + Time.Instance.GameSpeed + " Instance Time Ticks: " + Time.Instance._Time.Ticks); buffer.Dispose(); }
public static int FindPlayer(string Name) { int i; var loopTo = GetPlayersOnline(); for (i = 1; i <= loopTo; i++) { if (S_NetworkConfig.IsPlaying(i)) { // Make sure we dont try to check a name thats to small if (Microsoft.VisualBasic.Strings.Len(S_Players.GetPlayerName(i)) >= Microsoft.VisualBasic.Strings.Len(Name.Trim())) { if (Microsoft.VisualBasic.Strings.Mid(S_Players.GetPlayerName(i), 1, Microsoft.VisualBasic.Strings.Len(Name.Trim())).ToUpper() == Name.Trim().ToUpper()) { return(i); } } } } return(0); }
internal static void Party_InviteDecline(int index, int target) { S_NetworkSend.PlayerMsg(index, string.Format("{0} has declined to join your party.", S_Players.GetPlayerName(target)), (int)Enums.ColorType.BrightRed); S_NetworkSend.PlayerMsg(target, "You declined to join the party.", (int)Enums.ColorType.Yellow); // clear the invitation modTypes.TempPlayer[target].PartyInvite = 0; }
internal static void Party_InviteAccept(int index, int target) { int partyNum = 0; int i = 0; // check if already in a party if (modTypes.TempPlayer[index].InParty > 0) { // get the partynumber partyNum = modTypes.TempPlayer[index].InParty; // got a blank slot? for (i = 1; i <= Constants.MAX_PARTY_MEMBERS; i++) { if (Party[partyNum].Member[i] == 0) { // add to the party Party[partyNum].Member[i] = target; // recount party Party_CountMembers(partyNum); // send update to all - including new player SendPartyUpdate(partyNum); SendPartyVitals(partyNum, target); // let everyone know they've joined PartyMsg(partyNum, string.Format("{0} has joined the party.", S_Players.GetPlayerName(target))); // add them in modTypes.TempPlayer[target].InParty = (byte)partyNum; return; } } // no empty slots - let them know S_NetworkSend.PlayerMsg(index, "Party is full.", (int)Enums.ColorType.BrightRed); S_NetworkSend.PlayerMsg(target, "Party is full.", (int)Enums.ColorType.BrightRed); return; } else { // not in a party. Create one with the new person. for (i = 1; i <= Constants.MAX_PARTIES; i++) { // find blank party if (!(Party[i].Leader > 0)) { partyNum = i; break; } } // create the party Party[partyNum].MemberCount = 2; Party[partyNum].Leader = index; Party[partyNum].Member[1] = index; Party[partyNum].Member[2] = target; SendPartyUpdate(partyNum); SendPartyVitals(partyNum, index); SendPartyVitals(partyNum, target); // let them know it's created PartyMsg(partyNum, "Party created."); PartyMsg(partyNum, string.Format("{0} has joined the party.", S_Players.GetPlayerName(index))); // clear the invitation modTypes.TempPlayer[target].PartyInvite = 0; // add them to the party modTypes.TempPlayer[index].InParty = (byte)partyNum; modTypes.TempPlayer[target].InParty = (byte)partyNum; return; } }
public static void Packet_AcceptInvite(int index, ref byte[] data) { ByteStream buffer = new ByteStream(data); int response = buffer.ReadInt32(); buffer.Dispose(); if (response == 1) { if (modTypes.TempPlayer[index].Invitationindex > 0) { if (modTypes.TempPlayer[index].InvitationTimer > S_General.GetTimeMs()) { if (S_NetworkConfig.IsPlaying(modTypes.TempPlayer[index].Invitationindex)) { modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse = modTypes.TempPlayer[index].Invitationindex; modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastX = S_Players.GetPlayerX(index); modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastY = S_Players.GetPlayerY(index); modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].LastMap = S_Players.GetPlayerMap(index); modTypes.TempPlayer[index].InvitationTimer = 0; S_Players.PlayerWarp(index, modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[index].CurChar].Map, S_Housing.HouseConfig[modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[modTypes.TempPlayer[index].Invitationindex].CurChar].House.Houseindex].X, S_Housing.HouseConfig[modTypes.Player[modTypes.TempPlayer[index].Invitationindex].Character[(int)modTypes.TempPlayer[modTypes.TempPlayer[index].Invitationindex].CurChar].House.Houseindex].Y, true, true); } else { modTypes.TempPlayer[index].InvitationTimer = 0; S_NetworkSend.PlayerMsg(index, "Cannot find player!", 12); } } else { S_NetworkSend.PlayerMsg(index, "Your invitation has expired, have your friend re-invite you.", 14); } } } else { if (S_NetworkConfig.IsPlaying(modTypes.TempPlayer[index].Invitationindex)) { modTypes.TempPlayer[index].InvitationTimer = 0; S_NetworkSend.PlayerMsg(modTypes.TempPlayer[index].Invitationindex, (S_Players.GetPlayerName(index).Trim()) + " rejected your invitation", 12); } } }
public static void Packet_InviteToHouse(int index, ref byte[] data) { ByteStream buffer = new ByteStream(data); string Name = (buffer.ReadString().Trim()); int invitee = S_GameLogic.FindPlayer(Name); buffer.Dispose(); if (invitee == 0) { S_NetworkSend.PlayerMsg(index, "Player not found.", 12); } else { if (index == invitee) { S_NetworkSend.PlayerMsg(index, "You cannot invite yourself to you own house!", 12); } else { if (modTypes.TempPlayer[invitee].Invitationindex > 0) { if (modTypes.TempPlayer[invitee].InvitationTimer > S_General.GetTimeMs()) { S_NetworkSend.PlayerMsg(index, (S_Players.GetPlayerName(invitee).Trim()) + " is currently busy!", 14); return; } } if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].House.Houseindex > 0) { if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse > 0) { if (modTypes.Player[index].Character[(int)modTypes.TempPlayer[index].CurChar].InHouse == index) { if (modTypes.Player[invitee].Character[(int)modTypes.TempPlayer[invitee].CurChar].InHouse > 0) { if (modTypes.Player[invitee].Character[(int)modTypes.TempPlayer[invitee].CurChar].InHouse == index) { S_NetworkSend.PlayerMsg(index, (S_Players.GetPlayerName(invitee).Trim()) + " is already in your house!", 14); } else { S_NetworkSend.PlayerMsg(index, (S_Players.GetPlayerName(invitee).Trim()) + " is already visiting someone elses house!", 14); } } else { buffer = new ByteStream(4); buffer.WriteInt32(91); buffer.WriteInt32(index); S_NetworkConfig.Socket.SendDataTo(invitee, buffer.Data, buffer.Head); modTypes.TempPlayer[invitee].Invitationindex = index; modTypes.TempPlayer[invitee].InvitationTimer = checked (S_General.GetTimeMs() + 15000); buffer.Dispose(); } } else { S_NetworkSend.PlayerMsg(index, "Only the house owner can invite other players into their house.", 12); } } else { S_NetworkSend.PlayerMsg(index, "You must be inside your house before you can invite someone to visit!", 12); } } else { S_NetworkSend.PlayerMsg(index, "You do not have a house to invite anyone to!", 12); } } } }
public static void BidOnAuction(int Index, int Bid, int AuctionNum) { // Obvious if (AuctionNum == 0) { return; } // Lets make sure the auction even exists! if (Auction[AuctionNum].Owner == string.Empty) { S_NetworkSend.PlayerMsg(Index, "Auction no longer exists!", (int)Enums.ColorType.Red); return; } // Make sure they have enough money! if (S_Players.HasItem(Index, 1) < Bid) { S_NetworkSend.PlayerMsg(Index, "You Don't Have Enough Money To Make This Bid!", (int)Enums.ColorType.Red); return; } if (Bid < Auction[AuctionNum].Price) { S_NetworkSend.PlayerMsg(Index, "You Haven't Met This Bids Minimum Price!", (int)Enums.ColorType.Red); return; } if (Bid > Auction[AuctionNum].Bid) { // Give the previous bidder his $$ back if (Auction[AuctionNum].LastBidder != string.Empty) { GivePrevBid(Auction[AuctionNum].LastBidder, Auction[AuctionNum].Bid); } else { // Something went south, most likely a account deletion. Log it just incase S_General.AddDebug("Auction Failed To Find A Player And Return " + Bid + " To Them!"); } Auction[AuctionNum].Bid = Bid; Auction[AuctionNum].LastBidder = S_Players.GetPlayerName(Index); S_Players.TakeInvItem(Index, 1, Bid); S_NetworkSend.PlayerMsg(Index, "You have successfully bid " + Bid, (int)Enums.ColorType.Red); // Lets check if we won! if (Bid >= Auction[AuctionNum].MaxBid) { S_NetworkSend.PlayerMsg(Index, "You Have Won " + Types.Item[Auction[AuctionNum].Item].Name.Trim() + " !", (int)Enums.ColorType.Red); S_Players.GiveInvItem(Index, Auction[AuctionNum].Item, 0, true); // Should be working but may need work: if (Auction[AuctionNum].OwnerID != 0) { S_NetworkSend.PlayerMsg(Auction[AuctionNum].OwnerID, "Your Auction has sold: " + Types.Item[Auction[AuctionNum].Item].Name.Trim() + " !", (int)Enums.ColorType.Red); S_Players.GiveInvItem(Auction[AuctionNum].OwnerID, 1, Auction[AuctionNum].Bid, true); } else { AuctionSoldOut(AuctionNum); } DestroyAuction(AuctionNum); S_NetworkSend.SendAuctions(); } else { // We are not quite there yet S_NetworkSend.PlayerMsg(Index, "You Are " + (Auction[AuctionNum].MaxBid - Bid) + " Away from winning this auction!", (int)Enums.ColorType.Red); } } else { S_NetworkSend.PlayerMsg(Index, "Sorry, You Are " + (Auction[AuctionNum].Bid - Bid) + " Away from making a bid!", (int)Enums.ColorType.Red); } }