Exemple #1
0
        //Thanks Trojaner
        public static void KickVehicle(InteractableVehicle vehicle)
        {
            byte seat = 0;

            foreach (var passenger in vehicle.passengers)
            {
                vehicle.kickPlayer(seat);
                seat++;
            }
        }
Exemple #2
0
 private void OnPlayerUpdateStance(UnturnedPlayer player, byte stance)
 {
     if (stance == (byte)6 && LIGHT.Instance.Configuration.Instance.AllowCarOwnerShip)
     {
         InteractableVehicle veh = player.Player.Movement.getVehicle();
         if (LIGHT.Instance.DatabaseCar.CheckCarExistInDB(veh.instanceID.ToString()))
         {
             if (LIGHT.Instance.DatabaseCar.CheckCarDestoryed(veh.instanceID.ToString()) != veh.id.ToString())
             {
                 uint   CheckIDOld = veh.instanceID + 1;
                 string PlayerID   = LIGHT.Instance.DatabaseCar.GetOwnerID((CheckIDOld).ToString());
                 string CarID      = LIGHT.Instance.DatabaseCar.GetCarID((CheckIDOld).ToString());
                 if (PlayerID == player.Id && CarID == veh.id.ToString())
                 {
                     LIGHT.Instance.DatabaseCar.RemovedDestoryedCar(veh.instanceID.ToString());
                     LIGHT.Instance.DatabaseCar.RemovedDestoryedCar(CheckIDOld.ToString());
                     LIGHT.Instance.DatabaseCar.AddOwnership(veh.instanceID.ToString(), player.Id, player.SteamName);
                     return;
                 }
                 else
                 {
                     for (int x = 0; x < 10; x++)
                     {
                         CheckIDOld++;
                         PlayerID = LIGHT.Instance.DatabaseCar.GetOwnerID(CheckIDOld.ToString());
                         CarID    = LIGHT.Instance.DatabaseCar.GetCarID(CheckIDOld.ToString());
                         if (PlayerID == player.Id && CarID == veh.id.ToString())
                         {
                             LIGHT.Instance.DatabaseCar.RemovedDestoryedCar(veh.instanceID.ToString());
                             LIGHT.Instance.DatabaseCar.RemovedDestoryedCar(CheckIDOld.ToString());
                             LIGHT.Instance.DatabaseCar.AddOwnership(veh.instanceID.ToString(), player.Id, player.SteamName);
                             return;
                         }
                     }
                 }
                 LIGHT.Instance.DatabaseCar.RemovedDestoryedCar(veh.instanceID.ToString());
                 if (!LIGHT.Instance.Configuration.Instance.DriveUnownedCar)
                 {
                     byte seat = 0;
                     foreach (Passenger p in player.Player.Movement.getVehicle().passengers)
                     {
                         if (p.player.playerID.steamID.ToString() == player.Id)
                         {
                             break;
                         }
                         seat++;
                     }
                     veh.kickPlayer(seat);
                 }
                 LIGHT.Instance.DatabaseCar.AddCar(veh.instanceID.ToString(), veh.id.ToString(), veh.name);
                 UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("lpx_car_promotebuy", veh.instanceID.ToString()));
                 return;
             }
             if (LIGHT.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()) == "")
             {
                 UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("lpx_car_promotebuy", veh.instanceID.ToString()));
                 if (!LIGHT.Instance.Configuration.Instance.DriveUnownedCar)
                 {
                     byte seat = 0;
                     foreach (Passenger p in player.Player.Movement.getVehicle().passengers)
                     {
                         if (p.player.playerID.steamID.ToString() == player.Id)
                         {
                             break;
                         }
                         seat++;
                     }
                     veh.kickPlayer(seat);
                 }
                 return;
             }
             if (player.Id != LIGHT.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()))
             {
                 string[] PlayersWithKey = LIGHT.Instance.DatabaseCar.GetGivenKeys(veh.instanceID.ToString());
                 for (int x = 0; x < PlayersWithKey.Length; x++)
                 {
                     if (PlayersWithKey[x].Trim() == player.Id)
                     {
                         UnturnedChat.Say(player, LIGHT.Instance.Translate("car_key_used", veh.instanceID.ToString()));
                         return;
                     }
                 }
                 if (LIGHT.Instance.DatabaseCar.CheckLockedStatus(veh.instanceID.ToString()))
                 {
                     byte seat = 0;
                     foreach (Passenger p in player.Player.Movement.getVehicle().passengers)
                     {
                         if (p.player.playerID.steamID.ToString() == player.Id)
                         {
                             break;
                         }
                         seat++;
                     }
                     veh.kickPlayer(seat);
                     UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("lpx_car_ownerfalse"));
                 }
                 else
                 {
                     UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("car_not_locked", LIGHT.Instance.DatabaseCar.GetOwnerName(veh.instanceID.ToString())));
                 }
             }
             else
             {
                 UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("lpx_car_ownertrue"));
             }
         }
         else
         {
             if (!LIGHT.Instance.Configuration.Instance.DriveUnownedCar)
             {
                 byte seat = 0;
                 foreach (Passenger p in player.Player.Movement.getVehicle().passengers)
                 {
                     if (p.player.playerID.steamID.ToString() == player.Id)
                     {
                         break;
                     }
                     seat++;
                 }
                 veh.kickPlayer(seat);
             }
             LIGHT.Instance.DatabaseCar.AddCar(veh.instanceID.ToString(), veh.id.ToString(), veh.name);
             UnturnedChat.Say(player.CSteamID, LIGHT.Instance.Translate("lpx_car_promotebuy", veh.instanceID.ToString()));
         }
     }
 }