public static Vehicle CreateVehicle(Model model, Vector3 position, float heading, bool dynamic, Quaternion q = null, int drawDistance = -1) { Vehicle veh; int counter = 0; do { veh = World.CreateVehicle(model, position, heading); counter++; } while (veh == null && counter < 2000); if (veh == null) { UI.Notify("~r~~h~Map Editor~h~~w~~n~I tried very hard, but the vehicle failed to load."); return(null); } Vehicles.Add(veh.Handle); if (!dynamic) { StaticProps.Add(veh.Handle); veh.FreezePosition = true; } if (q != null) { Quaternion.SetEntityQuaternion(veh, q); } if (drawDistance != -1) { veh.LodDistance = drawDistance; } UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return(veh); }
public static Prop CreateProp(Model model, Vector3 position, Vector3 rotation, bool dynamic, Quaternion q = null, bool force = false, int drawDistance = -1) { if (StreamedInHandles.Count >= MAX_OBJECTS) { UI.Notify("~r~~h~Map Editor~h~~w~\nYou have reached the prop limit. You cannot place any more props."); return(null); } if (PropCount > 0 && PropCount % 249 == 0) { Script.Wait(100); } var prop = new Prop(Function.Call <int>(Hash.CREATE_OBJECT_NO_OFFSET, model.Hash, position.X, position.Y, position.Z, true, true, dynamic)); prop.Rotation = rotation; StreamedInHandles.Add(prop.Handle); if (!dynamic) { StaticProps.Add(prop.Handle); prop.FreezePosition = true; } if (q != null) { Quaternion.SetEntityQuaternion(prop, q); } prop.Position = position; if (drawDistance != -1) { prop.LodDistance = drawDistance; } UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return(prop); }
public static Ped CreatePed(Model model, Vector3 position, float heading, bool dynamic, Quaternion q = null, int drawDistance = -1) { var veh = World.CreatePed(model, position, heading); Peds.Add(veh.Handle); if (!dynamic) { StaticProps.Add(veh.Handle); veh.FreezePosition = true; } if (q != null) Quaternion.SetEntityQuaternion(veh, q); if (drawDistance != -1) veh.LodDistance = drawDistance; UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return veh; }
public static Ped CreatePed(Model model, Vector3 position, float heading, bool dynamic, Quaternion q = null, int drawDistance = -1) { var veh = World.CreatePed(model, position, heading); Peds.Add(veh.Handle); if (!dynamic) { StaticProps.Add(veh.Handle); veh.FreezePosition = true; } if (q != null) { Quaternion.SetEntityQuaternion(veh, q); } if (drawDistance != -1) { veh.LodDistance = drawDistance; } UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return(veh); }
public void ValidateDatabase() { // Validate object list. Dictionary<string, int> tmpDict = new Dictionary<string, int>(); int counter = 0; while (counter < ObjectDatabase.MainDb.Count) { var pair = ObjectDatabase.MainDb.ElementAt(counter); counter++; UI.ShowSubtitle((counter) + "/" + ObjectDatabase.MainDb.Count + " done. (" + (counter/(float) ObjectDatabase.MainDb.Count)*100 + "%)\nValid objects: " + tmpDict.Count, 2000); Yield(); var model = new Model(pair.Value); model.Request(100); if (!model.IsLoaded) { model.MarkAsNoLongerNeeded(); continue; } model.MarkAsNoLongerNeeded(); if (!tmpDict.ContainsKey(pair.Key)) tmpDict.Add(pair.Key, pair.Value); } string output = tmpDict.Aggregate("", (current, pair) => current + (pair.Key + "=" + pair.Value + "\r\n")); File.WriteAllText("scripts\\ObjectList.ini", output); }
public static Vehicle CreateVehicle(Model model, Vector3 position, float heading, bool dynamic, Quaternion q = null, int drawDistance = -1) { Vehicle veh; int counter = 0; do { veh = World.CreateVehicle(model, position, heading); counter++; } while (veh == null && counter < 2000); if (veh == null) { UI.Notify("~r~~h~Map Editor~h~~w~~n~I tried very hard, but the vehicle failed to load."); return null; } Vehicles.Add(veh.Handle); if (!dynamic) { StaticProps.Add(veh.Handle); veh.FreezePosition = true; } if(q != null) Quaternion.SetEntityQuaternion(veh, q); if (drawDistance != -1) veh.LodDistance = drawDistance; UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return veh; }
public static Prop CreateProp(Model model, Vector3 position, Vector3 rotation, bool dynamic, Quaternion q = null, bool force = false, int drawDistance = -1) { if (StreamedInHandles.Count >= MAX_OBJECTS) { UI.Notify("~r~~h~Map Editor~h~~w~\nYou have reached the prop limit. You cannot place any more props."); return null; } if (PropCount > 0 && PropCount % 249 == 0) Script.Wait(100); var prop = new Prop(Function.Call<int>(Hash.CREATE_OBJECT_NO_OFFSET, model.Hash, position.X, position.Y, position.Z, true, true, dynamic)); prop.Rotation = rotation; StreamedInHandles.Add(prop.Handle); if (!dynamic) { StaticProps.Add(prop.Handle); prop.FreezePosition = true; } if (q != null) Quaternion.SetEntityQuaternion(prop, q); prop.Position = position; if (drawDistance != -1) prop.LodDistance = drawDistance; UsedModels.Add(model.Hash); model.MarkAsNoLongerNeeded(); return prop; }