Example #1
0
        private void GasStation_PlayerKeyStateChange(object sender, KeyStateChangedEventArgs e)
        {
            if (!(sender is Player player))
            {
                return;
            }

            if (!KeyUtils.HasPressed(e.NewKeys, e.OldKeys, Keys.Crouch))
            {
                return;
            }

            if (!player.IsDriving())
            {
                return;
            }

            if (!GasStations.Any(gasStation => player.IsInRangeOfPoint(2.5f, gasStation.Position)))
            {
                return;
            }

            player.GameText("~g~Refuelling...", 3000, 4);
            player.ToggleControllable(false);

            var refuelTimer = new Timer(TimeSpan.FromSeconds(5), false);

            refuelTimer.Tick += (senderObject, ev) => RefuelVehicle(senderObject, ev, player);
        }
Example #2
0
        private async void Assistance_PlayerKeyStateChanged(object sender, SampSharp.GameMode.Events.KeyStateChangedEventArgs e)
        {
            if (!(sender is Player player))
            {
                return;
            }

            if (player.PlayerClass != PlayerClassType.Assistance)
            {
                return;
            }

            if (KeyUtils.HasPressed(e.NewKeys, e.OldKeys, SampSharp.GameMode.Definitions.Keys.Aim))
            {
                await FixPlayerVehicleAsync(player);
            }

            if (KeyUtils.HasPressed(e.NewKeys, e.OldKeys, SampSharp.GameMode.Definitions.Keys.Fire))
            {
                FixOwnVehicle(player);
            }
        }
Example #3
0
        private async void Police_PlayerKeyStateChanged(object sender, SampSharp.GameMode.Events.KeyStateChangedEventArgs e)
        {
            if (!(sender is Player player))
            {
                return;
            }

            if (player.PlayerClass != PlayerClassType.Police)
            {
                return;
            }

            if (KeyUtils.HasPressed(e.NewKeys, e.OldKeys, SampSharp.GameMode.Definitions.Keys.Aim) && player.Vehicle == null)
            {
                await FineNearbyPlayersAsync(player);

                return;
            }

            if (KeyUtils.HasPressed(e.NewKeys, e.OldKeys, SampSharp.GameMode.Definitions.Keys.Action) && player.Vehicle != null)
            {
                WarnNearbyPlayers(player);
            }
        }