public void Event_TryEnterToInterior(Client player)
        {
            Character charData = Account.GetPlayerData(player);

            if (charData == null)
            {
                return;
            }

            DoorInfo nearestDoor = Library.GetNearestDoor(charData);

            if (nearestDoor == null)
            {
                return;
            }

            // Przetrzymywanie
            if (charData.DetentionDoorId != 0)
            {
                if (charData.DetentionTime > Global.GetTimestamp())
                {
                    Ui.ShowWarning(player, "Twoja postać jest przetrzymywana, nie możesz przejść przez drzwi.");
                    return;
                }

                charData.DetentionDoorId = 0;
                charData.DetentionTime   = 0;
                charData.Save();
            }

            if (player.IsInVehicle)
            {
                Ui.ShowInfo(player, "Aby skorzystać z przejazdu pojazdem użyj komendy /przejazd.");
                return;
            }

            if (nearestDoor.DoorData.Locked)
            {
                Ui.ShowInfo(player, "Drzwi są zamknięte.");
                return;
            }


            if (nearestDoor.DoorType == DoorType.Out)
            {
                if ((int)Math.Floor(nearestDoor.DoorData.InX) == 0)
                {
                    Ui.ShowInfo(player, "Drzwi nie mają ustawionego wejścia.");
                    return;
                }
            }

            NAPI.ClientEvent.TriggerClientEvent(player, "client.doors.fadeOut");
        }
        public void Event_EnterInterior(Client player)
        {
            Character charData = Account.GetPlayerData(player);

            if (charData == null)
            {
                return;
            }

            DoorInfo nearestDoor = Library.GetNearestDoor(charData);

            if (nearestDoor == null)
            {
                return;
            }

            if (nearestDoor.DoorType == DoorType.Out)
            {
                if ((int)Math.Floor(nearestDoor.DoorData.InX) == 0)
                {
                    Ui.ShowInfo(player, "Drzwi nie mają ustawionego wejścia.");
                    return;
                }

                if (!player.IsInVehicle)
                {
                    player.Dimension = (uint)nearestDoor.DoorData.InDim;
                    player.Position  = new Vector3(nearestDoor.DoorData.InX, nearestDoor.DoorData.InY,
                                                   nearestDoor.DoorData.InZ);
                    player.Rotation = new Vector3(0, 0, nearestDoor.DoorData.InAngle);
                }
            }
            else if (nearestDoor.DoorType == DoorType.In)
            {
                if (!player.IsInVehicle)
                {
                    player.Dimension = (uint)nearestDoor.DoorData.OutDim;
                    player.Position  = new Vector3(nearestDoor.DoorData.OutX, nearestDoor.DoorData.OutY,
                                                   nearestDoor.DoorData.OutZ);
                    player.Rotation = new Vector3(0, 0, nearestDoor.DoorData.OutAngle);
                }
            }

            NAPI.ClientEvent.TriggerClientEvent(player, "client.doors.fadeIn");
        }
Beispiel #3
0
        /// <summary>
        /// Pobiera najbliższe drzwi.
        /// </summary>
        /// <param name="charData"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public static DoorInfo GetNearestDoor(Character charData, double range = 2.5)
        {
            if (charData == null)
            {
                return(null);
            }

            double   nearestRange = range;
            DoorInfo nearestDoors = null;

            foreach (KeyValuePair <int, InteriorDoor> entry in InteriorDoorsList)
            {
                if (charData.PlayerHandle.Dimension == entry.Value.OutDim) // Jeśli gracz jest na vw wyjściowym
                {
                    double distance = Global.GetDistanceBetweenPositions(charData.PlayerHandle.Position,
                                                                         new Vector3(entry.Value.OutX, entry.Value.OutY, entry.Value.OutZ));

                    if (distance < nearestRange)
                    {
                        nearestRange = distance;
                        nearestDoors = new DoorInfo {
                            DoorType = DoorType.Out, DoorData = entry.Value
                        };
                    }
                }
                else if (charData.PlayerHandle.Dimension == entry.Value.InDim) // Jeśli gracz jest na vw wejściowym
                {
                    double distance = Global.GetDistanceBetweenPositions(charData.PlayerHandle.Position,
                                                                         new Vector3(entry.Value.InX, entry.Value.InY, entry.Value.InZ));

                    if (distance < nearestRange)
                    {
                        nearestRange = distance;
                        nearestDoors = new DoorInfo {
                            DoorType = DoorType.In, DoorData = entry.Value
                        };
                    }
                }
            }

            return(nearestDoors);
        }
Beispiel #4
0
        public void CmdDrzwi(Client player, string args = "")
        {
            Character charData = Account.GetPlayerData(player);

            if (charData == null)
            {
                return;
            }

            string[]     arguments = Command.GetCommandArguments(args);
            const string legend    = "/drzwi [zamknij]";

            DoorInfo doorData = Library.GetNearestDoor(charData);

            if (doorData == null)
            {
                Ui.ShowError(player, "Nie stoisz przy żadnych drzwiach.");
                return;
            }

            Interior interiorData = Library.GetInteriorData(doorData.DoorData.ParentId);

            if (interiorData == null)
            {
                Ui.ShowError(player, "Nie znaleziono interioru do którego przypisane są drzwi.");
                return;
            }

            if (!Library.DoesPlayerHasInteriorPerm(charData, interiorData))
            {
                Ui.ShowError(player, "Nie posiadasz odpowiednich uprawnień.");
            }

            if (arguments.Length < 1)
            {
                Ui.ShowUsage(player, legend);
                return;
            }

            string fOption = arguments[0].ToLower();

            if (fOption == "zamknij")
            {
                if (doorData.DoorData.Locked)
                {
                    Ui.ShowInfo(player, "Drzwi zostały otwarte.");
                    Chat.Library.SendPlayerMeMessage(charData, "otwiera drzwi.", true);
                    doorData.DoorData.Locked = false;
                }
                else
                {
                    Ui.ShowInfo(player, "Drzwi zostały zamknięte.");
                    Chat.Library.SendPlayerMeMessage(charData, "zamyka drzwi.", true);
                    doorData.DoorData.Locked = true;
                }

                doorData.DoorData.Save();
            }
            else
            {
                Ui.ShowUsage(player, legend);
            }
        }