Exemple #1
0
        public static bool MenuCommand(GtaPlayer player)
        {
            var m = new Menu("Test menu", Vector2.Zero);

            m.Columns.Add(new MenuColumn(100));

            m.Rows.Add(new MenuRow("Active"));
            m.Rows.Add(new MenuRow("Disabled", true));
            m.Rows.Add(new MenuRow("Active2"));

            m.Show(player);

            m.Exit += (o, eventArgs) =>
            {
                player.SendClientMessage(Color.Red, "MENU CLOSED");
                m.Dispose();
            };

            m.Response += (o, eventArgs) =>
            {
                player.SendClientMessage(Color.Green, "SELECTED ROW " + eventArgs.Row);
                m.Dispose();
            };

            return(true);
        }
Exemple #2
0
        public static bool MenuCommand(GtaPlayer player)
        {
            var m = new Menu("Test menu", Vector2.Zero);

            m.Columns.Add(new MenuColumn(100));

            m.Rows.Add(new MenuRow("Active"));
            m.Rows.Add(new MenuRow("Disabled", true));
            m.Rows.Add(new MenuRow("Active2"));

            m.Show(player);

            m.Exit += (o, eventArgs) =>
            {
                player.SendClientMessage(Color.Red, "MENU CLOSED");
                m.Dispose();
            };

            m.Response += (o, eventArgs) =>
            {
                player.SendClientMessage(Color.Green, "SELECTED ROW " + eventArgs.Row);
                m.Dispose();
            };

            return true;
        }
Exemple #3
0
        public async void ASyncPlayerConnectedDelayed(GtaPlayer player)
        {
            await Task.Delay(2000);
            Console.WriteLine("in ASyncPlayerConnectedDelayed");
            player.SendClientMessage("ASync message! !{0}!", Native.IsMainThread());

            Sync.Run(() => player.SendClientMessage("Sync message! !{0}!", Native.IsMainThread()));
        }
Exemple #4
0
        public static void TestCommand(GtaPlayer player, string word, int num, string text)
        {
            Console.WriteLine("Player: {0}, Word: {1}, Rest: {2}, Num: {3}", player, word, text, num);
            Console.WriteLine("Text written to console...");
            player.SendClientMessage(Color.Green, "Text written to console!");

            player.SendClientMessage(Color.Green, "Formattest {0} -- {1} ,, {2}", 123, "xyz", "::DD");
        }
Exemple #5
0
        public async void ASyncPlayerConnectedDelayed(GtaPlayer player)
        {
            await Task.Delay(2000);

            Console.WriteLine("in ASyncPlayerConnectedDelayed");
            player.SendClientMessage("ASync message! !{0}!", Native.IsMainThread());

            Sync.Run(() => player.SendClientMessage("Sync message! !{0}!", Native.IsMainThread()));
        }
Exemple #6
0
        /// <summary>
        ///     Runs the command.
        /// </summary>
        /// <param name="player">The player running the command.</param>
        /// <param name="args">The arguments the player entered.</param>
        /// <returns>
        ///     True when the command has been executed, False otherwise.
        /// </returns>
        public override bool RunCommand(GtaPlayer player, string args)
        {
            if (!HasPlayerPermissionForCommand(player))
            {
                if (PermissionCheck.Message == null)
                {
                    // If the message is null, we return false so samp will think that this method doesn't exists
                    // and will print the default message
                    return(false);
                }

                player.SendClientMessage(PermissionCheck.Message);
                return(true);
            }

            var arguments = new List <object>();

            if (Command.IsStatic)
            {
                arguments.Add(player);
            }

            for (int paramIndex = 0; paramIndex < Parameters.Length; paramIndex++)
            {
                ParameterInfo      parameterInfo      = _parameterInfos[paramIndex + (Command.IsStatic ? 1 : 0)];
                ParameterAttribute parameterAttribute = Parameters[paramIndex];

                args = args.Trim();

                /*
                 * Check for missing optional parameters. This is obviously allowed.
                 */
                if (args.Length == 0 && parameterAttribute.Optional)
                {
                    arguments.Add(parameterInfo.DefaultValue);
                    continue;
                }

                object argument;
                if (args.Length == 0 || !parameterAttribute.Check(ref args, out argument))
                {
                    if (UsageFormat != null)
                    {
                        player.SendClientMessage(UsageFormat(CommandPath, Parameters));
                        return(true);
                    }

                    return(false);
                }

                arguments.Add(argument);
            }

            object result = Command.Invoke(Command.IsStatic ? null : player, arguments.ToArray());

            return(Command.ReturnType == typeof(void) || (bool)result);
        }
Exemple #7
0
 public static void CommandsCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Commands:");
     foreach (
         DetectedCommand cmd in
             Command.GetAll<DetectedCommand>()
                 .Where(c => c.HasPlayerPermissionForCommand(player))
                 .OrderBy( /* category??? */c => c.CommandPath))
     {
         player.SendClientMessage(Color.White,
             "/{0}: I could add an Attribute in my gamemode with an help message and/or color", cmd.CommandPath);
     }
 }
Exemple #8
0
 public static void CommandsCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Commands:");
     foreach (
         DetectedCommand cmd in
         Command.GetAll <DetectedCommand>()
         .Where(c => c.HasPlayerPermissionForCommand(player))
         .OrderBy(/* category??? */ c => c.CommandPath))
     {
         player.SendClientMessage(Color.White,
                                  "/{0}: I could add an Attribute in my gamemode with an help message and/or color", cmd.CommandPath);
     }
 }
Exemple #9
0
        public static async void DialogASyncCommand(GtaPlayer player)
        {
            var dialog = new Dialog(DialogStyle.Input, "Hello", "Insert something", "Confirm", "NO");
            var response = await dialog.ShowAsync(player);

            Console.WriteLine(Sync.IsRequired);
            Sync.Run(() => { player.SendClientMessage("Response: " + response.InputText); });
        }
Exemple #10
0
        public static async void DialogASyncCommand(GtaPlayer player)
        {
            var dialog   = new Dialog(DialogStyle.Input, "Hello", "Insert something", "Confirm", "NO");
            var response = await dialog.ShowAsync(player);

            Console.WriteLine(Sync.IsRequired);
            Sync.Run(() => { player.SendClientMessage("Response: " + response.InputText); });
        }
Exemple #11
0
        public static void VehicleCommand(GtaPlayer player, VehicleModelType model)
        {
            player.SendClientMessage(Color.GreenYellow, "You have spawned a {0}", model);
            Console.WriteLine("Spawning a {0} {2} for {1}", model, player, (int)model);
            GtaVehicle vehicle = GtaVehicle.Create(model, player.Position + new Vector3(0, 0, 0.5f), player.Rotation.Z, -1,
                                                   -1);

            player.PutInVehicle(vehicle);
        }
Exemple #12
0
        public static async void DialogASyncCommandLogintest(GtaPlayer player)
        {
            var dialog = new InputDialog("Hello", "Login please!", true, "Login", "Cancel");

            var timerToShowThingsWork = new Timer(1000, true);

            timerToShowThingsWork.Tick += (sender, args) =>
            {
                player.SendClientMessage("Things still work in the background!");
            };

            var response = await dialog.ShowAsync(player);

            player.SendClientMessage("Your input was {1}... Do we require a sync? {0}. So thats awesome! Lets move you up a lill. ", Sync.IsRequired, response.InputText);
            player.Position += new Vector3(0, 1, 0);

            timerToShowThingsWork.Dispose();
        }
Exemple #13
0
 public static void PutCommand(GtaPlayer player, int vehicleid, int seat = 0)
 {
     GtaVehicle v = GtaVehicle.Find(vehicleid);
     if (v == null)
     {
         player.SendClientMessage(Color.Red, "This vehicle does not exist!");
         return;
     }
     player.PutInVehicle(v, seat);
 }
Exemple #14
0
        public static void PutCommand(GtaPlayer player, int vehicleid, int seat = 0)
        {
            GtaVehicle v = GtaVehicle.Find(vehicleid);

            if (v == null)
            {
                player.SendClientMessage(Color.Red, "This vehicle does not exist!");
                return;
            }
            player.PutInVehicle(v, seat);
        }
Exemple #15
0
        public static void DialogCommand(GtaPlayer player)
        {
            var dialog = new MessageDialog("Captions", "abc", "OK!", "Cancel");

            dialog.Show(player);

            dialog.Response += (sender, args) =>
            {
                player.SendClientMessage("Response: " + args.DialogButton);
            };
        }
Exemple #16
0
        public static void DialogCommand(GtaPlayer player)
        {
            var dialog = new MessageDialog("Captions", "abc", "OK!", "Cancel");

            dialog.Show(player);

            dialog.Response += (sender, args) =>
            {
                player.SendClientMessage("Response: " + args.DialogButton);
            };
        }
Exemple #17
0
        public static void DialogListCommand(GtaPlayer player, string items)
        {
            var dialog = new ListDialog("Captions", "OK!");

            foreach (var i in items.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s)))
                dialog.Items.Add(i);

            dialog.Show(player);

            dialog.Response += (sender, args) =>
            {
                player.SendClientMessage("Response: " + args.ListItem);
            };
        }
Exemple #18
0
        public static void DialogListCommand(GtaPlayer player, string items)
        {
            var dialog = new ListDialog("Captions", "OK!");

            foreach (var i in items.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s)))
            {
                dialog.Items.Add(i);
            }

            dialog.Show(player);

            dialog.Response += (sender, args) =>
            {
                player.SendClientMessage("Response: " + args.ListItem);
            };
        }
Exemple #19
0
        public static async void DialogASyncCommandLogintest(GtaPlayer player)
        {
            var dialog = new InputDialog("Hello", "Login please!", true, "Login", "Cancel");

            var timerToShowThingsWork = new Timer(1000, true);
            timerToShowThingsWork.Tick += (sender, args) =>
            {
                player.SendClientMessage("Things still work in the background!");
            };

            var response = await dialog.ShowAsync(player);

            player.SendClientMessage("Your input was {1}... Do we require a sync? {0}. So thats awesome! Lets move you up a lill. ", Sync.IsRequired, response.InputText);
            player.Position += new Vector3(0,1,0);

            timerToShowThingsWork.Dispose();
        }
Exemple #20
0
 public static void VehicleCommand(GtaPlayer player, VehicleModelType model)
 {
     player.SendClientMessage(Color.GreenYellow, "You have spawned a {0}", model);
     Console.WriteLine("Spawning a {0} {2} for {1}", model, player, (int) model);
     GtaVehicle vehicle = GtaVehicle.Create(model, player.Position + new Vector3(0, 0, 0.5f), player.Rotation.Z, -1,
         -1);
     player.PutInVehicle(vehicle);
 }
Exemple #21
0
 public static void TellCommand(GtaPlayer player, GtaPlayer to, string message)
 {
     to.SendClientMessage(Color.Green, "{0} tells you: {1}", player.Name, message);
 }
Exemple #22
0
 public static void VehicleOverloadCommand(GtaPlayer player)
 {
     player.SendClientMessage(
         "This is the 'vehicle' overload. 'v', 'vehicle spawn' and 'vehicle list' is also available.");
 }
Exemple #23
0
 public static void VehicleListCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Available vehicles:");
     player.SendClientMessage(Color.GreenYellow, string.Join(", ", typeof (VehicleModelType).GetEnumNames()));
 }
Exemple #24
0
 public static void TellCommand(GtaPlayer player, GtaPlayer to, string message)
 {
     to.SendClientMessage(Color.Green, "{0} tells you: {1}", player.Name, message);
 }
Exemple #25
0
 public static void PositionCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Position: {0}", player.Position);
 }
Exemple #26
0
        public static void TestCommand(GtaPlayer player, string word, int num, string text)
        {
            Console.WriteLine("Player: {0}, Word: {1}, Rest: {2}, Num: {3}", player, word, text, num);
            Console.WriteLine("Text written to console...");
            player.SendClientMessage(Color.Green, "Text written to console!");

            player.SendClientMessage(Color.Green, "Formattest {0} -- {1} ,, {2}", 123, "xyz", "::DD");
        }
Exemple #27
0
 public static void TestAdminOnlyCommandWithoutMessage(GtaPlayer player)
 {
     player.SendClientMessage("You are admin, congratz.");
 }
Exemple #28
0
 public static void VehicleOverloadCommand(GtaPlayer player)
 {
     player.SendClientMessage(
         "This is the 'vehicle' overload. 'v', 'vehicle spawn' and 'vehicle list' is also available.");
 }
Exemple #29
0
        /// <summary>
        ///     Runs the command.
        /// </summary>
        /// <param name="player">The player running the command.</param>
        /// <param name="args">The arguments the player entered.</param>
        /// <returns>
        ///     True when the command has been executed, False otherwise.
        /// </returns>
        public override bool RunCommand(GtaPlayer player, string args)
        {
            if (!HasPlayerPermissionForCommand(player))
            {
                if (PermissionCheck.Message == null)
                {
                    // If the message is null, we return false so samp will think that this method doesn't exists
                    // and will print the default message
                    return false;
                }

                player.SendClientMessage(PermissionCheck.Message);
                return true;
            }

            var arguments = new List<object>();

            if (Command.IsStatic) arguments.Add(player);

            for (int paramIndex = 0; paramIndex < Parameters.Length; paramIndex++)
            {
                ParameterInfo parameterInfo = _parameterInfos[paramIndex + (Command.IsStatic ? 1 : 0)];
                ParameterAttribute parameterAttribute = Parameters[paramIndex];

                args = args.Trim();

                /*
                 * Check for missing optional parameters. This is obviously allowed.
                 */
                if (args.Length == 0 && parameterAttribute.Optional)
                {
                    arguments.Add(parameterInfo.DefaultValue);
                    continue;
                }

                object argument;
                if (args.Length == 0 || !parameterAttribute.Check(ref args, out argument))
                {
                    if (UsageFormat != null)
                    {
                        player.SendClientMessage(UsageFormat(CommandPath, Parameters));
                        return true;
                    }

                    return false;
                }

                arguments.Add(argument);
            }

            object result = Command.Invoke(Command.IsStatic ? null : player, arguments.ToArray());

            return Command.ReturnType == typeof (void) || (bool) result;
        }
Exemple #30
0
 public static void VehicleListCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Available vehicles:");
     player.SendClientMessage(Color.GreenYellow, string.Join(", ", typeof(VehicleModelType).GetEnumNames()));
 }
Exemple #31
0
 public static void TestAdminOnlyCommandWithoutMessage(GtaPlayer player)
 {
     player.SendClientMessage("You are admin, congratz.");
 }
Exemple #32
0
 public static void PositionCommand(GtaPlayer player)
 {
     player.SendClientMessage(Color.Green, "Position: {0}", player.Position);
 }