Ejemplo n.º 1
0
        public async void OnResourceStart()
        {
            NAPI.Server.SetAutoRespawnAfterDeath(false);
            NAPI.Server.SetAutoSpawnOnConnect(false);
            //NAPI.Server.SetGlobalServerChat(false);
            //NAPI.Server.SetCommandErrorMessage("");

            ServerUtilities.Initialise();

            Database db = new Database();

            Connection = db.Connection;

            GroupDatabase.InitializeTable();
            GroupDatabase.InitializeGroups();
            VehicleDatabase.InitializeTable();
            PlayerDatabase.InitializeTable();
            CharacterDatabase.InitializeTable();


            await GroupDatabase.AddCommandsToGroup(Config.GROUP_NAME_ADMIN, Commands.AdminCommands.ToArray());

            await GroupDatabase.AddCommandsToGroup(Config.GROUP_NAME_LEAD_ADMIN, Commands.OwnerCommands.ToArray());

            await GroupDatabase.AddCommandsToGroup(Config.GROUP_NAME_OWNER, Commands.OwnerCommands.ToArray());
        }
Ejemplo n.º 2
0
        public async void SelectCharacter(Client client, object[] args)
        {
            uint          characterId   = (uint)(int)args[0];
            CharacterData characterData = await CharacterDatabase.GetCharacterData(characterId);

            Vector3 position = characterData.GetPosition();
            float   heading  = characterData.Heading.HasValue ? characterData.Heading.Value : 0;

            if (position == null)
            {
                GamePosition spawnPoint = ServerUtilities.GetRandomSpawnPoint();
                position = spawnPoint.GetPosition();
                heading  = spawnPoint.GetHeading();
            }


            client.SetData(CharacterData.CHARACTER_DATA_KEY, characterData);

            PlayerData playerData         = client.GetData(PlayerData.PLAYER_DATA_KEY);
            GroupData  highestRankedGroup = await GroupDatabase.GetPlayerHighestRankingGroup(playerData.Id);

            if (highestRankedGroup == null)
            {
                return;
            }
            if (characterData == null)
            {
                return;
            }

            ServerUtilities.SetPlayerNametag(client);
            ServerUtilities.SwitchPlayerPosition(client, position, heading);
        }
        public static async void SetPlayerNametag(Client client)
        {
            PlayerData    playerData         = client.GetData(PlayerData.PLAYER_DATA_KEY);
            CharacterData characterData      = client.GetData(CharacterData.CHARACTER_DATA_KEY);
            GroupData     highestRankedGroup = await GroupDatabase.GetPlayerHighestRankingGroup(playerData.Id);



            if (characterData == null)
            {
                return;
            }
            client.Name = characterData.Name;

            if (highestRankedGroup == null)
            {
                client.Name = characterData.Name;
                NAPI.Player.SetPlayerName(client, characterData.Name);
                return;
            }

            var hexColor = highestRankedGroup.Color;

            client.Name = "[!{" + hexColor + "}" + highestRankedGroup.Name + "~w~] " + characterData.Name;
            NAPI.Player.SetPlayerName(client, "[!{" + hexColor + "}" + highestRankedGroup.Name + "~w~] " + characterData.Name);
        }
        public static async Task <bool> CanUseCommand(Client client, string command)
        {
            PlayerData playerData = client.GetData(PlayerData.PLAYER_DATA_KEY);

            if (playerData == null)
            {
                client.SendChatMessage("You are not logged in! Please reconnect.");
                return(false);
            }

            bool canUse = await GroupDatabase.DoesPlayerHaveCommand(playerData.Id, command);

            if (canUse == false)
            {
                Main.Logger.LogClient(client, "You do not have access to this command.");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        private DatabaseFactory()
        {

           connection = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), APPDB_PATH);
           

            /*    var sync = new SQLiteConnection(APPDB_PATH);
            connection = new SQLiteConnection(APPDB_PATH);*/

            identityDatabase = new IdentityDatabase(connection);
            threadDatabase = new ThreadDatabase(connection);
            groupDatabase = new GroupDatabase(connection);
            messageDatabase = new MessageDatabase(connection);
            textMessageDatabase = new TextMessageDatabase(connection);

            //contactDatabase = new ContactsDatabase(connection);
            //addressDatabase = new CanonicalAddressDatabase(connection);
            directoryDatabase = new TextSecureDirectory(connection);
            pushDatabase = new PushDatabase(connection);
            recipientDatabase = new RecipientDatabase(connection);
        }