Beispiel #1
0
        public static async Task givePlayerWanted(Player suspect, Player player, int wantedLevel, string wantedReason, bool server = false)
        {
            mdc mdc = new mdc( );

            mdc.cop          = !server ?player.Name : "unknown";
            mdc.suspect      = suspect.Name;
            mdc.wantedLevel  = wantedLevel;
            mdc.wantedReason = wantedReason;

            await databaseManager.updateQuery($"INSERT INTO mdc (cop, suspect, wantedLevel, wantedReason) VALUES ('{mdc.cop}', '{mdc.suspect}', '{mdc.wantedLevel}', '{mdc.wantedReason}')").Execute( );

            suspect.SetSharedData("wantedLevel", suspect.GetSharedData <int>("wantedLevel") + mdc.wantedLevel);
            suspect.SetData("date", DateTime.Now);

            if (suspect.GetSharedData <int>("wantedLevel") > 6)
            {
                suspect.SetSharedData("wantedLevel", 6);
            }

            var txt = ""; if (!server)

            {
                txt = $" ({player.Value})";
            }

            suspect.SendChatMessage($"~r~You committed a crime: {mdc.wantedReason}, reported by {mdc.cop} {txt}. W: +{mdc.wantedLevel}. New wanted level: {suspect.GetSharedData<int>( "wantedLevel" )}.");

            await databaseManager.updateQuery($"UPDATE accounts SET wantedLevel = '{suspect.GetSharedData<int>( "wantedLevel" )}' WHERE username = '******' LIMIT 1").Execute( );
        }
Beispiel #2
0
        public static async Task <List <mdc> > getPlayerMdc(string username)
        {
            List <mdc> mdcList = new List <mdc>( );

            await databaseManager.selectQuery($"SELECT * FROM mdc WHERE suspect = '{username}'", ( DbDataReader reader ) => {
                mdc mdc          = new mdc( );
                mdc.id           = ( int )reader["id"];
                mdc.cop          = ( string )reader["cop"];
                mdc.wantedReason = ( string )reader["wantedReason"];
                mdcList.Add(mdc);
            }).Execute( );

            return(mdcList);
        }