Exemple #1
0
        public void Spawn(Client player)
        {
            try
            {
                NAPI.Task.Run(() =>
                {
                    try
                    {
                        player.SetSharedData("IS_MASK", false);

                        // Logged in state, money, phone init
                        Trigger.ClientEvent(player, "loggedIn");
                        player.SetData("LOGGED_IN", true);

                        Trigger.ClientEvent(player, "UpdateMoney", Money);
                        Trigger.ClientEvent(player, "UpdateBank", MoneySystem.Bank.Accounts[Bank].Balance);
                        Trigger.ClientEvent(player, "initPhone");
                        Jobs.WorkManager.load(player);

                        // Skin, Health, Armor, RemoteID
                        player.SetSkin((Gender) ? PedHash.FreemodeMale01 : PedHash.FreemodeFemale01);
                        player.Health = (Health > 5) ? Health : 5;
                        player.Armor  = Armor;

                        player.SetSharedData("REMOTE_ID", player.Value);

                        Voice.Voice.PlayerJoin(player);

                        player.SetSharedData("voipmode", -1);

                        if (Fractions.Manager.FractionTypes[FractionID] == 1 || AdminLVL > 0)
                        {
                            Fractions.GangsCapture.LoadBlips(player);
                        }
                        if (WantedLVL != null)
                        {
                            Trigger.ClientEvent(player, "setWanted", WantedLVL.Level);
                        }

                        player.SetData("RESIST_STAGE", 0);
                        player.SetData("RESIST_TIME", 0);
                        if (AdminLVL > 0)
                        {
                            player.SetSharedData("IS_ADMIN", true);
                        }

                        Dashboard.sendStats(player);
                        Dashboard.sendItems(player);
                        if (Main.Players[player].LVL == 0)
                        {
                            NAPI.Task.Run(() => { try { Trigger.ClientEvent(player, "disabledmg", true); } catch { } }, 5000);
                        }

                        House house = HouseManager.GetHouse(player);
                        if (house != null)
                        {
                            // House blips & checkpoints
                            house.PetName = Main.Players[player].PetName;

                            Trigger.ClientEvent(player, "changeBlipColor", house.blip, 73);

                            Trigger.ClientEvent(player, "createCheckpoint", 333, 1, GarageManager.Garages[house.GarageID].Position - new Vector3(0, 0, 1.12), 1, NAPI.GlobalDimension, 220, 220, 0);
                            Trigger.ClientEvent(player, "createGarageBlip", GarageManager.Garages[house.GarageID].Position);
                        }

                        if (!Customization.CustomPlayerData.ContainsKey(UUID) || !Customization.CustomPlayerData[UUID].IsCreated)
                        {
                            Trigger.ClientEvent(player, "spawnShow", false);
                            Customization.CreateCharacter(player);
                        }
                        else
                        {
                            try
                            {
                                NAPI.Entity.SetEntityPosition(player, Main.Players[player].SpawnPos);
                                List <bool> prepData = new List <bool>
                                {
                                    true,
                                    (FractionID > 0) ? true : false,
                                    (house != null || HotelID != -1) ? true : false,
                                };
                                Trigger.ClientEvent(player, "spawnShow", JsonConvert.SerializeObject(prepData));
                                Customization.ApplyCharacter(player);
                            }
                            catch { }
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Write($"EXCEPTION AT \"Spawn.NAPI.Task.Run\":\n" + e.ToString(), nLog.Type.Error);
                    }
                });

                if (Warns > 0 && DateTime.Now > Unwarn)
                {
                    Warns--;

                    if (Warns > 0)
                    {
                        Unwarn = DateTime.Now.AddDays(14);
                    }
                    Notify.Send(player, NotifyType.Warning, NotifyPosition.BottomCenter, $"Одно предупреждение было снято. У Вас осталось {Warns}", 3000);
                }

                if (!Dashboard.isopen.ContainsKey(player))
                {
                    Dashboard.isopen.Add(player, false);
                }

                nInventory.Check(UUID);
                if (nInventory.Find(UUID, ItemType.BagWithMoney) != null)
                {
                    nInventory.Remove(player, ItemType.BagWithMoney, 1);
                }
                if (nInventory.Find(UUID, ItemType.BagWithDrill) != null)
                {
                    nInventory.Remove(player, ItemType.BagWithDrill, 1);
                }

                if (FractionID == 15)
                {
                    Trigger.ClientEvent(player, "enableadvert", true);
                    Fractions.LSNews.onLSNPlayerLoad(player);
                }
                if (AdminLVL > 0)
                {
                    ReportSys.onAdminLoad(player);
                }
            }
            catch (Exception e)
            {
                Log.Write("EXCEPTION AT \"Spawn\":\n" + e.ToString());
            }
        }