示例#1
0
        public static void CleanYourScript()
        {
            for (int i = ShiftWork.shiftWork.Count - 1; i >= 0; i--)
            {
                if (ShiftWork.shiftWork[i].IsValid())
                {
                    ShiftWork.shiftWork[i].Delete();
                }
            }

            for (int i = CreateStations.stations.Count - 1; i >= 0; i--)
            {
                if (CreateStations.stations[i].iconBlip.IsValid())
                {
                    CreateStations.stations[i].iconBlip.Delete();
                }
            }

            if (PlayerAuthenticate.isLogged)
            {
                CalloutManagement.checkIfCalloutEnded();
            }

            if (DutyState)
            {
                LiveTicker.AddTicker("I'm now Off-Duty");
            }

            DrawTexture.textureList.RemoveAll(x => x != null);
        }
示例#2
0
 public static void Functions_OnOnDutyStateChanged(bool onDuty)
 {
     DutyState = onDuty;
     if (onDuty)
     {
         //Add shiftPed Blips
         foreach (Vector3 sPed in ShiftWork.shiftPed)
         {
             Blip iconBlip = new Blip(sPed);
             iconBlip.Alpha  = 1.0f;
             iconBlip.Scale  = 1.5f;
             iconBlip.Sprite = BlipSprite.CashPickupPolice;
             ShiftWork.shiftWork.Add(iconBlip);
         }
         LiveTicker.AddTicker("I'm now On-Duty");
     }
     else if (!onDuty)
     {
         //Remove shiftPed Blips
         foreach (Blip sBlips in ShiftWork.shiftWork)
         {
             if (sBlips.IsValid())
             {
                 sBlips.Delete();
             }
         }
         LiveTicker.AddTicker("I'm now Off-Duty");
     }
 }
示例#3
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);
        }
示例#4
0
        public static void OnTimerEvent(object obj, ElapsedEventArgs e, MyPlayer myPlayer)
        {
            HungerManager.UpdatePlayerLife(myPlayer);

            // Online saves
            if (PlayerAuthenticate.isLogged && PlayerAuthenticate.playOnline == "true")
            {
                if (Game.LocalPlayer.Character.IsInAnyVehicle(false))
                {
                    var position = Game.LocalPlayer.Character.Position;
                    LiveTicker.AddTicker("I'm on Duty, on <font color=\"Orange\">" + World.GetStreetName(position) + "</font>");
                }
                var postData = new List <KeyValuePair <string, string> >();
                postData.Add(new KeyValuePair <string, string>("Methode", "SaveDaten"));
                postData.Add(new KeyValuePair <string, string>("Money", myPlayer.playerMoney.ToString()));
                var responseObject = new WebRequestManager.RequestResponseObject();
                responseObject.handler = new WebRequestManager.getWebRequestResponse(saveDatenResponse);
                WebRequestManager.SendResponse(postData, responseObject);
            }
        }
示例#5
0
        public static void checkisCalloutRunning()
        {
            if (PlayerAuthenticate.isLogged)
            {
                checkIfCalloutEnded();

                foreach (Callout callout in ScriptComponent.GetAllByType <Callout>())
                {
                    if (callout != null && callout.AcceptanceState == CalloutAcceptanceState.Running)
                    {
                        if (currentCallout == null)
                        {
                            currentCallout = callout;
                            calloutTime    = new Stopwatch();
                            calloutTime.Start();
                            LiveTicker.AddTicker("<br />Call: <font color=\"LightCoral\">" + getCalloutMessage(callout.CalloutMessage) + "</font><br />En Route to <font color=\"Orange\">" + Functions.GetZoneAtPosition(callout.CalloutPosition).RealAreaName + "</font>");
                        }
                    }
                }
            }
        }
示例#6
0
        public static void checkIfCalloutEnded()
        {
            if (currentCallout != null && currentCallout.AcceptanceState == CalloutAcceptanceState.Ended)
            {
                lock (CalloutEndObject)
                {
                    Game.LogTrivial(calloutTime.ElapsedMilliseconds.ToString() + " Millisekunden");
                    int money            = 50 + (50 * (int)(calloutTime.ElapsedMilliseconds / 60000));
                    int expMultiplicator = (ShiftWork.inShiftWork ? 10 : 5);
                    int exp = 5 + (expMultiplicator * (int)(calloutTime.ElapsedMilliseconds / 60000));
                    Main.myPlayer.playerMoney += money;
                    var time = getTime(calloutTime.ElapsedMilliseconds);
                    ExperienceManager.UpdateExp(exp, "Good Job, (Call: ~r~" + getCalloutMessage(currentCallout.CalloutMessage) + "~s~) successfully completed", false);
                    LiveTicker.AddTicker("<br />Call: <font color=\"LightCoral\">" + getCalloutMessage(currentCallout.CalloutMessage) + "</font><br />Code 4, no more Units required");
                    NotificationManager.addNotification("Good Job, (Call: ~r~" + getCalloutMessage(currentCallout.CalloutMessage) + "~s~) completed in " + time + " (~g~+" + money + "~s~$ & ~g~+" + exp + " ~s~EXP)");

                    calloutTime.Stop();
                    currentCallout = null;
                    calloutTime    = null;
                }
            }
        }
示例#7
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);
                }
            });
        }