Ejemplo n.º 1
0
        /// <summary>
        /// Selects a character
        /// </summary>
        /// <param name="player">Player to select character for</param>
        /// <param name="characterName">Character's name</param>
        public void SelectCharacter(Player player, string characterName)
        {
            if (IsPlayerInCharacterSelection(player))
            {
                Character character = this.GetCharacterForName(player, characterName);

                if (character != null)
                {
                    player.client.dimension      = 0;
                    player.client.freezePosition = false;

                    if (PlayerManager.Instance().TeleportPlayerToJailIfTimeLeft(character))
                    {
                        character.SendNotification("You have " + PlayerManager.Instance().GetTimeLeftInJailForCharacter(character) + " minutes of jail time left");
                    }
                    else if (character.spawnHouseId != -1)
                    {
                        HouseManager.Instance().AddCharacterToHouseWithId(character.spawnHouseId, character);
                        player.client.position = HouseManager.Instance().GetSpawnLocationOfHouseWithId(character.spawnHouseId);
                    }
                    else
                    {
                        // Default spawn
                        player.client.position = new Vector3(-692.194, 295.9935, 82.83133);
                    }

                    player.SetActiveCharacter(character);
                    this.RemovePlayerFromCharacterSelector(player);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets active character for player
        /// </summary>
        /// <param name="c">Character to set as active character</param>
        public void SetActiveCharacter(Character c)
        {
            activeCharacter     = c;
            client.nametag      = activeCharacter.ID.ToString() + " " + activeCharacter.fullName;
            client.nametagColor = new Color(c.faction.colorR, c.faction.colorG, c.faction.colorB);
            client.setSkin(API.shared.pedNameToModel(c.model));

            JobInfo i = JobManager.Instance().GetInfoForJobWithId(c.job);
            Faction f = FactionManager.Instance().GetFactionWithId(c.factionID);

            List <RPVehicle> vehicles = VehicleManager.Instance().GetVehiclesForCharacter(c);
            List <Item>      items    = c.GetAllItemsFromInventory();

            API.shared.triggerClientEvent(c.owner.client, "EVENT_INIT_HUD", i.name, i.colorR, i.colorG, i.colorB, f.name, f.colorR, f.colorG, f.colorB, c.money.ToString(), c.fullName, c.phone.phoneNumber, c.phone.GetTextMessageIds(), c.phone.GetTextMessageSenders(), c.phone.GetTextMessageTimes(), c.phone.GetTextMessageTexts(), c.phone.GetContactNames(), c.phone.GetContactNumbers(), vehicles.Select(x => x.id).ToList(), vehicles.Select(x => x.licensePlateText).ToList(), vehicles.Select(x => x.spawned).ToList(), items.Select(x => x.id).ToList(), items.Select(x => x.name).ToList(), items.Select(x => x.count).ToList(), items.Select(x => x.description).ToList());
            API.shared.triggerClientEvent(c.owner.client, "EVENT_CLOSE_CHARACTER_SELECT_MENU");

            HouseManager.Instance().SendListOfOwnedHousesToClient(c.owner.client);

            // Check faction, if is part of faction, then get text
            if (c.factionID != FactionI.CIVILIAN)
            {
                c.UpdateFactionRankText(FactionManager.Instance().GetRankTextForCharacter(c), 255, 255, 255);
            }

            API.shared.triggerClientEvent(c.owner.client, "EVENT_TOGGLE_HUD_ON");
            PlayerManager.Instance().ToggleMinimapForPlayer(c.owner.client, true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Script startup function
        /// </summary>
        public void StartScript()
        {
            API.consoleOutput("#### Script started! ####");

            API.onVehicleDeath       += VehicleManager.Instance().VehicleDestroyedEvent;
            API.onPlayerEnterVehicle += VehicleManager.Instance().VehicleEnterEvent;
            API.onPlayerExitVehicle  += VehicleManager.Instance().VehicleExitEvent;


            API.onPlayerDisconnected += PlayerManager.Instance().HandlePlayerDisconnect;
            // When API.onPlayerConnected is fixed, change this
            API.onPlayerFinishedDownload += PlayerManager.Instance().HandlePlayerConnect;
            API.onPlayerDeath            += PlayerManager.Instance().HandlePlayerDeath;


            PlayerManager.Instance().InitializePlayerManager();
            VehicleManager.Instance().InitializeVehicleManager();
            HouseManager.Instance().InitializeHouseManager();
            ItemManager.Instance().InitializeItemManager();
            MapManager.Instance().Initialize();
            JobManager.Instance().Initialize();
            FactionManager.Instance().InitializeFactions();

            API.consoleOutput("#### Script load complete! ####");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Script startup function
        /// </summary>
        public void StartScript()
        {
            API.consoleOutput("####Script started!####");
            WeatherManager weatherManager = new WeatherManager();

            API.onVehicleDeath       += VehicleManager.Instance().VehicleDestroyedEvent;
            API.onPlayerEnterVehicle += VehicleManager.Instance().VehicleEnterEvent;
            API.onPlayerExitVehicle  += VehicleManager.Instance().VehicleExitEvent;


            //API.onPlayerConnected += PlayerManager.Instance().HandlePlayerConnect;
            API.onPlayerDisconnected     += PlayerManager.Instance().HandlePlayerDisconnect;
            API.onPlayerFinishedDownload += PlayerManager.Instance().HandlePlayerConnect;


            PlayerManager.Instance().InitAccountCreationId();
            PlayerManager.Instance().InitTextMessagesId();
            PlayerManager.Instance().InitCharacterCreationId();
            PlayerManager.Instance().InitCharacterSelectorModels();
            PlayerManager.Instance().InitPhoneNumbers();
            PlayerManager.Instance().InitCharacterGenders();

            VehicleManager.Instance().LoadVehiclesFromDB();
            HouseManager.Instance().LoadHouseTemplates();
            JobManager.Instance().InitJobPickupPoints();
            ItemManager.Instance().InitializeItems();
            MapManager.Instance().Initialize();
            JobManager.Instance().Initialize();

            FactionManager.Instance().InitializeFactions();

            API.consoleOutput("####Script load complete!####");
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets a new spawn position for player inside a house that is owned by him/her
 /// </summary>
 /// <param name="client">Client</param>
 /// <param name="houseId">ID of the owned house</param>
 public void SetCharacterSpawnHouse(Character character, int houseId)
 {
     if (HouseManager.Instance().IsCharacterOwnerOrRenterOfHouse(character, houseId))
     {
         UpdateCharacterSpawnPosition(character, houseId);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sets a new spawn position for player inside a house that is owned by him/her
 /// </summary>
 /// <param name="c">Client</param>
 /// <param name="houseId">ID of the owned house</param>
 public void SetCharacterSpawnHouse(Client c, int houseId)
 {
     if (IsClientUsingCharacter(c))
     {
         Character character = GetActiveCharacterForClient(c);
         if (HouseManager.Instance().IsCharacterOwnerOrRenterOfHouse(character, houseId))
         {
             // Update spawn position for character
             UpdateCharacterSpawnPosition(character, houseId);
         }
     }
 }