public void test(IPlayer p) { //load the contracts on login if (p == null) { return; } MyIdentity id = GetIdentityByNameOrId(p.SteamId.ToString()); if (id == null) { return; } Contract contract = Database.TryGetContract(p.SteamId); if (contract != null) { TruckingPlugin.activeContracts.Remove(p.SteamId); TruckingPlugin.activeContracts.Add(p.SteamId, contract); StringBuilder contractDetails = new StringBuilder(); int pay = TruckingPlugin.GetMinimumPay(contract.getItemsInContract()); contractDetails = TruckingPlugin.MakeContractDetails(contract.getItemsInContract()); contractDetails.AppendLine(""); contractDetails.AppendLine("Minimum Payment " + String.Format("{0:n0}", pay) + " SC."); MyGps gps = contract.GetDeliveryLocation(); List <IMyGps> playerList = new List <IMyGps>(); MySession.Static.Gpss.GetGpsList(id.IdentityId, playerList); MyGpsCollection gpscol = (MyGpsCollection)MyAPIGateway.Session?.GPS; foreach (IMyGps gps2 in playerList) { if (gps2.Name.Contains("Delivery Location, bring hauling vehicle within 300m")) { MyAPIGateway.Session?.GPS.RemoveGps(id.IdentityId, gps2); } } gpscol.SendAddGps(id.IdentityId, ref gps); } }
public void ContractDetails() { StringBuilder contractDetails = new StringBuilder(); if (TruckingPlugin.getActiveContract(Context.Player.SteamUserId) != null) { Contract contract = TruckingPlugin.getActiveContract(Context.Player.SteamUserId); int pay = TruckingPlugin.GetMinimumPay(contract.getItemsInContract()); contractDetails = TruckingPlugin.MakeContractDetails(contract.getItemsInContract()); MyGps gps = TruckingPlugin.getDeliveryLocation(); MyGpsCollection gpscol = (MyGpsCollection)MyAPIGateway.Session?.GPS; gpscol.SendAddGps(Context.Player.Identity.IdentityId, ref gps); DialogMessage m = new DialogMessage("Contract Details", "Obtain and deliver these items", contractDetails.ToString()); ModCommunication.SendMessageTo(m, Context.Player.SteamUserId); } else { Context.Respond("You dont currently have a contract", "The Boss"); } }