Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static DynamicPickup CreatePickup(Model model, Vector3 position, float heading, int amount, bool dynamic, Quaternion q = null)
        {
            var v_4       = 515;
            int newPickup = -1;

            if (Game.Player.Character.IsInRangeOf(position, 30f))
            {
                newPickup = Function.Call <int>(Hash.CREATE_PICKUP_ROTATE, model.Hash, position.X, position.Y,
                                                position.Z, 0, 0, heading, v_4, amount, 0, false, 0);
            }

            var pcObj = new DynamicPickup(newPickup)
            {
                Flag         = v_4,
                Amount       = amount,
                RealPosition = position
            };

            if (newPickup != -1)
            {
                var start = 0;
                while (pcObj.ObjectHandle == -1 && start < 20)
                {
                    start++;
                    Script.Yield();
                }

                pcObj.Dynamic = false;
                new Prop(pcObj.ObjectHandle).IsPersistent = true;


                if (q != null)
                {
                    Quaternion.SetEntityQuaternion(new Prop(pcObj.ObjectHandle), q);
                }
                pcObj.UpdatePos();
            }

            Pickups.Add(pcObj);
            pcObj.PickupHash = model.Hash;
            pcObj.Timeout    = 1;
            pcObj.UID        = _pickupIds++;
            return(pcObj);
        }
Ejemplo n.º 4
0
        public static void MoveFromMemory(MapObject obj)
        {
            var  prop    = obj;
            Prop newProp = World.CreateProp(new Model(prop.Hash), prop.Position, prop.Rotation, false, false);

            newProp.FreezePosition = !prop.Dynamic;
            StreamedInHandles.Add(newProp.Handle);
            if (!prop.Dynamic)
            {
                StaticProps.Add(newProp.Handle);
                newProp.FreezePosition = true;
            }
            if (prop.Quaternion != null)
            {
                Quaternion.SetEntityQuaternion(newProp, prop.Quaternion);
            }
            newProp.Position = prop.Position;
            MemoryObjects.Remove(prop);
        }
Ejemplo n.º 5
0
        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);
        }