Log in to reply
 

C# Problem with ShowHelpMessage function



  • I'm making a mod that imports the new weapon wheel features from GTA Online.

    https://www.gta5-mods.com/scripts/extended-weapon-wheel-snacks-and-armor-as-in-gta-online

    I want to display the same help message with the UI.ShowHelpMessage function, but the text doesn't fit all the way in and gets cut off somewhere in the middle.

    UI.ShowHelpMessage("Press ~INPUT_DROP_AMMO~ to drop ammo.~n~Press ~INPUT_DROP_WEAPON~ to drop weapon.~n~Press ~INPUT_EAT_SNACK~ to eat a snack.~n~Press ~INPUT_USE_ARMOR~ to use armor.");

    Result

    alt text

    What am I doing wrong? How can I display a large help message?



  • @andre500 said in C# Problem with ShowHelpMessage function:

    What am I doing wrong? How can I display a large help message?

    I don't know what you're doing wrong because i"m not a programmer, so you'll have to wait for the experts. What I can tell you is that you are doing something wrong because I can get a larger message without issue. However I'm loading my message from a script which reads a text file. This allows me to reload the text or edit it rather than hard code it. Your syntax looks fine but....problem is possibly with INPUT_EAT_SNACK? Try replacing it temporarily with INPUT_DROP_AMMO and its code.

    so let's see~n~how much text~n~we can put in this box~n~before it starts to truncate it~n~and then we get pissed off~n~because the message doesn't appear in its entirety.

    alt text



  • @JohnFromGWN What script are you using? Is it open source? I'd like to see how it works.

    The problem is definitely not INPUT_EAT_SNACK. I used that tag in my mod, which is already published. It works just fine.



  • @andre500 lol. I don't use any mod scripts. I write my own even though i'm not a programmer. But you should be able to resolve your issue. The fact that the last line is the issue is why i suggested the SNACK line.

    
    
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using GTA;
    using GTA.Math;
    using GTA.Native;
    using System.Media;
    
    namespace TextDrawing
    {
        public class TextDraw : Script
        {
    
            string[] lines;   // The lines of the text file
            int index = 0; // The index of the next line to read
            string textString;
    
            public TextDraw()
            {
                Tick += onTick;
                Interval = 0;
                KeyDown += Basics_KeyDown;
                
                //    lines = System.IO.File.ReadAllLines(@"C:\Users\J2020\test.txt");  // Read the file here
                lines = System.IO.File.ReadAllLines(@"P:\SteamLibrary\steamapps\common\Grand Theft Auto V\mods\name.txt");  // Read the file here
            }
    
            private void onTick(object sender, EventArgs e)
            {
          
                if (0 == lines.Length || Game.IsLoading) return;
                DrawText();
    
                
            }
    
            private void DrawText()
            {
                var pos = new Point(250, 300);
                string textString = lines[index];
                var Text4Screen = new GTA.UI.TextElement(textString, pos, 0.45f, Color.White, GTA.UI.Font.ChaletLondon, GTA.UI.Alignment.Left, true, false, 400); //SIZE IS THIRD PARAMETER, LAST IS THE WIDTH BEFORE IT WRAPS
                Text4Screen.Enabled = true;
            
                
                //    Text4Screen.Draw(); //this is to show white text in center of screen
    
               GTA.UI.Screen.ShowHelpTextThisFrame(textString); //top left
            }
    
          
    
            private void Basics_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.PageDown) // next 
                { if (index < lines.Length - 1) index++;}
    
                if (e.KeyCode == Keys.PageUp) //  previous
                { if (index > 0) index--; }
    
                              
            }
        }
    }


  • Thank you. Your code uses the DrawText() function, which imitates ShowHelpMessage. With its help all the text is placed.

    I will use it


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.