예제 #1
0
        public static void FinishLogin(Client client)
        {
            TLMongoDatabase db        = new TLMongoDatabase();
            ObjectId        client_id = client.GetData("ID");
            TLPlayerStats   playerStats;

            var query = db.GetListById <TLPlayerStats>(client_id).Result;

            if (query.Count == 0)
            {
                playerStats    = new TLPlayerStats();
                playerStats.Id = client_id;
                db.Insert <TLPlayerStats>(playerStats);
            }
            else
            {
                playerStats = query[0];
            }

            client.Position = playerStats.GetLastPosition();

            NAPI.Entity.SetEntityTransparency(client, 255);
            NAPI.Entity.SetEntityInvincible(client, false);
            NAPI.ClientEvent.TriggerClientEvent(client, "playerLoggedIn");
            NAPI.ClientEvent.TriggerClientEvent(client, "LoginResult", 1);
            NAPI.ClientEvent.TriggerClientEvent(client, "moveSkyCamera", client, "down", 1, true);

            UpdateMoneyEvent.Update_Money(client);
        }
예제 #2
0
        public void CMD_GetBalance(Client client)
        {
            TLPlayerStats playerStats = TLPlayerHelper.GetPlayerStats(client);

            if (playerStats == null)
            {
                client.SendChatMessage($"~r~Player has no wallet");
                return;
            }

            client.SendChatMessage($"Your Balance is: ${playerStats.money}");
            UpdateMoneyEvent.Update_Money(client);
        }
예제 #3
0
        public void CMD_GiveMoney(Client client, string username, double amount)
        {
            if (client.Name.ToLower() == username)
            {
                client.SendChatMessage($"You can't give yourself money.");
                return;
            }

            TLPlayerStats sendingPlayerStats = TLPlayerHelper.GetPlayerStats(client);
            TLPlayer      recevingPlayerInfo = db.GetSingle <TLPlayer>("username", username).Result;

            if (recevingPlayerInfo == null)
            {
                client.SendChatMessage("That username does not exist");
                return;
            }

            TLPlayerStats receivingPlayerStats = db.GetSingle <TLPlayerStats>("username", recevingPlayerInfo.Username).Result;

            if (receivingPlayerStats == null)
            {
                Console.WriteLine($"{recevingPlayerInfo.Username} does not have TLPlayerStats table.");
                return;
            }

            bool sentMoney = sendingPlayerStats.SubMoney(amount);

            if (!sentMoney)
            {
                client.SendChatMessage("~r~You dont not have the sufficient funds for that.");
                return;
            }
            receivingPlayerStats.AddMoney(amount);

            db.Update <TLPlayerStats>(sendingPlayerStats.Id, "money", sendingPlayerStats.money.ToString());
            db.Update <TLPlayerStats>(receivingPlayerStats.Id, "money", receivingPlayerStats.money.ToString());

            client.SendChatMessage($"You sent ${amount} to {recevingPlayerInfo.Username}");

            UpdateMoneyEvent.Update_Money(client);

            Client receivingPlayerClient = NAPI.Player.GetPlayerFromName(username);

            if (receivingPlayerClient == null)
            {
                return;
            }

            UpdateMoneyEvent.Update_Money(receivingPlayerClient);
        }
예제 #4
0
        public void CMD_BurnMoney(Client client, double amount)
        {
            TLPlayerStats playerStats = TLPlayerHelper.GetPlayerStats(client);

            if (playerStats == null)
            {
                return;
            }

            bool result = playerStats.SubMoney(amount);

            db.Update <TLPlayerStats>(playerStats.Id, "money", playerStats.money.ToString());

            if (result)
            {
                client.SendChatMessage($"~y~You burnt ${amount}");
            }
            else
            {
                client.SendChatMessage($"~r~Something went wrong.");
            }

            UpdateMoneyEvent.Update_Money(client);
        }
예제 #5
0
        public void CMD_AddBalance(Client client, double amount)
        {
            TLPlayerStats playerStats = TLPlayerHelper.GetPlayerStats(client);

            if (playerStats == null)
            {
                return;
            }

            bool result = playerStats.AddMoney(amount);

            db.Update <TLPlayerStats>(playerStats.Id, "money", amount.ToString());

            if (result)
            {
                client.SendChatMessage($"~g~You recieved ${amount}");
            }
            else
            {
                client.SendChatMessage($"~r~Something went wrong.");
            }

            UpdateMoneyEvent.Update_Money(client);
        }