public void SlapPlayer(Client player, string partOfName)
        {
            Player user = Player.PlayerData[player];

            if (user.MasterAccount.AdminLevel < 1)
            {
                Message.NotAuthorised(player); return;
            }
            var target = Player.GetPlayerData(partOfName);

            if (target == null)
            {
                Message.PlayerNotConnected(player); return;
            }

            if (target.Client.isInVehicle)
            {
                GrandTheftMultiplayer.Server.Elements.Vehicle veh = target.Client.vehicle;
                veh.position = veh.position.Add(new Vector3(0, 0, 9));
            }
            else
            {
                API.setPlayerVelocity(target.Client, new Vector3(0, 0, 10));
            }

            Message.AdminMessage(target.Client, String.Format("Admin {0} has slapped you.", player.name));
            API.sendNotificationToPlayer(player, String.Format("You have slapped {0}.", target.Client.name));
        }
示例#2
0
        private void OnVehicleStreamIn(Client player, List <NetHandle> vehicles)
        {
            List <NetHandle> handles = new List <NetHandle>();
            List <Vector3>   pos     = new List <Vector3>();
            List <Vector3>   rot     = new List <Vector3>();

            foreach (NetHandle vehicle in vehicles)
            {
                GrandTheftMultiplayer.Server.Elements.Vehicle v = API.getEntityFromHandle <GrandTheftMultiplayer.Server.Elements.Vehicle>(vehicle);
                Console.WriteLine("{0} here", v.handle.Value);
                try
                {
                    foreach (Vehicle veh in Vehicle.VehicleData.Values)
                    {
                        Console.WriteLine("    {0} vehicle", veh.Entity.handle.Value);
                        if (veh.Entity.occupants.Count() == 0)
                        {
                            handles.Add(veh.Entity);
                            pos.Add(veh.UnoccupiedPosition);
                            rot.Add(veh.UnoccupiedRotation);
                        }
                    }
                }
                catch { continue; }
            }
            API.sendChatMessageToAll("" + pos.Count);
            API.triggerClientEvent(player, "ResyncUnoccupiedVehicles", handles, pos, rot);
        }
 public static void ClimbOver(this Ped ped, GrandTheftMultiplayer.Server.Elements.Vehicle veh)
 {
     Task.Run(() =>
     {
         API.shared.sendNativeToAllPlayers(Hash.TASK_SHUFFLE_TO_NEXT_VEHICLE_SEAT, ped, veh);
     });
 }
示例#4
0
 /// <summary>
 /// Управляет неоновой подсветкой транспорта
 /// </summary>
 private static void TurnNeonState(Vehicle vehicle, bool turnOn)
 {
     for (var i = 0; i < 4; i++)
     {
         API.shared.setVehicleNeonState(vehicle, i, turnOn);
     }
 }
示例#5
0
        public static int GetDriver(this GrandTheftMultiplayer.Server.Elements.Vehicle veh)
        {
            int id = API.shared.fetchNativeFromPlayer <int>(Player.IDs.Where(p => p != null).First(), Hash.GET_PED_IN_VEHICLE_SEAT, veh, -1);

            Console.WriteLine(id);
            return(id);
        }
示例#6
0
 public static GrandTheftMultiplayer.Server.Elements.Vehicle GetClosestOwnedOrFactionVehicle(Player sender, int factionId, int distance)
 {
     GrandTheftMultiplayer.Server.Elements.Vehicle closest = null;
     foreach (Vehicle v in Vehicle.VehicleData.Values)
     {
         if (v.IsAdminVehicle)
         {
             continue;
         }
         if (v.IsDealerVehicle)
         {
             continue;
         }
         if (!(v.Entity.position.DistanceTo(sender.Client.position) < distance))
         {
             continue;
         }
         if (closest != null &&
             !(Vehicle.VehicleData[closest].Entity.position.DistanceTo(sender.Client.position) >
               v.Entity.position.DistanceTo(sender.Client.position)))
         {
             continue;
         }
         if (v.FactionId == factionId || sender.Inventory.Count(k => k.Value == v.Key) == 1)
         {
             closest = v.Entity;
         }
     }
     return(closest);
 }
示例#7
0
        public static bool OwnACar(Client _Owner, GrandTheftMultiplayer.Server.Elements.Vehicle _vehicle, GrandTheftMultiplayer.Shared.VehicleHash _VehModelId)
        {
            try
            {
                var _veh = new Models.Vehicle
                {
                    VehicleId = currentVehList.Items.Count > 0 ? currentVehList.Items.LastOrDefault().VehicleId + 1 : 1,
                    Plate     = "LS" + (currentVehList.Items.Count > 0 ? currentVehList.Items.LastOrDefault().VehicleId + 1 : 1).ToString(),
                    //Color1 = _vehicle.primaryColor,
                    //Color2 = _vehicle.secondaryColor,
                    Fuel                = 100,
                    IsLocked            = false,
                    LastPosition        = _vehicle.position,
                    LastRotation        = _vehicle.rotation,
                    OwnerSocialClubName = _Owner.socialClubName,
                    VehicleModelId      = _VehModelId,
                    FactionId           = -1,
                    JobId               = -1,
                };

                for (int i = 0; i <= 69; i++)
                {
                    _veh.Mods[i] = -1;
                }

                currentVehList.Items.Add(_veh);
                SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                API.shared.consoleOutput(LogCat.Warn, ex.ToString());
                return(false);
            }
        }
示例#8
0
 public static GrandTheftMultiplayer.Server.Elements.Vehicle GetClosestFactionVehicle(Client sender, int factionId, int distance)
 {
     GrandTheftMultiplayer.Server.Elements.Vehicle closest = null;
     foreach (Vehicle v in Vehicle.VehicleData.Values)
     {
         if (v.IsAdminVehicle)
         {
             continue;
         }
         if (v.IsDealerVehicle)
         {
             continue;
         }
         if (v.Entity.position.DistanceTo(sender.position) < distance)
         {
             if (closest == null ||
                 Vehicle.VehicleData[closest].Entity.position.DistanceTo(sender.position) > v.Entity.position.DistanceTo(sender.position))
             {
                 if (v.FactionId == factionId)
                 {
                     closest = v.Entity;
                 }
             }
         }
     }
     return(closest);
 }
示例#9
0
 private void respawnFarmVehicle(Client player, Vehicle v)
 {
     API.sendChatMessageToPlayer(player, "Get back in the vehicle or the vehicle will despawn!");
     API.delay(10000, true, () =>
     {
         GrandTheftMultiplayer.Server.Elements.Vehicle vehicle = v.Entity;
         if (API.getVehicleOccupants(vehicle).FirstOrDefault() != null &&
             v.SidejobUserId != Player.PlayerData[player].Id)
         {
             v.SidejobUserId = -1;
             stopFarmSidejob(player);
         }
         if (API.getVehicleOccupants(vehicle).FirstOrDefault() == null)
         {
             if (API.getEntityData(v.Entity, "farmTrailer") != null)
             {
                 API.deleteEntity(API.getEntityData(v.Entity, "farmTrailer"));
             }
             API.deleteEntity(vehicle);
             v.SidejobUserId = -1;
             v.IsEngineOn    = false;
             v.Entity        = null;
             spawnTractor(v);
             stopFarmSidejob(player);
         }
     }
               );
 }
示例#10
0
        /// <summary>
        /// Возвращает ближайшую машину
        /// </summary>
        public Vehicle GetNearestVehicle(Client player, float range, string key = null)
        {
            var playerPosition = API.getEntityPosition(player);
            var vehicles       = GetAllVehicles().Where(e => Vector3.Distance(e.position, playerPosition) < 10f);

            if (key != null)
            {
                vehicles = vehicles.Where(e => API.getEntityData(e, key) != null).ToList();
            }
            Vehicle result          = null;
            var     nearestDistance = float.MaxValue;

            foreach (var vehicle in vehicles)
            {
                var position = API.getEntityPosition(vehicle);
                var distance = Vector3.Distance(position, playerPosition);
                if (distance > range || distance >= nearestDistance)
                {
                    continue;
                }
                nearestDistance = distance;
                result          = API.getEntityFromHandle <Vehicle>(vehicle);
            }
            return(result);
        }
示例#11
0
        /// <summary>
        /// Проверить, что транспорт находится на респауне в корректном состоянии
        /// </summary>
        private bool OnRespawnAndCorrect(Vehicle vehicle, Vector3 respawnPosition)
        {
            var distance = Vector3.Distance(respawnPosition, vehicle.position);
            var fuel     = API.getVehicleFuelLevel(vehicle);

            return(distance <= MIN_SPAWN_FAULT && vehicle.health > 0 && fuel > 10);
        }
示例#12
0
        public void DriveTo(GrandTheftMultiplayer.Server.Elements.Vehicle veh, float x, float y, float z, float speed)
        {
            pedHandle.DriveTo(veh, x, y, z, speed);

            API.deleteColShape(destColShape);
            destColShape = API.createCylinderColShape(new Vector3(x, y, z), 2.5f, 2.5f);
            destColShape.onEntityEnterColShape += onDestinationReached;
        }
示例#13
0
        /// <summary>
        /// Проверяет, что транспорт брошен
        /// </summary>
        public static bool IsAfk(Vehicle vehicle, int maxAfkMinutes)
        {
            if (!vehicle.hasData(VehicleEventsManager.AFK_KEY))
            {
                return(false);
            }
            var afkPeriod = DateTime.Now - (DateTime)vehicle.getData(VehicleEventsManager.AFK_KEY);

            return(afkPeriod.TotalMinutes >= maxAfkMinutes);
        }
示例#14
0
 public static void AttachTrailer(this GrandTheftMultiplayer.Server.Elements.Vehicle veh, NetHandle trailer)
 {
     foreach (Client c in API.shared.getAllPlayers())
     {
         if (c.vehicle != veh)
         {
             API.shared.sendNativeToPlayer(c, Hash.ATTACH_VEHICLE_TO_TRAILER, veh, Vehicle.VehicleData[trailer].Entity, 10f);
         }
     }
 }
示例#15
0
 public static Models.Vehicle FindVehicleByGameVehicle(GrandTheftMultiplayer.Server.Elements.Vehicle _vehicle)
 {
     foreach (var item in db_Vehicles.GetAll())
     {
         if (item.VehicleOnMap == _vehicle)
         {
             return(item);
         }
     }
     return(null);
 }
示例#16
0
 public static int ID(this GrandTheftMultiplayer.Server.Elements.Vehicle veh)
 {
     for (int i = 0; i < 2000; i++)
     {
         if (Vehicle.IDs[i] == veh)
         {
             return(i);
         }
     }
     return(-1);
 }
示例#17
0
 public static void TriggerDoor(GrandTheftMultiplayer.Server.Elements.Vehicle vehicle, int doorId)
 {
     if (vehicle.isDoorOpen(doorId))
     {
         vehicle.closeDoor(doorId);
     }
     else
     {
         vehicle.openDoor(doorId);
     }
 }
示例#18
0
 public static void CreateID(this GrandTheftMultiplayer.Server.Elements.Vehicle veh)
 {
     for (int i = 0; i < 2000; i++)
     {
         if (Vehicle.IDs[i] == null)
         {
             Vehicle.IDs[i] = veh;
             return;
         }
     }
 }
示例#19
0
 public static void DriveTo(this Ped ped, GrandTheftMultiplayer.Server.Elements.Vehicle veh, float x, float y, float z, float speed)
 {
     Task.Run(async() =>
     {
         while (veh.position.DistanceTo(new Vector3(x, y, z)) > 5)
         {
             await Task.Delay(1000);
             API.shared.setEntityPositionFrozen(ped, false);
             API.shared.sendNativeToAllPlayers(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, ped.handle, veh, x, y, z, speed, 1 | 2 | 16 | 32 | 128 | 256 | 262144, 10f);
         }
     });
 }
示例#20
0
 private bool isPlayerOnBoat(Client player)
 {
     GrandTheftMultiplayer.Server.Elements.Vehicle veh = Globals.GetClosestVehicle(player, 4);
     if (veh != null && API.getVehicleClassName(API.getVehicleClass((VehicleHash)veh.model.GetHashCode())).Equals("Boats"))
     {
         return(API.fetchNativeFromPlayer <bool>(player, Hash.IS_ENTITY_IN_WATER, veh));
     }
     else
     {
         return(false);
     }
 }
示例#21
0
 public static void WarpIntoVehicleForPlayer(this Ped ped, Client player, GrandTheftMultiplayer.Server.Elements.Vehicle veh, int seat)
 {
     Task.Run(async() =>
     {
         for (int i = 0; i < 3; i++)
         {
             await Task.Delay(1000);
             API.shared.setEntityPositionFrozen(ped, false);
             API.shared.sendNativeToPlayer(player, Hash.TASK_WARP_PED_INTO_VEHICLE, ped, veh, seat);
         }
     });
 }
示例#22
0
 public static void EnterVehicle(this Ped ped, GrandTheftMultiplayer.Server.Elements.Vehicle veh, int seat, int duration = 20, int flag = 1)
 {
     Task.Run(async() =>
     {
         for (int i = 0; i < duration; i++)
         {
             await Task.Delay(1000);
             API.shared.setEntityPositionFrozen(ped, false);
             API.shared.sendNativeToAllPlayers(Hash.TASK_ENTER_VEHICLE, ped, veh, -1, seat, 1.0, flag, 0);
         }
     });
 }
示例#23
0
 public static void EnterVehicle(this Client player, GrandTheftMultiplayer.Server.Elements.Vehicle veh, int seat)
 {
     Task.Run(async() =>
     {
         for (int i = 0; i < 4; i++)
         {
             await Task.Delay(1000);
             API.shared.setEntityPositionFrozen(player, false);
             API.shared.sendNativeToPlayersInDimension(player.dimension, Hash.TASK_ENTER_VEHICLE, player, veh, -1, seat, 1.0, 1, 0);
         }
     });
 }
示例#24
0
 public void GetVehiclesID(Client player)
 {
     GrandTheftMultiplayer.Server.Elements.Vehicle veh = Globals.GetClosestVehicle(player, 4);
     if (veh != null)
     {
         Message.Info(player, "Vehicle ID: " + Globals.GetVehicleID(veh));
     }
     else
     {
         API.SendWarningNotification(player, "No vehicle in your proximity.");
     }
 }
示例#25
0
        /// <summary>
        /// Устанавливает дополнительные настройки для некоторого транспорта
        /// </summary>
        private void SetAdditionalSettings(Vehicle vehicle)
        {
            var hash = (VehicleHash)API.getEntityModel(vehicle);

            if (hash == VehicleHash.Dinghy2)
            {
                API.setEntityPositionFrozen(vehicle, true);
            }
            if (NotUpdates.Contains(hash))
            {
                API.setEntityInvincible(vehicle, true);
            }
        }
示例#26
0
        /// <summary>
        /// Выставляет стандартные значения тюнинга
        /// </summary>
        private static void ResetTuning(Vehicle vehicle)
        {
            const int defaultValue = -1;
            var       vehicleHash  = (VehicleHash)API.shared.getEntityModel(vehicle);
            var       allMods      = API.shared.getVehicleValidMods(vehicleHash).Keys;

            foreach (var mod in allMods)
            {
                API.shared.setVehicleMod(vehicle, mod, defaultValue);
            }
            TurnNeonState(vehicle, false);
            API.shared.setVehicleEnginePowerMultiplier(vehicle, 0);
        }
示例#27
0
 /// <summary>
 /// Удалить транспорт игрока и отправить на штрафстоянку
 /// </summary>
 private void RemoveVehicle(Vehicle vehicle)
 {
     if (vehicle.hasData(OWNER_ID) && !RentOfScootersMenuHandler.IsScooter(vehicle.model))
     {
         var vehicleInfo = _vehicleInfoManager.GetInfoByHandle(vehicle);
         if (vehicleInfo != null)
         {
             vehicleInfo.IsSpawned     = false;
             vehicleInfo.OnParkingFine = true;
             _vehicleInfoManager.SetInfo(vehicleInfo);
         }
     }
     vehicle.delete();
 }
示例#28
0
        /// <summary>
        /// Восстановить начальную позицию транспорта
        /// </summary>
        public void RestorePosition(Vehicle vehicle)
        {
            var info   = (CommonVehicle)vehicle.getData(VEHICLE_INFO_KEY);
            var driver = API.getVehicleDriver(vehicle);

            if (vehicle.hasData(DONT_RESTORE) || OnRespawnAndCorrect(vehicle, info.SpawnPosition) || driver != null)
            {
                return;
            }
            if (vehicle.hasData(VehicleEventsManager.AFK_KEY) && !IsAfk(vehicle, 20))
            {
                return;
            }
            vehicle.delete();
            CreateVehicle(info);
        }
示例#29
0
 public static void DetachTrailer(this GrandTheftMultiplayer.Server.Elements.Vehicle veh)
 {
     foreach (Client c in API.shared.getAllPlayers())
     {
         if (c.vehicle != veh)
         {
             API.shared.sendNativeToAllPlayers(Hash.DETACH_VEHICLE_FROM_TRAILER, veh);
         }
     }
     Task.Run(() =>
     {
         API.shared.sleep(50);
         Vector3 pos = API.shared.getEntityPosition(veh);
         API.shared.sleep(450);
         API.shared.setEntityPosition(veh, pos);
     });
 }
示例#30
0
        public static void Delete(this GrandTheftMultiplayer.Server.Elements.Vehicle veh, bool removeVehicleData = true)
        {
            for (int i = 0; i < 2000; i++)
            {
                if (Vehicle.IDs[i] == veh)
                {
                    Vehicle.IDs[i] = null;
                    break;
                }
            }

            if (removeVehicleData)
            {
                Vehicle.VehicleData.Remove(veh);
            }
            API.shared.deleteEntity(veh);
        }