private async Task OnTick() { if (Merchant != null && Merchant.Position.Distance(MerchantPosition) > 1f) { await SafeTeleport.Teleport(Merchant.Id, MerchantPosition.Add(new Position(0, 0, 0.5f)), 100); } await BaseScript.Delay(500); }
public static async Task PostLoad(this AtlasCharacter character) { AtlasPlugin.Instance.AttachTickHandler(Intro); Session.CreatingCharacter = true; var player = Cache.Player; var timestamp = API.GetGameTimer(); while (timestamp + 5000 > API.GetGameTimer()) { await BaseScript.Delay(100); } Session.Reload(); AtlasPlugin.Instance.DetachTickHandler(Intro); var board = new MugshotBoardAttachment(); player.DisableHud(); #pragma warning disable 4014 board.Attach(player); player.CameraQueue.View(new CameraBuilder() .WithMotionBlur(0.5f) .WithInterpolation(CameraViews[0], CameraViews[1], 5000) ); #pragma warning restore 4014 API.DoScreenFadeIn(5000); await player.AnimationQueue.PlayDirectInQueue(new AnimationBuilder() .Select("mp_character_creation@customise@male_a", "intro") ); player.AnimationQueue.AddToQueue(new AnimationBuilder() .Select("mp_character_creation@customise@male_a", "loop") .WithFlags(AnimationFlags.Loop) .SkipTask() ).PlayQueue(); var registered = false; var view = 0; StyleManager.GetModule().OpenStyleChange(character.Style, "General", 0, async type => { if (type == 0) { registered = true; } else { var item = InterfaceManager.GetModule().MenuContext.Selected; if (item == null) { return; } var head = HeadComponents.Select(self => self.ToLower()) .Contains(item.Seed.Replace("style_component_", "").ToLower()); if (head && view == 0) { view = 1; player.CameraQueue.Reset(); await player.CameraQueue.View(new CameraBuilder() .SkipTask() .WithMotionBlur(0.5f) .WithInterpolation(CameraViews[1], CameraViews[2], 300) ); } else if (!head && view == 1) { view = 0; player.CameraQueue.Reset(); await player.CameraQueue.View(new CameraBuilder() .SkipTask() .WithMotionBlur(0.5f) .WithInterpolation(CameraViews[2], CameraViews[1], 300) ); } } }, "CHAR_CREATE", "All"); while (!registered) { if (!API.IsEntityPlayingAnim(player.Entity.Id, "mp_character_creation@customise@male_a", "loop", 3)) { player.AnimationQueue.AddToQueue(new AnimationBuilder() .Select("mp_character_creation@customise@male_a", "loop") .WithFlags(AnimationFlags.Loop) .SkipTask() ).PlayQueue(); board.IsAttached = false; #pragma warning disable 4014 board.Attach(player); #pragma warning restore 4014 } await BaseScript.Delay(100); } player.AnimationQueue.AddToQueue(new AnimationBuilder() .Select("mp_character_creation@customise@male_a", "outro") .WithFlags(AnimationFlags.StayInEndFrame) ).PlayQueue(); API.DoScreenFadeOut(3000); await BaseScript.Delay(5500); Session.Join(1); board.IsAttached = false; await SafeTeleport.Teleport(player.Entity.Id, new Position(-1045.326f, -2750.793f, 21.36343f, 330.1637f)); #pragma warning disable 4014 player.CameraQueue.View(new CameraBuilder() #pragma warning restore 4014 .WithMotionBlur(0.5f) .WithInterpolation( new RotatablePosition(-1032.415f, -2726.847f, 26.48441f, 152.7852f, -7f, 0f), new RotatablePosition(-1032.415f, -2726.847f, 22.23441f, 152.7852f, -7f, 0f), 10000) ); API.DoScreenFadeIn(8000); API.TaskGoStraightToCoord(player.Entity.Id, DefaultPosition.X, DefaultPosition.Y, DefaultPosition.Z, 1f, -1, DefaultPosition.Heading, 0f); while (DefaultPosition.Distance(player.Entity.Position) > 0.1 || Math.Abs(DefaultPosition.Heading - player.Entity.Position.Heading) > 1) { await BaseScript.Delay(10); } character.MarkedAsRegistered = true; await character.Save(); await player.AnimationQueue.PlayDirectInQueue(new AnimationBuilder() .Select("move_p_m_one_idles@generic", "fidget_look_around") ); API.TransitionToBlurred(0f); player.EnableHud(); player.CameraQueue.Reset(); await BaseScript.Delay(10); API.TransitionFromBlurred(500f); await BaseScript.Delay(1000); Session.CreatingCharacter = false; }
public async Task Load(AtlasPlayer player) { API.DoScreenFadeOut(0); Atlas.DiscordRichPresence.Status = player.Character.Fullname; Atlas.DiscordRichPresence.Commit(); var transition = new LoadTransition(); if (!player.Character.MarkedAsRegistered) { API.StopPlayerSwitch(); } var character = player.Character; var position = !character.MarkedAsRegistered ? CharacterExtensions.RegistrationPosition : character.Metadata.LastPosition ?? CharacterExtensions.DefaultPosition; if (position == character.Metadata.LastPosition) { position.Y += 1f; } character.Revive(position); try { var ped = Cache.Entity.Id; var health = character.Health; if (health > API.GetEntityMaxHealth(ped)) { health = API.GetEntityMaxHealth(ped); } API.SetEntityHealth(ped, health); API.SetPedArmour(ped, character.Shield); } catch (Exception) { // Dunno } var inventories = InventoryManager.GetModule(); var required = new InventoryContainer[] { new EquipmentInventory(new InventoryContainerBase { Seed = "equipment_inventory", Name = "Utrustning", SlotAmount = 5 }), new PocketsInventory(new InventoryContainerBase { Seed = "pockets_inventory", Name = "Fickor", SlotAmount = 20 }), new ProximityInventory(new InventoryContainerBase { Seed = "proximity_inventory", Name = "Omgivning", SlotAmount = 20 }) }; foreach (var entry in required) { if (character.Metadata.Inventories.All(self => self.Seed != entry.Seed)) { inventories.RegisterContainer(entry); character.Metadata.Inventories.Add(entry); entry.CallRegistration(); } else { var created = entry; switch (entry.Seed.ToUpper()) { case "EQUIPMENT_INVENTORY": created = new EquipmentInventory( character.Metadata.Inventories.FirstOrDefault( self => self.Seed == "equipment_inventory")); break; case "POCKETS_INVENTORY": created = new PocketsInventory( character.Metadata.Inventories.FirstOrDefault( self => self.Seed == "pockets_inventory")); break; case "PROXIMITY_INVENTORY": created = new ProximityInventory( character.Metadata.Inventories.FirstOrDefault( self => self.Seed == "proximity_inventory")); created.Slots = new InventoryItem[created.SlotAmount]; break; default: Logger.Info($"[Inventory] Could not find default required inventory {entry.Seed}"); break; } inventories.RegisterContainer(created); created.CallRegistration(); } } inventories.Registry.ForEach(self => self.RefreshItemClassifications()); await player.Character.Load(); Session.Join(player.Character.MarkedAsRegistered ? 1 : 100 + API.GetPlayerServerId(API.PlayerId())); await SafeTeleport.Teleport(player.Entity.Id, position); if (player.Character.MarkedAsRegistered) { await transition.Wait(); API.DoScreenFadeIn(5000); await transition.Down(player); } else { await player.Character.PostLoad(); } if (API.IsScreenFadedOut() && !API.IsScreenFadingOut()) { API.DoScreenFadeIn(5000); } player.EnableHud(); }
public override void Begin() { EventSystem.GetModule().Attach("ambulance:revive", new EventCallback(metadata => { Cache.Character.Revive(Cache.Entity.Position); return(null); })); { var enter = new Marker(new Position(334.2201f, -569.3099f, 43.31741f, 158.8153f)) { Message = "Tryck ~INPUT_CONTEXT~ för att gå till våning 2", Scale = 2f, Color = Color.Transparent }; enter.Callback += async() => { API.DoScreenFadeOut(1000); await BaseScript.Delay(3000); await SafeTeleport.Teleport(Cache.Entity.Id, new Position(275.5131f, -1361.161f, 24.53781f, 52.16409f)); API.DoScreenFadeIn(1000); }; var exit = new Marker(new Position(275.5131f, -1361.161f, 24.53781f, 52.16409f)) { Message = "Tryck ~INPUT_CONTEXT~ för att gå till våning 1", Scale = 2f, Color = Color.Transparent }; exit.Callback += async() => { API.DoScreenFadeOut(1000); await BaseScript.Delay(3000); await SafeTeleport.Teleport(Cache.Entity.Id, new Position(334.2201f, -569.3099f, 43.31741f, 158.8153f)); API.DoScreenFadeIn(1000); }; enter.Show(); exit.Show(); } foreach (var bed in Beds) { var marker = new Marker(bed) { Message = "Tryck ~INPUT_CONTEXT~ för att lägga dig", Scale = 1f, Color = Color.Transparent, Condition = self => !IsLayingInBed }; marker.Callback += async() => { var ped = Cache.Entity; var prop = GetBedProp(bed); var position = API.GetEntityCoords(prop, false).ToPosition(); var endpoint = position.Add(Offset); IsLayingInBed = true; API.SetEntityCollision(prop, false, false); await ped.AnimationQueue.PlayDirectInQueue(new AnimationBuilder() .Select("mp_bedmid", "f_getin_r_bighouse") .AtPosition(endpoint) ); API.SetEntityCollision(prop, true, true); ped.Movable = false; ped.Position = ped.Position.Subtract(new Position(0, 0f, 0.8f)); ped.AnimationQueue.AddToQueue(new AnimationBuilder() .Select("mp_bedmid", "f_sleep_r_loop_bighouse") .WithFlags(AnimationFlags.StayInEndFrame) ).PlayQueue(); API.BeginTextCommandDisplayHelp("STRING"); API.AddTextComponentSubstringPlayerName("Tryck ~INPUT_CONTEXT~ för att resa dig"); API.EndTextCommandDisplayHelp(0, false, true, 5000); AtlasPlugin.Instance.AttachTickHandler(OnBedTick); }; marker.Show(); } }
public override async void Begin(Job job) { var model = new Model(MerchantModel); if (MerchantModel != 0 && MerchantPosition != null) { var merchantId = $"merchant::{job.Attachment.ToString().ToLower()}"; var package = NetworkPackage.GetModule(); if (Session.IsSpawnHost() && !API.NetworkDoesNetworkIdExist(package.GetLoad <int>(merchantId).Get())) { await model.Request(5000); var ped = API.CreatePed(6, (uint)model.Hash, MerchantPosition.X, MerchantPosition.Y, MerchantPosition.Z, MerchantPosition.Heading, true, false); Merchant = new Merchant(ped) { Important = true, Position = MerchantPosition }; package.GetLoad <int>(merchantId).UpdateAndCommit(Merchant.NetworkModule.GetId()); await SafeTeleport.Teleport(ped, MerchantPosition); Merchant.Movable = false; } else { while ((Merchant = MerchantManager.GetModule() .GetMerchantById(package.GetLoad <int>(merchantId).Get())) == null) { await BaseScript.Delay(1000); } } } await Session.Loading(); var player = Cache.Player; var character = Cache.Character; var marker = new Marker(Armory) { Message = "Tryck ~INPUT_CONTEXT~ för att komma åt förrådet", Color = Color.Transparent, Condition = self => character.Metadata.Employment == job.Attachment }; marker.Callback += async() => { if (MerchantPosition != null && Merchant != null) { await player.Entity.AnimationQueue.PlayDirectInQueue(new AnimationBuilder() .Select("gestures@m@standing@casual", "gesture_hello") .AtPosition(Armory) ); } Callback?.Invoke(); }; marker.Show(); Atlas.AttachTickHandler(OnTick); }