private void IssueTicket(PlayerSession from, PlayerSession to) { var newTicket = new IssuedTicket(); newTicket.From = from.SteamId.m_SteamID; newTicket.To = to.SteamId.m_SteamID; tickets.Add(newTicket); }
void GiveTicket(PlayerSession player, string command, string[] args) { //get the ID of the player for whom to give the ticket PlayerSession ticketTo = null; ticketTo = getPlayerFromName(string.Join(" ", args)); if (ticketTo == null) { hurt.SendChatMessage(player, "Ticket was not issued. Unable to locate the player."); return; } else { int currentTicketCount = 1; bool alreadyIssued = false; foreach (var t in tickets) { if (t.To == ticketTo.SteamId.m_SteamID) { currentTicketCount++; } if (t.From == player.SteamId.m_SteamID) { //this player has already issued a ticket to this alreadyIssued = true; break; } } if (alreadyIssued) { hurt.SendChatMessage(player, "You can only issue a single ticket to a player."); return; } if (currentTicketCount >= ticketsBeforeJail) { //Jail the player here and clear out all the tickets for jailed player //Send the player to jail int repeats = (int)Math.Floor(Math.Round(jailLength / 5d)); timer.Repeat(5, repeats, () => player.WorldPlayerEntity.transform.position = GetJailCoords()); //Create the time for unjailing the player timer.Once(jailLength, () => UnJailPlayer(ticketTo)); //Send a message to the issuer hurt.BroadcastChat(ticketTo.Name + " has been put in jail."); //send a message to the defendant hurt.SendChatMessage(ticketTo, player.Name + " has issued you a ticket for griefing. You have exceeded the maximum number of tickets and have now been transported to jail."); } else { //add a ticket var newTicket = new IssuedTicket(); newTicket.From = player.SteamId.m_SteamID; newTicket.To = ticketTo.SteamId.m_SteamID; tickets.Add(newTicket); //Send a message to the issuer hurt.SendChatMessage(player, "A ticket has been issued to " + ticketTo.Name); //send a message to the defendant hurt.SendChatMessage(ticketTo, player.Name + " has issued you a ticket for griefing. You have a total of " + currentTicketCount.ToString() + ". If you get " + ticketsBeforeJail.ToString() + ", you will be sent to jail for " + getTimeStringFromSeconds(jailLength) + "."); } } }