// Use this for initialization
 void Start()
 {
     _score = GameObject.Find("BackgroundScore");
     //_menuSelection = GameObject.FindObjectOfType<MenuSelectionScript>();
     _baseScript = GameObject.FindObjectOfType<BaseScript>();
     _map = GameObject.FindObjectOfType<DontDestroyOnLoadMusicScript>();
     _currentLevel = GameObject.Find("CurrentLevelScore");
     _0Stars = GameObject.Find("BigStarsEmpty").GetComponent<Image>();
     _1Star = GameObject.Find("BigStarsFill1").GetComponent<Image>();
     _2Stars = GameObject.Find("BigStarsFill2").GetComponent<Image>();
     _3Stars = GameObject.Find("BigStarsFill3").GetComponent<Image>();
 }
 // Use this for initialization
 void Start()
 {
     _baseScript = GameObject.FindObjectOfType<BaseScript>();
     _resumeButton = GameObject.Find("ResumeButton");
     _quitButton = GameObject.Find("QuitButton");
     _backGround = GameObject.Find("OverlayPause");
     _pauseButton = GameObject.Find("PauseButton");
     _ScoreScreenScript = GameObject.Find("ScoreScreen").GetComponent<ScoreScreenScript>();
     _radialMenu = GameObject.FindObjectOfType<BuildingSpawnScript>().gameObject;
     _check = GameObject.FindObjectOfType<CheckForMusicScript>();
     _hud = GameObject.Find("HUD");
     _tutorialScript = GameObject.FindObjectOfType<TutorialMainScript>();
     if (_check.Check == true)_map = GameObject.FindObjectOfType<DontDestroyOnLoadMusicScript>();
 }
Beispiel #3
0
        public override BaseScript.EventEat OnSay3(Entity player, BaseScript.ChatType type, string name, ref string message)
        {
            if (_.GetDvarInt("playlist_enabled", 1) == 0)
            {
                return EventEat.EatNone;
            }

            if (message.StartsWith("!nm") || message.StartsWith("!nextmap"))
            {
                SayNextMap();
            }

            return EventEat.EatNone;
        }
 void Start()
 {
     GameObject shadowObject = new GameObject();
     shadowObject.name = "Shadow";
     shadowObject.transform.position = this.transform.position;
     shadowObject.AddComponent<SpriteRenderer>().sprite = _shadowSprite;
     shadowObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     shadowObject.transform.localPosition = new Vector3(shadowObject.transform.localPosition.x+0.09f, shadowObject.transform.localPosition.y - 0.5f, shadowObject.transform.localPosition.z);
     shadowObject.transform.parent = this.transform;
     _baseStats = GameObject.FindObjectOfType<BaseScript>();
     _gruntBase = GameObject.Find("GruntBase").GetComponent<AudioSource>();
     _flyingBase = GameObject.Find("GriffonBase").GetComponent<AudioSource>();
     _paladinBase = GameObject.Find("PaladinBase").GetComponent<AudioSource>();
     _heavyBase = GameObject.Find("HeavyBase").GetComponent<AudioSource>();
     _gruntDeathArrow = GameObject.Find("GruntArrow").GetComponent<AudioSource>();
     _flyingDeathArrow = GameObject.Find("GriffonArrow").GetComponent<AudioSource>();
     _paladinDeathArrow = GameObject.Find("PaladinArrow").GetComponent<AudioSource>();
     _heavyDeathArrow = GameObject.Find("HeavyArrow").GetComponent<AudioSource>();
 }
Beispiel #5
0
        private async Task UpdatePlayerList()
        {
            try {
                var list     = new PlayerList();
                var children = new List <int>();
                foreach (var player in list)
                {
                    children.Add(player.ServerId);
                    if (!this.Any(m => m is MenuItemSubMenu s && s.Child is PlayerMenu p && p.ServerId == player.ServerId))
                    {
                        OnConnect(player.ServerId);
                    }
                }

                RemoveAll(m => m is MenuItemSubMenu s && s.Child is PlayerMenu p && !children.Contains(p.ServerId));
                await BaseScript.Delay(1000);
            }
            catch (Exception ex) {
                Log.Error(ex);
            }
        }
        /// <summary>
        /// Toggles voice range through <see cref="Voice.VoiceRanges"/>
        /// </summary>
        public void ToggleVoiceRange()
        {
            int index = Array.IndexOf(this.Configuration.VoiceRanges, this.VoiceRange);

            if (index < 0)
            {
                this.VoiceRange = this.Configuration.VoiceRanges[1];
            }
            else if (index + 1 >= this.Configuration.VoiceRanges.Length)
            {
                this.VoiceRange = this.Configuration.VoiceRanges[0];
            }
            else
            {
                this.VoiceRange = this.Configuration.VoiceRanges[index + 1];
            }

            BaseScript.TriggerServerEvent(Event.SaltyChat_SetVoiceRange, this.VoiceRange);

            CitizenFX.Core.UI.Screen.ShowNotification($"New voice range is {this.VoiceRange} metres.");
        }
Beispiel #7
0
        public InverseTag() : base(Shared.Gamemode.InverseTag)
        {
            Debug.WriteLine("START INVERSE TAG");

            base.AddEventHandler("sthv:no_tagback_time_ms", new Action <int>(async(no_tagback_time_ms) => {
                isTaggingAllowed = false;
                await BaseScript.Delay(no_tagback_time_ms);
                isTaggingAllowed = true;
            }));
            base.AddEventHandler("sth:new_runner", new Action <int>((i) => {
                Runner = new Player(API.GetPlayerFromServerId(i));
                if (Runner == null)
                {
                    throw new Exception("Runner is null in sth:new_runner");
                }
            }));

            base.AddTick(OnTick);             //detect collisions and draw cone on runner
            base.AddTick(RunnerCarCheck);     //checks that runner is in a car
            base.AddTick(LogInfo);
        }
Beispiel #8
0
        public async Task RandomBehaviour()
        {
            await BaseScript.Delay(this.random.Next(4000, 6500));

            int dice = this.random.Next(1, 100 + 1);

            if (dice <= 25 && suspectActive)
            {
                ClearPedTasks(this.DrunkSuspect.Handle);
                ClearPedTasksImmediately(this.DrunkSuspect.Handle);

                this.DrunkSuspect.Task.FightAgainst(GetClosestPed(DrunkSuspect));
            }
            else if (dice > 25 && dice <= 40 && suspectActive)
            {
                ClearPedTasks(this.DrunkSuspect.Handle);
                ClearPedTasksImmediately(this.DrunkSuspect.Handle);

                this.DrunkSuspect.Task.ReactAndFlee(GetClosestPed(DrunkSuspect));
            }
        }
        private void HandleAI911([FromSource] Player source, string data)
        {
            try
            {
                Log.Verbose($"PoliceJob HandleAI911");
                var deserialized = Helpers.MsgPack.Deserialize <CadAlertAIModel>(data);

                foreach (var player in SessionManager.PlayerList)
                {
                    Log.Verbose($"Checking {player.Value.Character.CharID} duty = {player.Value.Character.Duty}");
                    if (player.Value.Character.Duty.HasFlag(deserialized.SendAlertToGroup))
                    {
                        BaseScript.TriggerClientEvent(player.Value.Player, "Communication.IncomingAIAlert.Police", data);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"PoliceJob HandleAI911 Error: {ex.Message}");
            }
        }
Beispiel #10
0
        /// <summary>
        /// Gets the current menu selection.
        /// </summary>
        /// <returns></returns>
        public async Task <int> GetSelection()
        {
            BeginScaleformMovieMethodN("GET_COLUMN_SELECTION");
            PushScaleformMovieMethodParameterInt(0);
            var ret = EndScaleformMovieMethodReturn();

            int maxTimer = GetGameTimer();

            while (!GetScaleformMovieFunctionReturnBool(ret))
            {
                if (GetGameTimer() - maxTimer > 100)
                {
                    break;
                }
                await BaseScript.Delay(0);
            }

            var retInt = GetScaleformMovieFunctionReturnInt(ret);

            return(retInt);
        }
        public ALPR_ExpiredLicense()
        {
            //  Picks a random location on the map within a radius given below.
            float offsetX = rnd.Next(100, 450);
            float offsetY = rnd.Next(100, 450);

            InitInfo(World.GetNextPositionOnStreet(new Vector3(offsetX, offsetY, 0)));

            //  Information that FivePD uses for both the in-game notification and police computer.
            ShortName          = "ALPR: Driving License Expired";
            CalloutDescription = "An ALPR camera has picked up a flag on a vehicle, the registered owner is driving with an expired driving license.";
            ResponseCode       = 2;
            StartDistance      = 100f;

            //  FivePDAudio compatibility - https://gtapolicemods.com/index.php?/files/file/895-fivepd-audio-dispatch-audio/
            BaseScript.TriggerEvent("FivePDAudio::RegisterCallout", new object[]
            {
                this.ShortName,
                @"CRIMES/CRIME_TRAFFIC_ALERT_01.ogg"
            });
        }
Beispiel #12
0
        /// <summary>
        /// 时间间隔较为宽松的检测的异步方法
        /// </summary>
        /// <returns></returns>
        public async Task TolerantTick()
        {
            var missionPeds = MissionPedController.GetAllMissionPeds();

            // 已经加入
            if (IsJoined)
            {
                RetainJoinState();
                CheckFinishState();
            }
            else if (IsActivated)
            {
                RetainActivateState();
            }
            else
            {
                RevertBaseState();
            }

            await BaseScript.Delay(1000);
        }
Beispiel #13
0
        public async void Spawn()           //Function used for spawning a player in the map during a match
        {
            API.DoScreenFadeOut(500);       //Makes the screen fade out for 0.5 seconds

            while (API.IsScreenFadingOut()) //Loops until the screen is finished fading out
            {
                await BaseScript.Delay(0);  //Waits 0 miliseconds
            }

            Vector3 spawnpoint = spawnpoints[API.GetRandomIntInRange(0, spawnpoints.Count)];                 //Select a random spawnpoint

            FreezePlayer(true);                                                                              //Freeze the player

            API.RequestCollisionAtCoord(spawnpoint.X, spawnpoint.Y, spawnpoint.Z);                           //Load the map at the position of the spawnpoint

            int ped = Game.PlayerPed.Handle;                                                                 //The player character id

            API.SetEntityCoordsNoOffset(ped, spawnpoint.X, spawnpoint.Y, spawnpoint.Z, false, false, false); //Teleport the player to the spawnpoint
            API.NetworkResurrectLocalPlayer(spawnpoint.X, spawnpoint.Y, spawnpoint.Z, 0f, true, true);       //Revive the player at the spawnpoint

            API.ClearPedTasksImmediately(ped);                                                               //cancel any tasks the character is currently doing
            API.RemoveAllPedWeapons(ped, true);                                                              //Remove all the players weapons
            API.ClearPedBloodDamage(ped);                                                                    //Remove any blood on the player

            while (!API.HasCollisionLoadedAroundEntity(ped))                                                 //Loop until the map has loaded around the player
            {
                await BaseScript.Delay(0);                                                                   //Waits 0 miliseconds
            }

            API.ShutdownLoadingScreen();   //Shutdown the loading screen if active

            API.DoScreenFadeIn(500);       //Makes the screen fade in for 0.5 seconds

            while (API.IsScreenFadingIn()) //Loops until the screen is finished fading in
            {
                await BaseScript.Delay(0); //Waits 0 miliseconds
            }

            FreezePlayer(false); //Unfreezes the player
        }
Beispiel #14
0
        public Tow()
        {
            returnVehicleItem = new MenuItemStandard
            {
                Title      = "Return Job Vehicle",
                OnActivate = async item =>
                {
                    if (Game.PlayerPed.Position.DistanceToSquared(towDropoffPoint) < 200.0f && currentTowTruck != null && (currentTowTruck.Position.DistanceToSquared(towDropoffPoint) < 200.0f || currentTowTruck.IsDead))
                    {
                        if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle == currentTowTruck)
                        {
                            Game.PlayerPed.Task.LeaveVehicle(currentTowTruck, true);
                        }

                        Log.ToChat("[Job]", "Returning job vehicle", ConstantColours.Job);

                        await BaseScript.Delay(3000);

                        EndJob();
                        Client.Get <InteractionUI>().RemoveInteractionMenuItem(returnVehicleItem);
                    }
                }
            };
            Client.RegisterTickHandler(VehicleGetTick);
            Client.RegisterTickHandler(JobTick);
            Client.RegisterEventHandler("Player.CheckForInteraction", new Action(OnInteraction));
            Client.RegisterEventHandler("Job.GetTowRequest", new Action(OnTowRequest));
            CommandRegister.RegisterCommand("tow", handleTowCommand);
            CommandRegister.RegisterCommand("canceltowjob", handleTowJobCancel);

            BlipHandler.AddBlip("Tow yard", towMarkerLocation, new BlipOptions
            {
                Sprite = BlipSprite.TowTruck
            });

            MarkerHandler.AddMarker(towMarkerLocation, new MarkerOptions
            {
                ScaleFloat = 4.0f
            });
        }
Beispiel #15
0
        public async Task StartInteraction(Ped closest, Ped staff, Ped suspect)
        {
            this.medic.Task.ChatTo(closest);
            ShowDialog("[Guard] Thanks for coming, the patient is just over there. They managed to break out the facility!", 3000, 20f);
            await BaseScript.Delay(3500);

            this.patient.Task.ChatTo(closest);
            ShowDialog("[Patient] *Sobbing*", 3000, 20f);
            await BaseScript.Delay(4000);

            ShowDialog("[You] Sir? Do you want to come out for me?", 3000, 20f);
            await BaseScript.Delay(3000);

            int dice = random.Next(0, 100);

            if (dice <= 20)
            {
                ShowDialog("[Patient] YOU CAN'T CONTAIN ME!", 3000, 30f);
                patient.Task.FightAgainst(closest);
            }
            else if (dice > 20 && dice <= 50)
            {
                ShowDialog("[Patient] FIRE MAKES ALL CLEAN AGAIN", 3000, 30f);
                patient.Euphoria.Teeter.Start();
                await BaseScript.Delay(500);

                dice = random.Next(3000, 15000);
                _    = this.outcomeController(dice);
                ShowDialog("[Guard] F**k! He's covered in fuel!.", 3000, 20f);
                ShowNetworkedNotification("Restrain the suspect before they set light to themselves!", "CHAR_HUMANDEFAULT", "CHAR_HUMANDEFAULT", "Help", " ", 20f);
            }
            else
            {
                ShowDialog("[Patient] GOTTA GO FAST!", 3000, 20f);
                patient.Task.FleeFrom(closest);
                await BaseScript.Delay(5000);

                patient.Task.Cower(30000);
            }
        }
Beispiel #16
0
        private void Update(Client client)
        {
            foreach (var trackedVehicle in this.Tracked.ToList())
            {
                var     vehicleHandle = NetToVeh(trackedVehicle.Item2);
                Vehicle citVeh        = new Vehicle(vehicleHandle);
                Player  player        = new Player(GetNearestPlayerToEntity(citVeh.Handle));

                if (player == client.LocalPlayer || !NetworkIsPlayerConnected(player.Handle))
                {
                    if (!(Vector3.Distance(client.LocalPlayer.Character.Position, citVeh.Position) >
                          VehicleLoadDistance))
                    {
                        continue;
                    }

                    citVeh.Delete();
                    this.Tracked.Remove(trackedVehicle);
                    BaseScript.TriggerServerEvent("igi:car:unclaim", trackedVehicle.Item2);
                }
                else
                {
                    var netId = NetworkGetNetworkIdFromEntity(citVeh.Handle);
                    //Debug.WriteLine($"Vehicle: {vehicleHandle} NetId: {netId} - {citVeh.Position}");

                    Car car = citVeh;
                    car.NetId = netId;

                    // Transfer the vehicle to the closest client
                    //Client.Log($"Removing Vehicle from tracked: {car.Handle}");
                    //this.Tracked.Remove(car.Handle ?? 0);

                    Client.Log($"Transfering vehicle to player: {player.ServerId}  -  {car.Handle}");
                    BaseScript.TriggerServerEvent(
                        "igi:car:transfer",
                        JsonConvert.SerializeObject(car),
                        player.ServerId);
                }
            }
        }
        private async Task OnControlTick()
        {
            Game.DisableControlThisFrame(0, Control.EnterCheatCode);
            Game.DisableControlThisFrame(0, Control.PushToTalk);
            Game.DisableControlThisFrame(0, Control.VehiclePushbikeSprint);

            if (Game.Player.IsAlive)
            {
                if (Game.IsControlJustPressed(0, Control.EnterCheatCode))
                {
                    this.ToggleVoiceRange();
                }

                if (VoiceManager.PrimaryRadioChannel != null)
                {
                    if (Game.IsControlJustPressed(0, Control.PushToTalk))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, VoiceManager.PrimaryRadioChannel, true);
                    }
                    else if (Game.IsControlJustReleased(0, Control.PushToTalk))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, VoiceManager.PrimaryRadioChannel, false);
                    }
                }

                if (VoiceManager.SecondaryRadioChannel != null)
                {
                    if (Game.IsControlJustPressed(0, Control.VehiclePushbikeSprint))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, VoiceManager.SecondaryRadioChannel, true);
                    }
                    else if (Game.IsControlJustReleased(0, Control.VehiclePushbikeSprint))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, VoiceManager.SecondaryRadioChannel, false);
                    }
                }
            }

            await Task.FromResult(0);
        }
        private async Task OnControlTick()
        {
            Game.DisableControlThisFrame(0, Control.OpenJournal);
            Game.DisableControlThisFrame(0, Control.PushToTalk);
            Game.DisableControlThisFrame(0, Control.OpenSatchelMenu);

            if (Game.Player.IsAlive)
            {
                if (Game.IsControlJustPressed(0, Control.OpenJournal))
                {
                    this.ToggleVoiceRange();
                }

                if (this.PrimaryRadioChannel != null)
                {
                    if (Game.IsControlJustPressed(0, Control.PushToTalk))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, this.PrimaryRadioChannel, true);
                    }
                    else if (Game.IsControlJustReleased(0, Control.PushToTalk))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, this.PrimaryRadioChannel, false);
                    }
                }

                if (this.SecondaryRadioChannel != null)
                {
                    if (Game.IsControlJustPressed(0, Control.OpenSatchelMenu))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, this.SecondaryRadioChannel, true);
                    }
                    else if (Game.IsControlJustReleased(0, Control.OpenSatchelMenu))
                    {
                        BaseScript.TriggerServerEvent(Event.SaltyChat_IsSending, this.SecondaryRadioChannel, false);
                    }
                }
            }

            await Task.FromResult(0);
        }
Beispiel #19
0
        public Taxi()
        {
            returnVehicleItem = new MenuItemStandard
            {
                Title      = "Return Job Vehicle",
                OnActivate = async item =>
                {
                    if (Game.PlayerPed.Position.DistanceToSquared(vehicleSpawnLocation) < 200.0f && JobVehicle != null && (JobVehicle.Position.DistanceToSquared(vehicleSpawnLocation) < 200.0f || JobVehicle.IsDead))
                    {
                        if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle == JobVehicle)
                        {
                            Game.PlayerPed.Task.LeaveVehicle(JobVehicle, true);
                        }

                        Log.ToChat("[Job]", "Returning job vehicle", ConstantColours.Job);

                        await BaseScript.Delay(3000);

                        EndJob();
                        Client.Get <InteractionUI>().RemoveInteractionMenuItem(returnVehicleItem);
                    }
                }
            };
            CommandRegister.RegisterCommand("canceltaxijob", new Action <Command>(cmd =>
            {
                if (inTaxiJob)
                {
                    Log.ToChat("[Job]", "You cancelled your current taxi job", ConstantColours.Job);
                    endTaxiJob();
                }
                else
                {
                    Log.ToChat("[Job]", "You must have a fare to cancel your job", ConstantColours.Job);
                }
            }));
            Client.RegisterEventHandler("Player.CheckForInteraction", new Action(OnInteraction));
            LoadBlips();
            //Client.Instance.RegisterTickHandler(JobTick);
            //Client.Instance.RegisterTickHandler(taxiSearchTick);
        }
        private async void OnDoDrag(int target)
        {
            try
            {
                //var targetSession = Client.Instance.Instances.Session.GetPlayer(target);

                var targetPlayer = Client.PlayerList.FirstOrDefault(o => o.ServerId == target);

                Log.ToServer($"Our drag owner is {targetPlayer} target player object == null {targetPlayer == null}");

                if (targetPlayer == null)
                {
                    return;
                }

                var ticks = 0;
                while (!Cache.PlayerPed.IsAttachedTo(targetPlayer.Character) && ticks < 10)
                {
                    //Log.ToServer("Trying to attach");
                    if (Cache.PlayerPed.IsAttached())
                    {
                        Cache.PlayerPed.Detach();
                    }
                    AttachEntityToEntity(Game.PlayerPed.Handle, targetPlayer.Character.Handle, 1, 0.0f, 1.0f, 0.0f, 0.0f, -90.0f, 0.0f, false, false, false, true, 1, true);
                    ticks++;
                    await BaseScript.Delay(250);
                }

                Client.RegisterTickHandler(DisableActions);
                Client.RegisterTickHandler(CheckPlayerExists);
                Client.RegisterTickHandler(CheckAttachTick);

                Cache.PlayerPed.IsCollisionEnabled = false;
            }
            catch (Exception e)
            {
                Log.Error(e, true);
            }
        }
 static private void HandleEmote(Command command)
 {
     try
     {
         if (command.Args.Count == 0)
         {
             BaseScript.TriggerEvent("Chat.Message", "", "#AAAAAA", $"Valid emotes: {String.Join(", ", scenarios.Select(e => e.Key.ToTitleCase()))}");
         }
         else if (command.Args.Count == 1 && scenarios.ContainsKey(command.Args.Get(0).ToLower()))
         {
             PlayEmote(command.Args.Get(0).ToLower());
         }
         else
         {
             BaseScript.TriggerEvent("Chat.Message", "", "#AAAAAA", $"Invalid emote specified");
         }
     }
     catch (Exception ex)
     {
         Log.Error($"HandleEmote error: {ex.Message}");
     }
 }
Beispiel #22
0
        public static async Task <bool> IsInFrontOfWater(this Ped PlayerPed)
        {
            Vector3 ProbeLocation = PlayerPed.GetOffsetPosition(new Vector3(0, 8, 0));

            OutputArgument z           = new OutputArgument();
            bool           groundFound = Function.Call <bool>(Hash.GET_GROUND_Z_FOR_3D_COORD, ProbeLocation.X, ProbeLocation.Y, ProbeLocation.Z, z, false);
            float          groundZ     = z.GetResult <float>();

            ProbeLocation.Z = (float)groundZ - 0.1f;
            Ped ProbePed = await CitizenFX.Core.World.CreatePed(new Model(PedHash.Rat), ProbeLocation);

            ProbePed.PositionNoOffset = ProbeLocation;
            ProbePed.Opacity          = 0;
            await BaseScript.Delay(50);

            bool isProbeInWater = Function.Call <bool>(Hash.IS_ENTITY_IN_WATER, ProbePed.Handle);

            ProbePed.Delete();
            bool isPlayerInWater = Function.Call <bool>(Hash.IS_ENTITY_IN_WATER, PlayerPed.Handle);

            return(isPlayerInWater || isProbeInWater);
        }
Beispiel #23
0
        public static async Task <IEnumerable <T> > GetAsync(object where)
        {
            var dataNamespace = DataManager.Namespace;
            var eventSink     = GetEventSink();
            var queryId       = eventSink.GetQueryId();

            BaseScript.TriggerServerEvent(string.Format("{0}:get{1}", dataNamespace, typeof(T).Name), new
            {
                version = 1,
                id      = queryId,
                query   = where
            });

            var result = await eventSink.PendGet(queryId);

            if (result.version != 1)
            {
                throw new Exception("Result version did not match the expected value.");
            }

            return(Deserialize(result.data));
        }
        private async Task FirstTick()
        {
            string resourceName = API.GetCurrentResourceName();

            this.ServerUniqueIdentifier = API.GetResourceMetadata(resourceName, "ServerUniqueIdentifier", 0);
            this.SoundPack             = API.GetResourceMetadata(resourceName, "SoundPack", 0);
            this.IngameChannel         = UInt64.Parse(API.GetResourceMetadata(resourceName, "IngameChannelId", 0));
            this.IngameChannelPassword = API.GetResourceMetadata(resourceName, "IngameChannelPassword", 0);

            string swissChannelIds = API.GetResourceMetadata(resourceName, "SwissChannelIds", 0);

            if (!String.IsNullOrEmpty(swissChannelIds))
            {
                this.SwissChannelIds = swissChannelIds.Split(',').Select(s => UInt64.Parse(s.Trim())).ToArray();
            }

            BaseScript.TriggerServerEvent(Event.SaltyChat_Initialize);

            this.Tick -= this.FirstTick;

            await Task.FromResult(0);
        }
        private void StartFishing(Session.Session playerSession)
        {
            Log.Verbose($"Starting fishing for {playerSession.PlayerName}");
            playerSession.TriggerEvent("Fishing.StartFishing");

            Task.Factory.StartNew(async() =>
            {
                var currentSecond = timePerFish;
                var currentTick   = 0;
                while (playerSession.GetLocalData("Character.IsFishing", false))
                {
                    if (!InFishingZone(playerSession) || playerSession.IsInVehicle())
                    {
                        playerSession.SetLocalData("Character.IsFishing", false);
                        Log.ToClient("[Fishing]", "You moved to far away from the fishing area", ConstantColours.Job, playerSession.Source);
                        Log.Debug($"{playerSession.PlayerName} no longer in a fishing zone. Terminating thread");
                        return;
                    }

                    if (currentTick >= 1000)
                    {
                        currentTick    = 0;
                        currentSecond -= 1;

                        if (playerSession.GetLocalData("Character.IsFishing", false) && currentSecond <= 0) // Make sure no change
                        {
                            AttemptAddFish(playerSession);
                            playerSession.SetLocalData("Character.IsFishing", false);

                            /*await BaseScript.Delay(2000);
                             * currentSecond = timePerFish;*/
                        }
                    }

                    await BaseScript.Delay(100);
                    currentTick += 100;
                }
            });
        }
Beispiel #26
0
 static private async void StayLoop()
 {
     if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle.GetPedOnSeat(VehicleSeat.Passenger) == Game.PlayerPed)
     {
         while (stayToggle)
         {
             if (ControlHelper.IsControlJustPressed(Control.Enter))
             {
                 stayToggle = false;
             }
             if ((Game.PlayerPed.CurrentVehicle.GetPedOnSeat(VehicleSeat.Passenger) == Game.PlayerPed) || Function.Call <bool>(Hash.CAN_SHUFFLE_SEAT, Game.PlayerPed.CurrentVehicle.Handle, true))
             {
                 Game.PlayerPed.Task.ClearAll();
             }
             await BaseScript.Delay(0);
         }
     }
     else
     {
         stayToggle = false;
     }
 }
Beispiel #27
0
        public async Task RandomBehaviour()
        {
            await BaseScript.Delay(random.Next(4000, 6500));

            int x = random.Next(1, 100 + 1);

            if (x <= 25)
            {
                ClearPedTasks(this.Attacker.Handle);
                ClearPedTasksImmediately(this.Attacker.Handle);

                this.Attacker.Task.FightAgainst(GetClosestPed(Attacker));
            }
            else if (x > 25 && x <= 40)
            {
                ClearPedTasks(this.Attacker.Handle);
                ClearPedTasksImmediately(this.Attacker.Handle);

                this.Attacker.Task.ReactAndFlee(GetClosestPed(Attacker));
            }
            Debug.WriteLine("In tick event");
        }
 /// <summary>
 /// This is just an extra measure to be safe in the sense that we don't have orphaned blips/emergency vehicles around the map
 /// </summary>
 private static async void RegularBlipCleanup()
 {
     while (true)
     {
         duty.ToList().ForEach(d =>
         {
             if (!otherPlayerList.ContainsCharID(d.Key))
             {
                 if (d.Value.Item3 != null && d.Value.Item3.Exists())
                 {
                     d.Value.Item3.Delete();
                 }
                 if (d.Value.Item4 != null && d.Value.Item4.Exists())
                 {
                     d.Value.Item4.Delete();
                 }
                 duty.Remove(d.Key);
             }
         });
         await BaseScript.Delay(cleanupInterval);
     }
 }
Beispiel #29
0
        public async Task <IVideoPlayer> CreateVideoPlayerAsync(Shared.Models.Screen screen)
        {
            var browser = new DuiBrowser(this.duiUrl, this.duiWidth, this.duiHeight);

            while (!API.IsDuiAvailable(browser.NativeValue))
            {
                await BaseScript.Delay(5);
            }

            browser.CreateRuntimeTexture();
            await BaseScript.Delay(1000);

            Debug.WriteLine("sending init..");
            browser.Init(screen.Name, this.posterUrl);

            if (!screen.Is3DRendered)
            {
                return(CreateVideoPlayer2D(browser, screen));
            }

            return(await this.CreateVideoPlayer3D(browser, screen));
        }
        private async Task OnTick()
        {
            if (Client.Get <JobHandler>() != null && LocalSession != null && Client.Get <JobHandler>().OnDutyAsJob(JobType.Police | JobType.EMS, LocalSession))
            {
                return;
            }

            WeaponHash currentWeapon = Game.PlayerPed.Weapons.Current.Hash;

            if (prevWeapon != currentWeapon)
            {
                if (prevWeapon != WeaponHash.Unarmed && Game.PlayerPed.Weapons.HasWeapon(prevWeapon))
                {
                    var ammoAmount = Game.PlayerPed.Weapons[prevWeapon].Ammo;
                    removeAmmoFromWeapon(getWeaponType(prevWeapon), ammoAmount);
                }

                prevWeapon = currentWeapon;

                await BaseScript.Delay(250);
            }
        }
Beispiel #31
0
        /// <summary>
        /// Draws the player names and chips.
        /// </summary>
        public static async void DrawPlayerNamesAndChips()
        {
            while (!Blackjack.HasPlayerLeftTable && Blackjack.CurrentGame.IsActive)
            {
                if (Blackjack.ShowPlayersHandHud && Game.IsControlPressed(0, Control.Sprint))
                {
                    var players = GetCleanedPlayerList();

                    float yStart = 0.0625f;
                    foreach (var player in players.OrderBy(p => p.Position))
                    {
                        UI.DrawText($"{player.Name} \nSeat {player.Position} ${player.Chips}",
                                    new Vector2(0.85375f + 0.03f, yStart - 0.03f), Color.FromArgb(255, 255, 255, 255),
                                    0.5f,                     //only for other players and dealer
                                    Font.ChaletComprimeCologne);
                        yStart = yStart + 0.1f;
                    }
                }

                await BaseScript.Delay(0);
            }
        }
Beispiel #32
0
        /// <summary>
        /// Draws the player current hand.
        /// </summary>
        /// <param name="playerPosition">The player position.</param>
        /// <param name="xStartPos">The x start position.</param>
        /// <param name="yPos">The y position.</param>
        /// <param name="width">The width.</param>
        public static async void DrawPlayerCurrentHandForDealer(int playerPosition, float xStartPos, float yPos, float width)
        {
            var player = Blackjack.CurrentGame.Players.FirstOrDefault(p => p.Position == playerPosition);

            while (!Blackjack.HasPlayerLeftTable && player?.GetActiveHand != null && player.GetActiveHand.IsActive)
            {
                player = Blackjack.CurrentGame.Players.FirstOrDefault(p => p.Position == playerPosition);

                player?.GetActiveHand?.DrawActiveHand(xStartPos, yPos, width);

                if (Blackjack.IsClientDealer())
                {
                    UI.DrawText($"{player?.Position} - {player?.Name} ${player?.GetActiveHand?.Bet}",
                                new Vector2(xStartPos + -0.06f, yPos + -.125f),
                                Color.FromArgb(255, 255, 255, 255), 0.5f,
                                Font.ChaletComprimeCologne);                  //only for dealer
                }
                await BaseScript.Delay(0);
            }

            Log.Info($"DrawPlayerCurrentHandForDealer: {player?.GetActiveHand != null} && {!Blackjack.HasPlayerLeftTable} && {player?.GetActiveHand?.IsActive}");
        }
Beispiel #33
0
		static private async void UpdateTasti()
		{
			if (!Scaleform)
			{
				Buttons = new Scaleform("instructional_buttons");
				while (!HasScaleformMovieLoaded(Buttons.Handle)) await BaseScript.Delay(0);

				Buttons.CallFunction("CLEAR_ALL");
				Buttons.CallFunction("TOGGLE_MOUSE_BUTTONS", false);


				Buttons.CallFunction("CLEAR_ALL");

				Buttons.CallFunction("SET_DATA_SLOT", 0, GetControlInstructionalButton(2, 236, 1), "Change Visual");
				Buttons.CallFunction("SET_DATA_SLOT", 1, GetControlInstructionalButton(2, 204, 1), "Get off the Wheel");

				Buttons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
				Scaleform = true;
			}
			if (Scaleform)
				Buttons.Render2D();
		}
Beispiel #34
0
    public void OnClick()
    {
        //Debug.Log("click" + GetComponent<LoadCache>().getCurPath());
        string name      = BaseScript.getLoadObject("Canvas/username").GetComponent <InputField>().text;
        string passw     = BaseScript.getLoadObject("Canvas/passw").GetComponent <InputField>().text;
        string passwsure = BaseScript.getLoadObject("Canvas/passwsure").GetComponent <InputField>().text;

        if (passw == passwsure)
        {
            Debug.Log("on passw success");
        }
        if (i == 0)
        {
            BaseTest.send(new BaseData(null).createObject().putObject("mK", new BaseData("login")).putObject("mV", new BaseData(null).createObject().putObject("username", name).putObject("userpassword", passw)));
        }
        else
        {
            BaseTest.send(new BaseData(null).createObject().putObject("mE", new BaseData("da")).putObject("mV", new BaseData(null).createObject().putObject("username", name).putObject("userpassword", passw)));
        }
        i++;
        //BaseTest.send(new BaseData(null).createObject().putObject("regist", new BaseData(null).createObject().putObject("username", name).putObject("userpassword", passw)));
    }
    // Use this for initialization
    //Load all the Variables and Prepare the Radial Menu
    void Start()
    {
        //Get all the prefabs of the Idle towers level 1
        _towerArrowIdle = (GameObject)Resources.Load("Towers/TreeIdleLevel1");
        _towerCannonIdle = (GameObject)Resources.Load("Towers/TrollIdleLevel1");
        _towerSpiderIdle = (GameObject)Resources.Load("Towers/SpiderIdleLevel1");

        _check = GameObject.FindObjectOfType<CheckForMusicScript>();
        _tileMap = FindObjectOfType<TileMapScript>();
        _baseScript = GameObject.FindObjectOfType<BaseScript>();
        _calculateEverything();
        //Check if there is audio source and get all the sources
        if (_check.Check == true)
        {

            _troll1 = GameObject.Find("Troll1").GetComponent<AudioSource>();
            _troll2 = GameObject.Find("Troll2").GetComponent<AudioSource>();
            _spider1 = GameObject.Find("Spider1").GetComponent<AudioSource>();
            _spider2 = GameObject.Find("Spider2").GetComponent<AudioSource>();
            _tree1 = GameObject.Find("Tree1").GetComponent<AudioSource>();
            _tree2 = GameObject.Find("Tree2").GetComponent<AudioSource>();
        }
    }
Beispiel #36
0
        public override BaseScript.EventEat OnSay3(Entity player, BaseScript.ChatType type, string name, ref string message)
        {
            string[] strArray1 = message.Split(' ');
            if (message.StartsWith("!") && Permisos.CanUseCommand(player,strArray1[0]))
            {
                /*
                if (strArray1[0] == "!devlogs")
                {
                    using (var client = new WebClient())
                    {
                        var responseString = client.DownloadString("http://www.nemu.tk/nemu/warreceiver.php?port=" + _sPort + "&warid=" + _warid);
                        Log.Write(LogLevel.All, responseString);
                    }
                    Log.Write(LogLevel.All, _sPort);
                    Log.Write(LogLevel.All, _warid);
                    Log.Write(LogLevel.All, ToHex(player.GUID));
                }
                 */
                if (strArray1[0] == "!war")
                {
                    if (strArray1[1] == "off")
                    {
                        _warid = "6fbfd5e68d3306e51350bea0232f8fa5";
                        TellClient(player, "^3War: ^1Off");
                        Log.Info(BotName + "Puerto: " + _sPort);
                        Log.Info(BotName + "WarID: " + _warid);
                    }
                    else
                    {
                        _warid = strArray1[1];
                        TellClient(player, "^3WarID: ^2" + _warid);
                        Log.Info(BotName + "Puerto: " + _sPort);
                        Log.Info(BotName + "WarID: " + _warid);
                    }

                    using (var client = new WebClient())
                    {
                        var values = new NameValueCollection();
                        values["port"] = _sPort;
                        values["warid"] = _warid;

                        var response = client.UploadValues("http://www.nemu.tk/nemu/warreceiver.php", values);

                        var responseString = Encoding.Default.GetString(response);
                    }
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!kick"))
                {

                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!ban"))
                {
                    ban(message, player);
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!tmpban"))
                {
                    tmpban(message, player);
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!slot"))
                {
                    if (strArray1.Length > 1)
                    {
                        getslot(message, player);
                        return BaseScript.EventEat.EatGame;
                    }
                    slot(player);
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0] == "!mr")
                {
                    Utilities.ExecuteCommand("map_restart");
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0] == "!fr")
                {
                    Utilities.ExecuteCommand("fast_restart");
                    ServerSay(" ^2Fast Restarting the map...");
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!unban"))
                {
                    if (strArray1.Length <= 1)
                    {
                        TellClient(player, "^1Enter a playername");
                        return BaseScript.EventEat.EatGame;
                    }
                    Entity byName = FindByName(strArray1[1]);
                    if (byName == null)
                    {
                        TellClient(player, "^1That user wasn't found or multiple were found.");
                        return BaseScript.EventEat.EatGame;
                    }
                    Utilities.ExecuteCommand("unban " + byName.Name);
                    ServerSay(" ^1" + byName.Name + " ^3has been unbanned.");
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!guid"))
                {
                    TellClient(player, "^2Your GUID is: ^5" + player.GUID.ToString());
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!pm"))
                {
                    PM(player, message);
                    return BaseScript.EventEat.EatGame;
                }
                if (strArray1[0].Equals("!admins"))
                {
                    if (admins == "")
                    {
                        TellClient(player, "^1Online admins not in server");
                        return BaseScript.EventEat.EatGame;
                    }
                    TellClient(player, "^3Online ^2Admins ^7: " + admins);
                    return BaseScript.EventEat.EatGame;
                }
            }
            return BaseScript.EventEat.EatNone;
        }
 void Start()
 {
     parent = transform.parent.gameObject.GetComponent<BaseScript>();
     system = GameObject.FindGameObjectWithTag("System");
     rpcScript = system.GetComponent<RPCScript>();
 }
Beispiel #38
0
 public static void AddScript(BaseScript script)
 {
     _scripts.Add(script);
 }
 public void Restore(BaseScript playerBase)
 {
     playerBase.health = health;
     playerBase.player = player;
     playerBase.myPlayerType = myPlayerType;
 }
 public BaseSaverScript(BaseScript playerBase)
 {
     health = playerBase.health;
     player = playerBase.player;
     myPlayerType = playerBase.myPlayerType;
 }
Beispiel #41
0
 void Instance_ScriptCrashed(BaseScript script, Exception exception)
 {
     Game.DisplayTextBox("Script " + script.GetType().Name + " crashed. Check the log for details.");
 }
 void Start()
 {
     _upgradePanel = GameObject.Find("UpgradePanel"); //gets the panel in the game scene
     _upgradeOne = FindObjectOfType<UpgradeOneButtonScript>(); //the first upgrade button in the panel
     _upgradeTwo = FindObjectOfType<UpgradeTwoButtonScript>(); //the second upgrade button in the panel
     _baseScript = FindObjectOfType<BaseScript>();
 }
Beispiel #43
0
        private static void LoadScript(BaseScript script)
        {
            Log.Write(LogLevel.Info, "Loading script {0}", script.GetType().Name);

            ScriptProcessor.AddScript(script);
        }