Ejemplo n.º 1
0
        private void OnVehicleEngineToggle(Client player, NetHandle vehicle, bool state)
        {
            if (state == true)
            {
                if (vehicle.GetVehicle() == null)
                {
                    return;
                }

                if (_testVehicles.Any(x => x[2] == vehicle.GetVehicle()))
                {
                    var c = player.GetCharacter();

                    if (c.IsInDmvTest)
                    {
                        c.TimeStartedDmvTest = DateTime.Now;
                        player.SetData("DMV_VEHICLE", vehicle);
                        NAPI.ClientEvent.TriggerClientEvent(player, "DMV_STARTTEST", _testCheckpoints, vehicle);
                        NAPI.Chat.SendChatMessageToPlayer(player, "~y~** GO! You'll have to finish in less than or equal to 5 minutes and with more than 999 damage to the vehicle.");
                        NAPI.Chat.SendChatMessageToPlayer(player, "~y~** You have plently of time so drive safe and make sure you don't break your vehicle.");
                    }
                    else
                    {
                        if (!player.GetAccount().AdminDuty)
                        {
                            NAPI.Chat.SendChatMessageToPlayer(player, "You haven't started the driving test.");
                            NAPI.Vehicle.SetVehicleEngineStatus(vehicle, false);
                            // CONV NOTE: proper delay needed probably
                            //API.Delay(1000, true, () => API.WarpPlayerOutOfVehicle(player));
                            Task.Delay(1000).ContinueWith(t => API.WarpPlayerOutOfVehicle(player));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void API_onPlayerEnterVehicle(Client player, NetHandle vehicle, int seat)
        {
            var veh       = vehicle.GetVehicle();
            var character = player.GetCharacter();

            if (veh?.Job?.Type == JobManager.JobTypes.Trucker && character.JobOne?.Type == JobManager.JobTypes.Trucker)
            {
                if (API.HasEntityData(player, "TRUCKING_CANCELTIMER") &&
                    API.GetEntityData(vehicle, "TRUCKER_DRIVER") == player)
                {
                    Timer timer = API.GetEntityData(player, "TRUCKING_CANCELTIMER");
                    timer.Dispose();
                    API.ResetEntityData(player, "TRUCKING_CANCELTIMER");
                    API.SendChatMessageToPlayer(player, "You've got back into the truck.");
                    return;
                }

                if (API.GetEntityData(vehicle, "TRUCKER_DRIVER") == player)
                {
                    return;
                }

                if (character.TruckingStage != Character.TruckingStages.None)
                {
                    API.Delay(1000, true, () => API.WarpPlayerOutOfVehicle(player));;
                    return;
                }

                character.TruckingStage = Character.TruckingStages.GettingTrailer;
                API.SetEntityData(vehicle, "TRUCKER_DRIVER", player);
                API.SetEntityData(player, "TRUCKER_VEHICLE", vehicle);
                API.SendChatMessageToPlayer(player, "~r~[Trucking]~w~ Decide what to deliver using ~g~/startrun [supplies/gas].");
            }
        }
Ejemplo n.º 3
0
        public void CancelRun(Client player)
        {
            if (player.GetCharacter().TruckingStage == Character.TruckingStages.None)
            {
                return;
            }

            //Respawn cars and warp out.
            player.GetCharacter().TruckingStage = Character.TruckingStages.None;
            NetHandle veh = API.GetEntityData(player, "TRUCKER_VEHICLE");

            if (player.vehicle != null && player.vehicle == veh)
            {
                API.Delay(1000, true, () => API.WarpPlayerOutOfVehicle(player));
            }
            ;

            if (!veh.IsNull)
            {
                VehicleManager.respawn_vehicle(veh.GetVehicle());
            }

            //Reset Timers.
            Timer timer = API.GetEntityData(player, "TRUCKING_CANCELTIMER");

            timer?.Dispose();
            timer = API.GetEntityData(player, "TRUCKING_UNLOAD_TIMER");
            timer?.Dispose();
            timer = API.GetEntityData(player, "TRUCKING_LOAD_TIMER");
            timer?.Dispose();
            API.ResetEntityData(player, "TRUCKING_CANCELTIMER");
            API.ResetEntityData(player, "TRUCKING_UNLOAD_TIMER");
            API.ResetEntityData(player, "TRUCKING_LOAD_TIMER");

            //Reset other variables
            API.ResetEntityData(player, "TRUCKER_VEHICLE");
            API.ResetEntityData(veh, "TRUCKER_DRIVER");

            //Unfreeze and send message.
            API.FreezePlayer(player, false);
            API.SendChatMessageToPlayer(player, "The trucking run has been done or cancelled.");
        }
Ejemplo n.º 4
0
        private void API_onPlayerEnterVehicle(Client player, NetHandle vehicle, int seat)
        {
            if (vehicle.GetVehicle() == null)
            {
                return;
            }

            if (API.GetEntityModel(vehicle) == (int)VehicleHash.Flatbed && player.GetCharacter().JobOne.Type == JobManager.JobTypes.Lumberjack)
            {
                Vehicle veh = API.GetEntityData(vehicle, "Vehicle");
                if (veh.Job?.Type != JobManager.JobTypes.Lumberjack)
                {
                    return;
                }

                Tree tree = API.GetEntityData(vehicle, "TREE_OBJ");
                if (tree == null)
                {
                    return;
                }

                if (API.HasEntityData(vehicle, "TREE_DRIVER"))
                {
                    int id = API.GetEntityData(vehicle, "TREE_DRIVER");
                    if (id != player.GetCharacter().Id)
                    {
                        API.Delay(1000, true, () => API.WarpPlayerOutOfVehicle(player));;
                        API.SendChatMessageToPlayer(player, "This is not yours.");
                        return;
                    }
                }

                if (API.HasEntityData(vehicle, "Tree_Cancel_Timer"))
                {
                    System.Threading.Timer timer = API.GetEntityData(vehicle, "Tree_Cancel_Timer");
                    timer.Dispose();
                    API.ResetEntityData(vehicle, "Tree_Cancel_Timer");
                    API.SendChatMessageToPlayer(player, "You've got back into your vehicle.");
                }
            }
        }