예제 #1
0
 public static bool playerOkToSuicide(vPlayer p)
 {
     if (p.IsDead)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while already dead!");
         return(false);
     }
     if (p.WantedLevel > 0)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while wanted.");
         return(false);
     }
     if (p.IsInVehicle)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while in a vehicle.");
         return(false);
     }
     if (p.IsAttached)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while attached to an object/vehicle.");
         return(false);
     }
     if (!p.IsOnGround)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while not on the ground.");
         return(false);
     }
     if (p.combatTag)
     {
         processCommandError(p, "kill", noSyntax, "You cannot do this while in combat.");
     }
     return(true);
 }
예제 #2
0
        public static async Task AttemptLogin(Player player, string user, string pass)
        {
            vPlayer p = (vPlayer)player;
            int     id;
            string  username;
            string  passhash = "";

            var results = await database.Query("SELECT * FROM users WHERE username = '******'");

            id       = results[0]["id"];
            username = results[0]["username"];
            passhash = results[0]["password"];
            bool correct = await Bcrypt.Verify(pass, passhash);

            if (correct)
            {
                p.accountID = id;
                p.loadPlayerData(results[0]["money"], results[0]["skin"], results[0]["bank"], results[0]["staff_level"], results[0]["dim"], results[0]["int"], results[0]["x"], results[0]["y"], results[0]["z"], results[0]["rot"], results[0]["job"]);
                ChatBox.WriteLine("Welcome " + user, player, Slipe.Shared.Utilities.Color.Green);
            }
            else
            {
                ChatBox.WriteLine("Wrong login info.", player, Slipe.Shared.Utilities.Color.Red);
                Slipe.MtaDefinitions.MtaServer.KickPlayer(player.MTAElement, "Xoa", "Invalid login info");
            }
        }
예제 #3
0
        public static async Task getPlayerItems(vPlayer player)
        {
            var results = await database.Query("SELECT * FROM users_items WHERE owner = ?", player.accountID);

            foreach (var row in results)
            {
                player.Inventory.Add(row["name"], new PlayerItem(row["name"], row["amount"], row["owner"]));
            }
        }
예제 #4
0
        public static bool hasStaffPermission(float required_lvl, vPlayer p, string action)
        {
            if (p.StaffLevel >= required_lvl)
            {
                return(true);
            }

            ChatBox.WriteLine("You do not have permission to perform this action: " + action, p, Color.Red);
            return(false);
        }
예제 #5
0
        public static async Task AttemptPlayerRelog(Player player, int id)
        {
            vPlayer p       = (vPlayer)player;
            var     results = await database.Query("SELECT * FROM users WHERE id = '" + id + "'");

            id          = results[0]["id"];
            p.accountID = id;
            p.loadPlayerData(results[0]["money"], results[0]["skin"], results[0]["bank"], results[0]["staff_level"], results[0]["dim"], results[0]["int"], results[0]["x"], results[0]["y"], results[0]["z"], results[0]["rot"], results[0]["job"]);
            ChatBox.WriteLine("Welcome " + (string)results[0]["username"], player, Slipe.Shared.Utilities.Color.Green);
        }
예제 #6
0
 public static void processCommandError(vPlayer p, string cmdname, string[] cmdargs, string error)
 {
     ChatBox.WriteLine("There was an error performing the command:", p, Color.Red);
     ChatBox.WriteLine(error, p, Color.Salmon);
     if (cmdargs == noSyntax)
     {
         ChatBox.WriteLine("SYNTAX: /" + cmdname, p, Color.Orange);
     }
     else
     {
         ChatBox.WriteLine("SYNTAX: /" + cmdname + " " + string.Join(" ", cmdargs), p, Color.Orange);
     }
 }
예제 #7
0
파일: Item.cs 프로젝트: JamieJ98/slipe-rpg
 public PlayerItem(string name, int a, int playerid)
 {
     this.ID     = name;
     this.amount = a;
     this.Owner  = (vPlayer)ElementManager.Instance.GetByType <Player>().FirstOrDefault(e => ((vPlayer)e).accountID == playerid);
 }
예제 #8
0
        public static void HandleCommand(Player player, string command, string[] arguments)
        {
            vPlayer p = (vPlayer)player;

            switch (command)
            {
                #region temp commands
            case "checkitems":
                p.editMoney(-100);
                break;
                #endregion

                #region Chat
            case "main":
                mPlayer.sendGlobalMessage("main", "#" + mPlayer.HexCodeFromName(p) + "(" + Utils.getCityCode(p) + ") " + p.Name + ": #FFFFFF" + Program.wrapParameters(arguments, 0));
                break;

            case "xc":
                if (Checking.hasStaffPermission(0.1f, p, "/xc"))
                {
                    mPlayer.sendGlobalMessage("staff", "#" + mPlayer.HexCodeFromName(p) + "(STAFF) " + p.Name + ": #FFFFFF" + Program.wrapParameters(arguments, 0));
                }
                break;
                #endregion

                #region General Gameplay Commands
            case "kill":
                if (p.suicide)
                {
                    ChatBox.WriteLine("You cancelled your suicide.", player, Color.GreenYellow);
                    p.suicide      = false;
                    p.suicideTimer = 0;
                    p.Frozen       = false;
                }
                else if (Checking.playerOkToSuicide(p))
                {
                    //add a check for already frozen
                    ChatBox.WriteLine("You will be killed in 5 seconds use /kill again to cancel.", player, Color.AquaMarine);
                    p.suicide      = true;
                    p.suicideTimer = 0;
                }
                break;
                #endregion

                #region Login Commands (will be removed once GUI is done)
            case "slogin":
                _ = dbManager.AttemptLogin(player, arguments[0], arguments[1]);
                break;

            case "sregister":
                _ = dbManager.Register(player, arguments[0], arguments[1]);
                break;
                #endregion

                #region Money related commands
            case "balance":
                ChatBox.WriteLine("Your Bank Balance is: $" + p.BankBalance, player, Color.GreenYellow);
                break;

            case "withdraw":
                int amount = Convert.ToInt32(arguments[0]);
                if (amount > 0)
                {
                    p.withdrawBankMoney(amount);
                }
                else
                {
                    Program.dx.Invoke("shout", p.MTAElement, "Nice try.", 255, 0, 0);
                }
                break;
                #endregion

                #region Job related commands
            case "quitjob":
                p.quitJob();
                break;

            case "criminal":
                p.setJob("Criminal");
                Program.dx.Invoke("shout", p.MTAElement, "You are now a criminal", 255, 0, 0);
                break;

            case "gangster":
                p.setJob("Gangster");
                break;

            case "police":
                p.setJob("Police Officer");
                break;

            case "medic":
                p.setJob("Paramedic");
                break;
                #endregion

                #region Staff Commands
            case "forcesave":
                if (Checking.hasStaffPermission(1, p, "/forcesave"))
                {
                    p.saveData();
                }
                break;

            case "staff":
                if (Checking.hasStaffPermission(1, p, "/staff"))
                {
                    p.setJob("L" + p.StaffLevel + " Staff");
                    p.Model = 217;
                }
                break;

            case "staffg":
                if (Checking.hasStaffPermission(1, p, "/staffg"))
                {
                    p.setJob("L" + p.StaffLevel + " Staff");
                    p.Model = 211;
                }
                break;

            case "setskin":
                string[] syntax = { "player", "skinID" };
                if (Checking.hasStaffPermission(1, p, "/setskin"))
                {
                    try
                    {
                        vPlayer target = (vPlayer)Player.GetFromName(arguments[0]);
                        int     skin;
                        bool    success = Int32.TryParse(arguments[1], out skin);
                        if (success)
                        {
                            if (Checking.isValidSkin(skin))
                            {
                                target.skin  = skin;
                                target.Model = skin;
                            }
                            else
                            {
                                Checking.processCommandError(p, command, syntax, "Invalid Skin");
                            }
                        }
                        else
                        {
                            Checking.processCommandError(p, command, syntax, "Invalid Skin");
                        }
                    }
                    catch (ArgumentOutOfRangeException) { Checking.processCommandError(p, "setskin", Checking.noSyntax, "Incorrect syntax."); }
                    catch (NullElementException e) { Checking.processCommandError(p, "setskin", Checking.noSyntax, e.Message); }
                }
                break;
                #endregion
            }
        }
예제 #9
0
        public static string HexCodeFromName(vPlayer p)
        {
            Color myColor = p.NametagColor;

            return(myColor.R.ToString("X2") + myColor.G.ToString("X2") + myColor.B.ToString("X2"));
        }