Exemplo n.º 1
0
 private static void loginResponse(dynamic result, params object[] arguments)
 {
     lock (loginResponseObject)
     {
         try
         {
             if (result.ContainsKey("userAuth") && result["userAuth"] == true)
             {
                 onlineUsername = "";
                 if (result.ContainsKey("userName"))
                 {
                     onlineUsername = (string)result["userName"];
                 }
                 isLogged = true;
                 LiveTicker.AddTicker("I'm now On-Duty");
                 ExperienceManager.UpdateExp(5, "Login Bonus");
                 ExperienceManager.SelectPlayerInfo();
                 NotificationManager.addNotification("[~b~Police~s~Life~r~S~s~]: You have been ~g~successfully~s~ logged in ~b~Officer " + onlineUsername);
             }
             else
             {
                 NotificationManager.addNotification("[~b~Police~s~Life~r~S~s~]: ~r~You have a invalid Token, your data will not be updated with our Server. ~w~Visit http://PoliceLifeS.de for more Infos");
                 Game.DisplayHelp("In our online mode, you have more options (EXP System, Callout Statistics and more)");
             }
         }
         catch (Exception ex)
         {
             Game.LogTrivial(ex.ToString());
         }
     }
 }
Exemplo n.º 2
0
        private static void ShiftFinish()
        {
            inShiftWork = false;
            int exp   = 35;
            int money = 1350;

            if (arrestedPeds > 2 && arrestedPeds <= 5)
            {
                exp = 50; money = 1500;
            }
            else if (arrestedPeds > 5 && arrestedPeds <= 10)
            {
                exp = 80; money = 1800;
            }
            else if (arrestedPeds > 10 && arrestedPeds <= 15)
            {
                exp = 150; money = 2100;
            }
            if (PlayerAuthenticate.isLogged)
            {
                ExperienceManager.UpdateExp(exp, "Finished shiftwork");
                LiveTicker.AddTicker("I have <font color='green'>successfully completed</font> my shift work");
                Main.myPlayer.playerMoney += money;
            }
            else
            {
                NotificationManager.addNotification("Your money was ~r~not saved~s~, because you are ~r~not logged in");
            }
            NotificationManager.addNotification("~s~Your shift work is completed.\n\nArrested people: ~g~" + arrestedPeds + "\n+" + money + "$\n\n~s~Good work ~b~Officer " + PlayerAuthenticate.onlineUsername);
        }
Exemplo n.º 3
0
        public static void Progress()
        {
            GameFiber.StartNew(delegate
            {
                Game.DisplayNotification("[~b~Police~s~Life~r~S~s~]: ~b~Please wait ...");
                GameFiber.Sleep(5000);
                PlayerAuthenticate.Login();
                CreateStations.CreateGasStations();
                while (true)
                {
                    try
                    {
                        var player = Game.LocalPlayer.Character;
                        if (player != null)
                        {
                            if (player.IsAlive)
                            {
                                HungerFactory.ConsumptionsHitPoints(myPlayer);
                                DrawTexture.changePlayerLifeTexture(myPlayer);
                                CalloutManagement.checkisCalloutRunning();

                                if (ScreenWidth != Game.Resolution.Width || ScreenHeight != Game.Resolution.Height)
                                {
                                    //Reinitalisiere Texturen, wenn Auflösung sich ändert
                                    ScreenWidth  = Game.Resolution.Width;
                                    ScreenHeight = Game.Resolution.Height;
                                    DrawTexture.initTextures();
                                }
                            }

                            if (player.IsInAnyVehicle(false))
                            {
                                var currentVehicle = player.CurrentVehicle;
                                if (currentVehicle != null)
                                {
                                    currentVehicle.Metadata.BrakeEnable = (Game.IsKeyDownRightNow(ReadIniFile.HandBrakeKey) ? true : false);

                                    if (Game.IsKeyDown(ReadIniFile.ToggleEngineKey))
                                    {
                                        currentVehicle.IsEngineOn = !currentVehicle.IsEngineOn;
                                    }

                                    if (Game.IsKeyDown(Keys.F9))
                                    {
                                        if (!DrawTexture.getTextureVisible("policeRadio"))
                                        {
                                            var policeRadio = DrawTexture.getDrawObject("policeRadio");
                                            if (policeRadio != null)
                                            {
                                                if (policeRadio.texture == null)
                                                {
                                                    policeRadio.texture = DrawTexture.getTextureFromResource(Resources.policeradio);
                                                    policeRadio.x       = policeRadio.texture.Size.Width * 2;
                                                    policeRadio.y       = Game.Resolution.Height - policeRadio.texture.Size.Height;
                                                    policeRadio.width   = policeRadio.texture.Size.Width;
                                                    policeRadio.height  = policeRadio.texture.Size.Height;
                                                }
                                                DrawTexture.setTextureVisible("policeRadio", true);
                                            }
                                            else
                                            {
                                                Game.DisplayNotification("[~b~Police~s~Life~r~S~s~]: ~r~PoliceRadio Texture Initialization Error");
                                            }
                                        }
                                        else
                                        {
                                            DrawTexture.setTextureVisible("policeRadio", false);
                                        }
                                    }

                                    if (Game.IsKeyDown(ReadIniFile.IndicatorLeftKey))
                                    {
                                        if (currentVehicle.Metadata.IndicatorLeft != null && currentVehicle.Metadata.IndicatorLeft)
                                        {
                                            currentVehicle.Metadata.IndicatorLeft  = false;
                                            currentVehicle.Metadata.IndicatorRight = false;
                                            DrawTexture.blinkTimer.Stop();
                                            DrawTexture.blinkStatus = false;
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Off;
                                        }
                                        else
                                        {
                                            currentVehicle.Metadata.IndicatorLeft  = true;
                                            currentVehicle.Metadata.IndicatorRight = false;
                                            DrawTexture.blinkTimer.Start();
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.LeftOnly;
                                        }
                                    }
                                    else if (Game.IsKeyDown(ReadIniFile.IndicatorRightKey))
                                    {
                                        if (currentVehicle.Metadata.IndicatorRight != null && currentVehicle.Metadata.IndicatorRight)
                                        {
                                            currentVehicle.Metadata.IndicatorRight = false;
                                            currentVehicle.Metadata.IndicatorLeft  = false;
                                            DrawTexture.blinkTimer.Stop();
                                            DrawTexture.blinkStatus = false;
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Off;
                                        }
                                        else
                                        {
                                            currentVehicle.Metadata.IndicatorRight = true;
                                            currentVehicle.Metadata.IndicatorLeft  = false;
                                            DrawTexture.blinkTimer.Start();
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.RightOnly;
                                        }
                                    }
                                    else if (Game.IsKeyDown(ReadIniFile.IndicatorBothKey))
                                    {
                                        if (currentVehicle.Metadata.IndicatorRight != null && currentVehicle.Metadata.IndicatorRight && currentVehicle.Metadata.IndicatorLeft != null && currentVehicle.Metadata.IndicatorLeft)
                                        {
                                            currentVehicle.Metadata.IndicatorRight = false;
                                            currentVehicle.Metadata.IndicatorLeft  = false;
                                            DrawTexture.blinkTimer.Stop();
                                            DrawTexture.blinkStatus = false;
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Off;
                                        }
                                        else
                                        {
                                            currentVehicle.Metadata.IndicatorRight = true;
                                            currentVehicle.Metadata.IndicatorLeft  = true;
                                            DrawTexture.blinkTimer.Start();
                                            currentVehicle.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Both;
                                        }
                                    }
                                }
                                // If the player increases the first time in the vehicle
                                if (playerEnterVehicle == false)
                                {
                                    playerEnterVehicle = true; // Then there is no longer the first time
                                    dbVehicle          = DBVehicleManager.SelectVehicle(player);
                                    // When he got no DBVehicle
                                    if (dbVehicle == null)
                                    {
                                        // We use DBVehicle - We store the vehicle in the database
                                        DBVehicleManager.InsertVehicle(DBVehicleFactory.GetRandomVehicle(player.CurrentVehicle.LicensePlate));
                                        dbVehicle = DBVehicleManager.SelectVehicle(player);
                                    }
                                    // We know this vehicle, this vehicle is in our database
                                    if (dbVehicle != null)
                                    {
                                    }
                                    GameFiber.Yield();
                                }
                                // We start to calculate the tank
                                fuelConsumption.PlayerIsDriving(player, dbVehicle);
                                // Displays only the tank level when the player moves more than 5Kmh
                                if (DrawTexture.getTextureVisible("SpeedoMeter") == false && NativeFunction.CallByName <int>("GET_FOLLOW_PED_CAM_VIEW_MODE") != 4 && !player.IsDead)
                                {
                                    //Enable Speedo if in Vehicle
                                    DrawTexture.toggleSpeedoTexture(true);
                                }
                                else if (NativeFunction.CallByName <int>("GET_FOLLOW_PED_CAM_VIEW_MODE") == 4 && !player.IsDead)
                                {
                                    if (ReadIniFile.viewInCockpit)
                                    {
                                        //Enable Speedo if in Vehicle and Cockpit View if enabled
                                        DrawTexture.toggleSpeedoTexture(true);
                                    }
                                    else
                                    {
                                        //Disable Speedo if in Vehicle and Cockpit View if wanted
                                        DrawTexture.toggleSpeedoTexture(false);
                                    }
                                }
                                else if (DrawTexture.getTextureVisible("SpeedoMeter") == true && player.IsDead)
                                {
                                    //Disable Speedo, because Player Dead
                                    DrawTexture.toggleSpeedoTexture(false);
                                }
                                DrawTexture.changeSpeedoTexture(dbVehicle);
                            }
                            if (!player.IsInAnyVehicle(false) && playerEnterVehicle)
                            {
                                // Then we set this field to False
                                // So the next boarding is his first time
                                playerEnterVehicle = false;
                                DrawTexture.toggleSpeedoTexture(false);

                                // Memory the vehicle tank when the player leaves the vehicle
                                DBVehicleManager.UpdateVehicle(dbVehicle, dbVehicle.tankful);

                                GameFiber.Yield();
                            }

                            if (Game.IsKeyDownRightNow(ReadIniFile.ViewOverlayKey))
                            {
                                DrawTexture.setTextureVisible("Hungery", true);
                                DrawText.DrawMoneyStatus();
                                if (DutyState && ShiftWork.inShiftWork)
                                {
                                    DrawText.DrawShiftWorkStatus();
                                }
                            }
                            else
                            {
                                DrawTexture.setTextureVisible("Hungery", false);
                            }

                            if (DutyState)
                            {
                                if (Game.IsKeyDown(Keys.F7))
                                {
                                    /* if (!DrawTexture.getTextureVisible("policeRadio"))
                                     * {
                                     *   DrawTexture.setTextureVisible("policeRadio", true);
                                     *   DrawTexture.setTextureVisible("policeRadioInner", true);
                                     * }
                                     * else
                                     * {
                                     *   DrawTexture.setTextureVisible("policeRadio", false);
                                     *   DrawTexture.setTextureVisible("policeRadioInner", false);
                                     * }
                                     * Vehicle v = null;
                                     * vehicles.TryTake(out v);
                                     * if(v != null)
                                     * {
                                     *  Game.LocalPlayer.Character.Position = v.RearPosition;
                                     * }*/
                                }

                                var position = player.Position;
                                for (int i = 0; i < CreateStations.stations.Count; i++)
                                {
                                    // If the position of the player to a station is less than
                                    if (position.DistanceTo(CreateStations.stations[i].position) <= 30)
                                    {
                                        CreateStations.stations[i].TryUse(player, dbVehicle, myPlayer);
                                    }
                                    if (position.DistanceTo(CreateStations.stations[i].position) <= 3000f)
                                    {
                                        CreateStations.stations[i].iconBlip.Alpha = 1.0f;
                                    }
                                    else
                                    {
                                        CreateStations.stations[i].iconBlip.Alpha = 0.0f;
                                    }
                                }
                                foreach (Vector3 sPed in ShiftWork.shiftPed)
                                {
                                    if (Vector3.Distance(sPed, position) <= 1 && !ShiftWork.inShiftWork)
                                    {
                                        Game.DisplayHelp("Want to start your shift work? ~g~(" + (new KeysConverter()).ConvertToString(ReadIniFile.ShiftWorkStartKey) + ") Yes~s~ - ~r~(" + (new KeysConverter()).ConvertToString(ReadIniFile.ShiftWorkCancelKey) + ") No");
                                        if (Game.IsKeyDown(ReadIniFile.ShiftWorkStartKey))
                                        {
                                            ShiftWork.arrestedPeds = 0;
                                            ShiftWork.inShiftWork  = true;
                                            ShiftWork.Start();
                                            LiveTicker.AddTicker("I started my shift work");
                                        }
                                        break;
                                    }
                                    else if (Vector3.Distance(sPed, position) <= 1 && ShiftWork.inShiftWork)
                                    {
                                        Game.DisplayHelp("Want to cancel your shift work? ~g~(" + (new KeysConverter()).ConvertToString(ReadIniFile.ShiftWorkStartKey) + ") Yes~s~ - ~r~(" + (new KeysConverter()).ConvertToString(ReadIniFile.ShiftWorkCancelKey) + ") No");
                                        if (Game.IsKeyDown(ReadIniFile.ShiftWorkStartKey))
                                        {
                                            ShiftWork.inShiftWork = false;
                                            LiveTicker.AddTicker("I canceled my shift work");
                                            ShiftWork.timer.Stop();
                                            NotificationManager.addNotification("[~b~Police~s~Life~r~S~s~]: Your shift was ~r~canceled by yourself");
                                        }
                                        break;
                                    }
                                }

                                // if the player is in a shiftwork
                                if (ShiftWork.inShiftWork)
                                {
                                    if (player.IsDead && !playerDeath)
                                    {
                                        playerDeath           = true;
                                        ShiftWork.inShiftWork = false;
                                        LiveTicker.AddTicker("Dies while his shift work");
                                        ShiftWork.timer.Stop();
                                        NotificationManager.addNotification("[~b~Police~s~Life~r~S~s~]: The shift work was ~r~terminated~s~ because ~r~you died.");
                                    }
                                }

                                if (player.IsAlive && playerDeath)
                                {
                                    playerDeath = false;
                                }
                            }
                        }
                    }catch (Exception ex)
                    {
                        Game.LogTrivial(ex.ToString());
                    }
                    GameFiber.Yield();
                }
            });

            GameFiber.StartNew(delegate
            {
                while (true)
                {
                    var player = Game.LocalPlayer.Character;
                    if (player != null)
                    {
                        if (PlayerAuthenticate.isLogged)
                        {
                            LiveTicker.SendTickerToServer();

                            var nearbyPeds = player.GetNearbyPeds(10);
                            if (nearbyPeds.Count() > 0)
                            {
                                int arrested = 0;
                                var position = player.Position;
                                foreach (Ped np in nearbyPeds)
                                {
                                    if (!np.IsValid())
                                    {
                                        continue;
                                    }
                                    if (np.IsDead)
                                    {
                                        continue;
                                    }

                                    if (Vector3.Distance(np.Position, position) <= 20)
                                    {
                                        if (Functions.IsPedArrested(np) && Functions.GetPedArrestingOfficer(np) == player)
                                        {
                                            if (!arrestedPeds.Contains(np))
                                            {
                                                arrestedPeds.Add(np);
                                                if (ShiftWork.inShiftWork)
                                                {
                                                    ShiftWork.arrestedPeds += 1;
                                                }
                                                arrested++;
                                            }
                                        }
                                    }
                                }
                                if (arrested > 0)
                                {
                                    ExperienceManager.addArrestedPeds(arrested, ShiftWork.inShiftWork);
                                }
                            }

                            if (arrestedPeds.Count() > 0)
                            {
                                for (int i = arrestedPeds.Count - 1; i >= 0; i--)
                                {
                                    if (!arrestedPeds[i].IsValid())
                                    {
                                        arrestedPeds.RemoveAt(i);
                                        continue;
                                    }
                                    if (!arrestedPeds[i].IsDead)
                                    {
                                        continue;
                                    }

                                    ExperienceManager.UpdateExp(-20, "Suspect Died in your presence");
                                    arrestedPeds.RemoveAt(i);
                                }
                            }
                        }
                    }
                    NotificationManager.TakeNotification();
                    GameFiber.Sleep(2000);
                }
            });
        }
Exemplo n.º 4
0
        protected override void OnUse(Ped playerped, DBVehicle dbVehicle, MyPlayer myPlayer)
        {
            if (EatPoint.Any(r => r.IsInRange(playerped.Position)))
            {
                NativeFunction.CallByName <uint>("SET_VEHICLE_DOOR_OPEN", vehicle, 5, false, false);
                Ped[] ped       = playerped.GetNearbyPeds(1);
                Ped   burgerPed = ped[0];
                if (myPlayer.playerLife >= 80 && !eaten)
                {
                    if (!answer)
                    {
                        Game.DisplayHelp("Give an answer by pressing Key 1 or 2");
                        Game.DisplaySubtitle("~y~Burgermen~s~: Unfortunately I have no more food, Check back soon ~b~officer", 1000);
                        NotificationManager.addNotification("~b~Your~s~ answers:\n\n1 - No problem, i come again later\n2 - Make your job properly!");
                    }
                    if (answer)
                    {
                        if (goodAnswer)
                        {
                            goodAnswer = false;
                            Game.DisplaySubtitle("~b~You~s~: No problem, they do a good job! i'll be back later", 4000);
                            GameFiber.Sleep(4000);
                            Game.DisplaySubtitle("~y~Burgermen~s~: Thank you for your understanding! You're a good officer", 10000);
                            if (PlayerAuthenticate.isLogged)
                            {
                                ExperienceManager.UpdateExp(5, "Good Behavior");
                            }

                            GameFiber.Sleep(10000);
                        }
                        else if (badAnswer)
                        {
                            badAnswer = false;
                            Game.DisplaySubtitle("~b~You~s~: Make their job properly Sir! I need my food ... !!", 4000);
                            GameFiber.Sleep(4000);
                            Game.DisplaySubtitle("~y~Burgermen~s~: I can not hear it! .. i .. i ... I quit my job!!!", 15000);
                            Vehicle[] _vehicle = burgerPed.GetNearbyVehicles(1);
                            _vehicle[0].LockStatus     = VehicleLockStatus.Unlocked;
                            _vehicle[0].FuelTankHealth = 500.0f;
                            burgerPed.Tasks.EnterVehicle(_vehicle[0], 5000, -1).WaitForCompletion();
                            _vehicle[0].LockStatus = VehicleLockStatus.Locked;
                            NativeFunction.CallByName <uint>("START_VEHICLE_HORN", vehicle, 5000, 0, true);
                            burgerPed.Dismiss();
                            GameFiber.Sleep(10000);
                            GameFiber.Yield();
                        }
                    }

                    if (Game.IsKeyDown(Keys.D1))
                    {
                        answer     = true;
                        goodAnswer = true;
                    }
                    else if (Game.IsKeyDown(Keys.D2))
                    {
                        answer    = true;
                        badAnswer = true;
                    }
                    return;
                }

                if (playerped.IsInAnyVehicle(false))
                {
                    Game.DisplaySubtitle("~y~Burgermen~s~: Officer " + PlayerAuthenticate.onlineUsername + ", please get out of the vehicle I can not understand you", 1000);
                    return;
                }

                if (!menuSelection && !eaten)
                {
                    Vector3 directionFromPlayerToPed = (playerped.Position - burgerPed.Position);
                    directionFromPlayerToPed.Normalize();
                    float heading = MathHelper.ConvertDirectionToHeading(directionFromPlayerToPed);
                    burgerPed.Heading = heading;
                    Game.DisplayHelp("Give an answer by pressing Key 1 or 2");
                    Game.DisplaySubtitle("~y~Burgermen~s~: Nice to see you, what do you want to buy ?", 1000);
                    NotificationManager.addNotification("~b~Choose a key ~s~for your food:\n\n1 - Burger with cheese\n" + "2 - HotDog with a drink");
                    GameFiber.Yield();
                }

                if (Game.IsKeyDown(Keys.D1))
                {
                    menuSelection = true;
                    Game.DisplaySubtitle("~y~Burgermen~s~: Okay, you want a burger. ~g~Good choice i prepare it ", 5000);
                    GameFiber.Sleep(5000);
                    eaten = true;
                    Game.DisplaySubtitle("~y~Burgermen~s~: Thank you for your visit ~b~Officer " + PlayerAuthenticate.onlineUsername + "~s~, Here your food, ~p~Bon Appetit ", 9000);
                    myPlayer.playerLife = 100;
                    HungerManager.UpdatePlayerLife(myPlayer);
                    GameFiber.Yield();
                }
                else if (Game.IsKeyDown(Keys.D2))
                {
                    menuSelection = true;
                    Game.DisplaySubtitle("~y~Burgermen~s~: I cook a hotdog for you. I prepare it one moment please", 5000);
                    GameFiber.Sleep(5000);
                    eaten = true;
                    Game.DisplaySubtitle("~y~Burgermen~s~: Thank you for your visit ~b~Officer " + PlayerAuthenticate.onlineUsername + "~s~, Here your food, ~p~Bon Appetit ", 9000);
                    myPlayer.playerLife = 100;
                    HungerManager.UpdatePlayerLife(myPlayer);
                    GameFiber.Yield();
                }
            }
            else
            {
                eaten = false;
            }
            base.OnUse(playerped, dbVehicle, myPlayer);
        }