Esempio n. 1
0
        public async void removeLicense(Player player, string username, mainLicense.license license)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }

            var target = playerManager.getPlayer(username);

            if (target.IsNull)
            {
                player.SendChatMessage("!{#CECECE}The specified player ID is either not connected or has not authenticated.");
                return;
            }
            await target.removeLicense(license, player);
        }
Esempio n. 2
0
        public async void onSet(Player player, string username, string type, dynamic args1 = null, dynamic args2 = null, dynamic args3 = null)
        {
            if (playerManager.doesPlayerHasAdmin(player) <= 0)
            {
                player.SendChatMessage("!{#CEF0AC}You need to be an admin.");
                return;
            }

            Player target = playerManager.getPlayer(username);

            if (target == null)
            {
                player.SendChatMessage("!{#CECECE}The specified player ID is either not connected or has not authenticated.");
                return;
            }

            switch (type)
            {
            case "Money":
            case "money":
                int money = 0;
                if (!int.TryParse(args1, out money))
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Invalid amount.");
                    return;
                }

                target.SendChatMessage($"~r~Admin {player.Name}[{player.Value}] has given you {money}$.");
                SendMessageToAdmins($"{"!{#F03337}"}Warning: Admin {player.Name}[{player.Value}] sent ${money} to {target.Name}[{target.Value}].");
                await target.giveMoney(money);

                break;

            case "License":
            case "license":

                mainLicense.license license = 0; int hours = 0;
                if (mainLicense.license.TryParse(args1, true, out license))
                {
                    if (!int.TryParse(args2, out hours))
                    {
                        player.SendChatMessage($"{"!{#CECECE}"}Invalid amount.");
                        return;
                    }

                    if (hours > 0)
                    {
                        await target.setLicense(license, hours);
                    }
                    else
                    {
                        await target.removeLicense(license);
                    }

                    target.SendChatMessage($"~r~Admin {player.Name} has changed your license  {Enum.GetName(typeof(mainLicense.license), license)} to {hours} hours.");
                    SendMessageToAdmins($"{"!{#EFB646}"}{target.Name} [id: {new accountController(target).sqlid}]'s {Enum.GetName(typeof(mainLicense.license), license)} was set to {hours} hours(( Admin {player.Name}[id: {new accountController(player).sqlid}] ))");
                }
                else
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Invalid license.");
                }
                break;

            case "Materials":
            case "materials":
                int amount = 0;
                if (!int.TryParse(args1, out amount))
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Invalid amount.");
                    return;
                }
                target.SetSharedData("materials", target.GetSharedData <int>("materials") + amount);
                target.SendChatMessage($"~r~Admin {player.Name}[{player.Value}] has given you {amount}$.");
                SendMessageToAdmins($"{"!{#F03337}"}Warning: Admin {player.Name}[{player.Value}] sent {amount} materials to {target.Name}[{target.Value}].");
                await databaseManager.updateQuery($"UPDATE accounts SET materials = '{target.GetSharedData<int>("materials")}' WHERE username = '******'").Execute();

                break;

            case "Job":
            case "job":
                playerManager.job job = 0;
                if (playerManager.job.TryParse(args1, true, out job))
                {
                    target.SetSharedData("job", job);
                    target.SendChatMessage($"~r~Admin {player.Name} has changed your job to {Enum.GetName(typeof(playerManager.job), job)}.");
                    SendMessageToAdmins($"{"!{#EFB646}"}{target.Name} [id: {new accountController(target).sqlid}]'s job was set to {Enum.GetName(typeof(playerManager.job), job)} (( Admin {player.Name}[id: {new accountController(player).sqlid}] ))");
                    await databaseManager.updateQuery($"UPDATE accounts SET job = '{(int)job}' WHERE username = '******'").Execute();
                }
                else
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Invalid job.");
                }
                break;

            case "Group":
            case "group":
                factionsManager.type faction = 0;
                if (factionsManager.type.TryParse(args1, true, out faction))
                {
                    target.SetSharedData("faction", faction);
                    target.SendChatMessage($"~r~Admin {player.Name} has set your group to {Enum.GetName(typeof(factionsManager.type), faction)}.");
                    SendMessageToAdmins($"{"!{#EFB646}"}{target.Name} [id: {new accountController(target).sqlid}]'s group was set to {Enum.GetName(typeof(factionsManager.type), faction)} (( Admin {player.Name}[id: {new accountController(player).sqlid}] ))");
                    await databaseManager.updateQuery($"UPDATE accounts SET faction = '{(int)faction}' WHERE username = '******'").Execute();
                }
                else
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Invalid faction.");
                }
                break;

            case "Grouprank":
            case "grouprank":
                int rank = 0;
                if (!int.TryParse(args1, out rank))
                {
                    player.SendChatMessage($"{"!{#F03337}"}Invalid group rank.");
                    return;
                }
                if (target.HasSharedData("faction") && target.GetSharedData <factionsManager.type>("faction") == factionsManager.type.civilian)
                {
                    player.SendChatMessage($"{"!{#CECECE}"}Target does not have a group.");
                    return;
                }
                target.SetData("factionRank", rank);
                target.SendChatMessage($"~r~Admin {player.Name} has set your group rank to {rank}.");
                SendMessageToAdmins($"{"!{#EFB646}"}{target.Name} [id: {new accountController(target).sqlid}]'s group rank was set to {rank} (( Admin {player.Name}[id: {new accountController(player).sqlid}] ))");
                await databaseManager.updateQuery($"UPDATE accounts SET factionRank = '{rank}' WHERE username = '******'").Execute();

                break;

            case "vw":
            case "Vw":
                int vw = 0;
                if (!int.TryParse(args1, out vw))
                {
                    player.SendChatMessage("");
                    return;
                }
                target.SendChatMessage($"~r~Admin {player.Name} has set your virtual world to {vw}.");
                SendMessageToAdminsAdmCmd($"Admin {player.Name}[{player.Value}] has changed {target.Name}[{target.Value}]'s virtual world to {vw}.");
                target.Dimension = (uint)vw;
                break;
            }
        }