/** Main Constructor */ public Mission() { pauseState = true; objectives = new List <Objective>(); vehicles = new List <NetHandle>(); players = new List <Client>(); objectiveCooldown = DateTime.Now; partyInstance = new Random().Next(0, 9000000); missionReward = 0; maxMissionTime = -1; missionWeaponReward = WeaponHash.Unarmed; stashInfo = null; removeFromMissionOnDeath = false; }
public void startChopShopJob(Client player, params object[] arguments) { if (player.position.DistanceTo(startPoint) >= 5) { return; } Mission mission; if (API.hasEntityData(player, "Mission")) { mission = API.getEntityData(player, "Mission"); if (mission.MissionObjectiveCount > 0) { API.sendChatMessageToPlayer(player, "~r~You seem to already have a mission running."); return; } API.setEntitySyncedData(player, "Mission_New_Instance", true); API.setEntityData(player, "Mission", mission); mission.addPlayer(player); } else { mission = new Mission(); API.setEntitySyncedData(player, "Mission_New_Instance", true); API.setEntityData(player, "Mission", mission); mission.addPlayer(player); } // Basic Setup. mission.useTimer(); mission.MissionTime = 60 * 5; mission.MissionReward = reward; mission.MissionTitle = "Chop Shop"; mission.RemoveFromMissionOnDeath = true; StashInfo stash = StashManager.getStashInfoByID(1); if (stash == null) { API.sendChatMessageToPlayer(player, "~r~Something went wrong with stashes. Contact an administrator."); return; } mission.AttachStashInfo = stash; // Setup a unique ID for the vehicle we'll be using. int uniqueID = new Random().Next(1, 50000); // == First Major Objective // = Create an empty objective to house information. Create an empty ObjectiveInfo Add our first objective, and associate the Vehicle ID with our objective. Objective objective = mission.addEmptyObjective(mission); ObjectiveInfo objectiveInfo = objective.addEmptyObjectiveInfo(); objectiveInfo.Location = midPoint; objectiveInfo.Type = Objective.ObjectiveTypes.Location; objectiveInfo.Lockpick = new minigames.Lockpick(); // == Second Major Objective int missionIndex = new Random().Next(0, locations.Count); int carIndex = new Random().Next(0, vehicleList.Count); Vector3 location = locations[missionIndex].Location; Vector3 rotation = locations[missionIndex].Rotation; objective = mission.addEmptyObjective(mission); objectiveInfo = objective.addEmptyObjectiveInfo(); objectiveInfo.Location = location; objectiveInfo.Type = Objective.ObjectiveTypes.BreakIntoVehicle; objectiveInfo.Lockpick = new minigames.Lockpick(); NetHandle vehicle = objective.addObjectiveVehicle(mission, location.Add(new Vector3(0, 0, 0.2)), API.vehicleNameToModel(vehicleList[carIndex]), rotation, uniqueID); API.setVehiclePrimaryColor(vehicle, new Random().Next(0, 159)); API.setVehicleSecondaryColor(vehicle, new Random().Next(0, 159)); API.setEntityPositionFrozen(vehicle, true); API.delay(5000, true, () => { API.setVehicleLocked(vehicle, true); API.setVehicleEngineStatus(vehicle, false); API.setEntityPositionFrozen(vehicle, false); }); // == Third Major Objective - Take Vehicle objective = mission.addEmptyObjective(mission); objectiveInfo = objective.addEmptyObjectiveInfo(); objectiveInfo.Location = location; objectiveInfo.Type = Objective.ObjectiveTypes.RetrieveVehicle; objectiveInfo.UniqueVehicleID = uniqueID; objectiveInfo = objective.addEmptyObjectiveInfo(); objectiveInfo.Type = Objective.ObjectiveTypes.UnlockVehicles; objectiveInfo.Location = new Vector3(); objectiveInfo.UniqueVehicleID = uniqueID; // == Parse End Point objective = mission.addEmptyObjective(mission); objectiveInfo = objective.addEmptyObjectiveInfo(); objectiveInfo.Location = endPoint; objectiveInfo.Type = Objective.ObjectiveTypes.VehicleLocation; objectiveInfo.UniqueVehicleID = uniqueID; // == Start Mission mission.startMission(); }