Log in to reply
 

[Tutorial] Help Notification (Key or blips etc.) + 7 Contextual Code Ex./Snippets C# SHVDN3



  • Hello everyone,
    Here is a complete tutorial on "How to create your own Help notifications with Key bind or Blips" in C# / SHVDN3
    It show different key bind depending on what you are using & actually game state or (moving) Blips, Street, & more !
    I also added 7 different context of use for each 7 possibility, and so 7 example of use !
    So depending on your actual knowledge you may learn a lot more then only Help Notifications !
    It may be considered as code snippets, I tried to put as much knowledge as possible, I hope it's not too much !
    KeyBoard =
    KeyBoard
    Controller =
    Controller

    Each Notifications could show Blips, Key, Player/Ped & More !, Text may be Bold or Colored & More !
    (Full list = https://pastebin.com/nqNYWMSB)

    Care not Tested , AFAIK If you want to use moving Blips, or anything that requires constant update (Moving, or alive, & more) You could only use Easiest Way - Normal Way:2nd - Natives&Hard Way:2nd
    Precising those Informations will be appreciated !

    Both line #region & #endregion aren't used by the code, they are only useful for us coder, Here is an exemple of use,


    Summary

    It's almost always from easiest to hardest !

    • Easiest Way (Exemples: Display when the game & scripts are fully loaded !)
    • Normal Way
      • 1st : Show Help ONE/EACH tick. > Exemple Context : Dipslay when Player position is next to Shop position
      • 2nd : Show Help until its turned off by Same line > Exemple Context : Display when User press Key, With anti-Spam Securitybolded text
      • 3rd : Show Help until it's turned off by different line > Exemple Context : Display when User press Key, With Closing Timer
    • Hardest & Natives Way
      • 1st : Show Help ONE/EACH tick > Exemple Context : In cover, Health refill, with cost and display !
      • 2nd : Show Help until its turned off by Same line > Exemple Context : Simple random Dice Game, with Smart display !
      • 3rd : Show Help until it's turned off by different line > Exemple Context : Press F Joke, When player reach 90km/h = 25 M/s

    Easiest way (Thanks to @JohnFromGWN) =

    In your scripts you just have to call EACH Tick this function :

    Essential scripts with no exemples or context :

    GTA.UI.Screen.ShowHelpTextThisFrame("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop");//Here you put the text you want between " "
    

    To end obviously stop calling the function ;)

    Exemple Context : Display when the game & scripts are fully loaded !

    Here it will wait until game is loaded to just display help notification, then it will be closed by user pressing the key

    public class ModName : Script
    {
        public ModName()
        { 
            //...Your Method/Function...
            Tick += onTick;
        }
        void onTick(object sender, EventArgs e)
        {
             //...Your Method/Function...
             bool textSeen = false;  //This will be used to stop "Help" display
             if (Game.IsLoading == false && textSeen == false)     //Check loading state , & if text as been closed
             {
                 GTA.UI.Screen.ShowHelpTextThisFrame("~r~Game ~y~is ~g~Loaded ~w~! ~b~Press ~INPUT_CONTEXT~ ~w~to ~g~Close ");//Here you put the text you want between " "
             };          //Dont miss ";" after each if() {}; or if() {} else {};
             if (Game.IsControlJustPressed(GTA.Control.Context)) //If user press E or left then >
             { textSeen = true; }; //It put textSeen on true, so it stop display !, Take care of each ";"
        }
    }
    

    Normal Way (Thanks to @Jitnaught & @JustDancePC) =


    1st : Show Help ONE/EACH tick

    (Need to call on each display tick so !)
    [Arguments = Loop: false |Shape: 1 to 50]

    Essential scripts with no exemples or context :

    GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop",1,true,false);//Here you put the text you want between " "
    

    Exemple Context : Dipslay when Player position is next to Shop position

    Shop Position = x:-212 y:-1618 z:34
    It will display Help when player position is next / near to Shop position

    public class ModName : Script
    {
        public ModName()
        { 
            //...Your Method/Function...
            Tick += onTick;
        }
        void onTick(object sender, EventArgs e)
        {
             //...Your Method/Function...
             if (World.GetDistance(Game.Player.Character.Position, new Vector3(-212.4f, -1618f, 34.1f)) > 4f) //Distance Check 4f=4m radius around Vector3 Pos
             { 
                 GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop",1,true,false);//Here you put the text you want between " "
             };          //Dont miss ";" after each if or if else
        }
    }
    

    With this exemple it will stop displaying when player will move from the RADIUS (4m) around Vector3 location
    If you did any other way To end obviously stop calling the function ;) (Here if(World.GetDistance...) increase it just automatically stop calling !)


    2nd : Show Help until its turned off by Same line

    (Is turned OFF is the game/scripts reload) [Arguments = Loop: false |Shape: -1]

    Essential scripts with no exemples or context :

    GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", -1,true,false); //Here you put the text you want between " "
    

    Exemple Context : Display when User press Key, With anti-Spam Securitybolded text

    Here, For exemple, we will call when User press Input_Context, The key showed on picture, Keyboard:E Controller:Right

    public class ModName : Script
    {
        #region Initilization
        bool security = false;    //Here we initialize a security Boolean Value to false
        int timeCounter = -1; //Here using an init to -1 allow us to use this int from 0 to X without confusing with (Re)Initialization Value
        #endregion
        public ModName()
        { /*...Your Method/Function...*/ }
        #region OnTick
        void onTick(object sender, EventArgs e)          //You need to know one Tick +- = one ms
        {
            //...Your Method/Function...
            #region Control or Input
            if (Game.IsControlJustPressed(GTA.Control.Context) && Security == false)   //Here we get user input, and check security
            {
                 GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", -1,true,false); //Here you put the text you want between " "
                security = true; //Here, we activate security to avoid double input or lags (Only one key press each 1/5sec)
            };
            #endregion
            #region Security & Time Counter  
            if (security == true) 
            { 
                 if (timeCounter < 0) { timeCounter = 200; };                  //Here it is start point, so it start the time counter, 200 is a time in ms, So 0.2 sec or 1/5 sec
                 if (timeCounter > 0) { timeCounter--; };           //Here "--" is like timeCounter=timeCounter-1, So each ms it decrease -1
                 if (timeCounter == 0) { timeCounter = -1; security = false; }; //Here, when a really small time have passed, It reinitialize to default : the timeCounter(=-1) & the secuity Lock(false)
            }; // ";" always after if(){}; or if(){}else{};
            #endregion
        }
        #endregion
    }
    

    To clear the Help, User just press the key again ! If you did it another way, just call the exact same function again.


    3rd & harder : Show Help until it's turned off by different line

    (Keep open even if the game/scripts reload)
    [Arguments = Loop: true (then false) |Shape: 1 to 50]

    Essential scripts with no exemples or context :

    Start:
    GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", 1,true,true);  //Here you put the text you want between " "
    End:
    GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", 1,true,false);  //Same text, false instead of true
    

    Exemple Context : Display when User press Key, With Closing Timer

    Here, It will call when User press Input_Context, The key showed on picture, Keyboard:E Controller:Right )
    Then it will close after 10 sec (Instead of Natives:1st exemples, We will use a derived timeCounter to count time in sec instead of ms(=basic tick))

    public class ModName : Script
    {
        #region Initialization
        int timeReference = Game.GameTime + 1000;  //Initialization of time references, used to count in sec
        int secTimeCounter = -1;     //Here, initialization at -1 avoid confuse with the timer ends ! same as Natives:2nd exemples
        #endregion
        public ModName()
        { /*...Your Method/Function...*/ }
        #region OnTick
        void onTick(object sender, EventArgs e)          //You need to know one Tick +- = one ms
        {
            //...Your Method/Function...
            #region Control or Input
            if (Game.IsControlJustPressed(GTA.Control.Context))   //Here we get user input
            {
                 GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", 1,true,true);  //Here you put the text you want between " "
                 secTimeCounter = 10; //Here, we activate closing time counter (Here it's in sec, so 10 sec, if user re-press it restart time counter to 10sec, if you don't want, add Natives:1th example security)
            };
            #endregion
            #region Sec Time Counter  
            if (timeReference <= Game.GameTime)    //With this simple if & its last line, everything in will occur each sec or 1000ms
            {
                if (secTimeCounter > 0) { secTimeCounter--; }; //Each 1000ms, 1 sec pass & so decrease
                if (secTimeCounter = 0) 
                { 
                    secTimeCounter--; 
                    GTA.UI.Screen.ShowHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop", 1,true,false);  //Same text, false instead of true
                timeReference=Game.GameTime+1000 //With this simple line, each seconds or 1000ms, we add 1sec before next occurence
                }; //AS always, dont miss the ";" 
            }; //If an error show or if parts of the mods dont load my advice is to check each "if" from top to end !
            #endregion
        }
        #endregion
    }
    

    With this exemple it will stop displaying after 10sec
    If you did any other way To end call the function again with false instead of true for the last agruments !


    Harder way, In a learning & understanding way (or any other goal) =

    More Time & code needed for the exact same result, So it's useful only for helping working with native, as well as using method/function, well Explaining & Understanding all of this, may help people to understand how SHVDN is made & works, (And maybe contributing to improve/update or doing it their own). & Understanding HOW Natives Works (Which could be game Changer)

    I recommend creating a Method in the class ModName : Script
    Depending of how you wants to show the Help we will have different possibility = (From easiest to hardest)


    1st : Show Help ONE/EACH tick

    (Need to call on each display tick so !)
    [Arguments = Loop: 0 |Shape: 1 to 50]

    Essential scripts with no exemples or context :

    FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop");//Here you put the text you want between " "
    

    Exemple Context : In cover, Health refill, with cost and display !

    Display an help with a cost relative to player health when Player is low life, & in cover since at least 5sec ,
    Then , if player press the key & have the money, then it take money & refill health
    First, we start creating our method/function !

    public class ModName : Script
    {
        public ModName()
        {
        void FloatingHelpText(string text)
            {
                Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING"); //"STRING" Isn't important put what you wants !
                Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
                Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 1, 10); //Here the first agruments is always 0/  Second arguments is Loop: 0 or 1/ Third is Beep, always 1 (AFAIK)/ Fourth & last is Scale(aka duration): -1 to 50
            }
        }
    }
    

    Now we have our method, lets call it in our scripts, at EACH tick ! (Could be used everywhere)
    We will start converting tick/ms in Sec/1000tick/1000ms,
    We will need to count each second spend in cover,
    This counter will restart if player leaves cover,
    & when counter reach 5 we will display !
    NB: If you use SHVDN2 stop & use 3, no it's a joke even if 3 is better, just use UI.Notify instead of Notification.Show

    public class ModName : Script
    {
        #region Initilization
        int timeReference = Game.GameTime+1000; //Initialization of time references, used to count in sec
        int coverTimeCounter = 0; //Time spend in cover in sec
        int cost = 0;   //Used to calculate cost of health refill
        bool isReady = false; //Used to know if it's ok to refill player health when key pressed
        #endregion
        public ModName()
        { /*...Your Method/Function...*/ }
        #region OnTick
        void onTick(object sender, EventArgs e)          //You need to know one Tick +- = one ms
        {
            //...Your Method/Function...
            #region Sec Time Counter  
            if (timeReference <= Game.GameTime)    //With this simple if & its last line, everything in will occur each sec or 1000ms
            {
                if (Game.Player.Character.IsInCover == true) { coverTimeCounter++; } //When player is in cover, each sec it add +1, no ";" here because of next else
                else { coverTimeCounter=0; isReady = false; }; //Else restart timer !
                if (coverTimeCounter >= 5 && Game.Player.Character.Health <= 150f) //Check the time in cover and the health
                { 
                    cost = (300-Game.Player.Character.Health)*5; //Calculate Health refill Cost
                    FloatingHelpText("Press ~INPUT_CONTEXT~ to refill your health for "+cost+"~g~$");  //display help with cost !
                    isReady = true;    //Allow refill
                }        //Never any ";" before else
                else { isReady = false; }; //Reset, AS always, dont miss the ";" 
            };
            #endregion
            #region Get User Input
            if (Game.IsControlJustPressed(GTA.Control.Context) && isReady == true) 
            { 
                if (Game.Player.Character.Money >= cost) 
               { 
                    Game.Player.Character.Money -= cost;  //Here y -= x is like y = y-x
                    Game.Player.Character.Health = (cost/5)+Game.Player.Character.Health;  //Tricky calcul to get health value user paid for !
                    Notification.Show("Thanks for your purchase, Your now full Health !");  //Display, Above map (not help)
                    isReady = false; //Reset 
                }
                else { Notification.Show("You need more money ! It cost = " + cost + " $"); }; //Above map notif' if it not possible
                timeReference = Game.GameTime+1000 //With this simple line, each seconds or 1000ms, we add 1sec before next occurence
                }; //If an error show or if parts of the mods dont load my advice is to check each "if" from top to end !
            #endregion
        }; //each if need his ";" or "else" each need ";" or another "else" !
        #endregion
    }
    

    With this exemple it will stop displaying when player will move from the Vector3 location
    If you did any other way To end obviously stop calling the function ;) (Here when if(World.GetDistance...) increase it just automatically stop calling !)


    2nd : Show Help until its turned off by Same line

    (Is turned OFF is the game/scripts reload)
    [Arguments = Loop: 0 |Shape: -1]

    Essential scripts with no exemples or context :

    Function/Method: 
    void FloatingHelpText(string text)
            {
                Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING"); //"STRING" Isn't important put what you wants !
                Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
                Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 1, -1);  //Here the first arguments is always 0/ Second arguments is Loop: 0 or 1/ Third is Beep, always 1 (AFAIK)/ Fourth & last is Scale(aka duration): -1 to 50
            } 
    Display/Call:
    FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop");  //Here you put the text you want between " "
    

    Exemple Context : Simple random Dice Game, with Smart display !

    Next to the Casino diamond, Pos = x:924 y:47 z:81
    First let's build 2 Function/Method, a HelpText & a Randomizer

    public class ModName : Script
    {
        public ModName()
        {
        void FloatingHelpText(string text)  //HelpText function/method
            {
                Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING"); //"STRING" Isn't important put what you wants !
                Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
                Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 1, -1); //Here the first agruments is always 0/ Second arguments is Loop: 0 or 1/ Third is Beep, always 1 (AFAIK)/ Fourth & last is Scale(aka duration): -1 to 50
            } 
        void randomizer(int low,int high,out int var) { Random rnd = new Random(); var = rnd.Next(low, high); } //Randomizer function/method using Random().Next()
        }
    }
    

    Now we have our method, lets call it in our scripts, (Could be used everywhere)

    public class ModName : Script
    {
        #region Initialization
        Vector3 diceGamePosition = new Vector3(924f,47f,81f)
        int timeReference = Game.GameTime+1000; //Initialization of time references, used to count in sec
        bool isNear = false;     //Used to know if player is near
        bool isOpen = false;    //used to know if Help is actually  displayed
        bool gameLaunched = false;  //used to know when the dice game is launched or not
        bool resultDone = true;      //used to know when the dice game result is here or not
        int gameCounter = -1;        //used to count time before result
        int result = -1;          //used to know which result the dice gived us
        #endregion
        public ModName()
        { 
            /*...Your Method/Function...*/ 
            #region Blip Generation
            Blip diceGame = World.CreateBlip(diceGamePosition); //Create blip
            BlipCrate.Sprite = BlipSprite.Casino;   //Set image = icon =sprite
            BlipCrate.Color = BlipColor.GolfPlayer2; //set Colors
            BlipCrate.Name = "Dice Game";        //Set Name
            BlipCrate.IsShortRange = true;       
            #endregion
        }
        #region OnTick
        void onTick(object sender, EventArgs e)          //You need to know one Tick +- = one ms
        {
            //...Your Method/Function...
            #region Control or Input
            if (Game.IsControlJustPressed(GTA.Control.Context) && isNear == true)   //Here we get user input only if player is near dice game !
            {
                if (Game.Player.Character.Money>=25) //Check if player had enought money !
                {
                    Game.Player.Character.Money-=25; //take money
                    FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); //Stop Help display
                    Notification.Show("Thanks for your purchase, the result will take 3sec"); //Display Thanks message
                    gameLaunched = true; //Used to start counter ! Logics usage
                }
                else { Notification.Show("You need more money, at least 25$ !"); }; //else display fails message
            }; 
            #endregion
            #region Result 
            if(resultDone == false && Result > 0) //Check if result is needed
           {
               switch (result) //Here the most complicated part, For each result, this switch will go to associated case: 
               {
                   case 1: Game.Player.Character.Money+=100; Notification.Show("~p~Amazing ! You wins the Jackpot ! + 100$ ! 4 Free game more !"); FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); result = -1;  return;
                   case 2: Game.Player.Character.Money+=25; Notification.Show("~g~Nice ! You wins 25$ ! A Free game !"); resultDone = true; FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); result = -1;  return;
                   case 3: Notification.Show("~r~You didn't win anything ! Try again !"); resultDone = true; result = -1; FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); return;
                   case 4: Notification.Show("~r~You didn't win anything ! Try again !"); resultDone = true; result = -1;  FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); return;
                   case 5: Notification.Show("~r~You didn't win anything ! Try again !"); resultDone = true; result = -1;  FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); return;
                   case 6: Notification.Show("~r~You didn't win anything ! Try again !"); resultDone = true; result = -1;  FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); return;
               }   //return is needed at end of each case to get out of switch !
           }; 
    /* Each switch case do : - Give money when win - Display result message - Re-initialize result to -1 - Re-initialize  resultDone to true - Re-Display Help Notif' "Press ... to ..." */
            #endregion
            #region Sec Time Counter  
            if (timeReference <= Game.GameTime)    //With this simple if & its last line, everything in will occur each sec or 1000ms
            {
                #region Get Distance
                if (World.GetDistance(Game.Player.Character.Position, diceGamePosition) < 5f) { isNear = true; } //Here we change a bool depending on player proximity, It allows us to use our isNear instead of SHVDN World.GetDistance(Game.Player.Character.Position, diceGamePosition) < 5f
                else { isNear = false; }; //Then Make sure to have Dis-activator after, like this line
                #endregion
                #region Display & Clear Display
                if (isNear == true && isOpen == false && resultDone = true && gameLaunched = false) 
                { FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); isOpen = true;}; //When player is Near & Help is NOT open & Not waiting for game result or game starting !
                if (isNear == false && isOpen == true && resultDone = true && gameLaunched = false) 
                { ​FloatingHelpText("~b~Press ~INPUT_CONTEXT~ ~w~to ~y~start ~b~Dice ~g~Game ~w~! Cost is 25 $"); isOpen = false; };  //When player is NOT Near & Help is open & Not waiting for game result or game starting !
                #endregion
                #region Dice Game
                if (gameLaunched == true)  //If the game is launched, start the 3sec counter !
                { 
                    if (gameCounter > 0) {gameCounter--; }; //Main Counter
                    if (gameCounter == -1) { gameCounter = 3; }; //Start the Counter
                    if (gameCounter == 0) {gameCounter--; randomizer(0,7,out result); gameLaunched = false; resultDone = false; };
                 }; //End the Counter
                #endregion
                timeReference=Game.GameTime+1000 //With this simple line, each seconds or 1000ms, we add 1sec before next occurence
                }; //AS always, dont miss the ";" 
            }; //If an error show or if parts of the mods dont load my advice is to check each "if" from top to end !
            #endregion
        }
        #endregion
    }
    

    To clear the Help User just press the key again !


    3rd & harder : Show Help until it's turned off by different line

    (Keep open even if the game/scripts reload)
    [Arguments = Loop: 1 |Shape: 1 to 50]

    Essential scripts with no exemples or context :

    Method/Function:
    void FloatingHelpText(int loop, string text)
            {
                Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING"); //"STRING" Isn't important put what you wants !
                Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
                Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, loop, 1, 10); //Here the first arguments is always 0/ Second arguments is Loop: 0 or 1/ Third is Beep, always 1 (AFAIK)/ Fourth & last is Scale(aka duration): -1 to 50
           }
    Start:
    FloatingHelpText(1 , "~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop"); //Here you put the text you want between " "
    End:
    FloatingHelpText(0 , "~b~Press ~INPUT_CONTEXT~ ~w~to ~y~Open ~b~Car ~g~Shop"); //Same text, 0 instead of 1
    

    Exemple Context : Press F Joke, When player reach 90km/h = 25 M/s

    First let's build a Function/Method
    This one is a bit different, it had 2 arguments instead of 1, It allow us to change the "loop" value !

    public class ModName : Script
    {
        public ModName()
        {
        void FloatingHelpText(int loop, string text)
            {
                Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_HELP, "STRING");
                Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
                Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, loop, 1, 10); //Here the first agruments is always 0 / Second arguments is Loop: 0 or 1/ Third is Beep, always 1 (AFAIK) / Fourth & last is Scale(aka duration): -1 to 50
            }
        }
    }
    

    Now we have our method, lets call it in our scripts,

    public class ModName : Script
    {
        #region Initilization
        int timeReference = Game.GameTime + 1000;  //Initialization of time references, used to count in sec
        bool isHelpActivated = false; //Boolean to check if the help is on or not
        #endregion
        public ModName()
        { /*...Your Method/Function...*/  }
        #region OnTick
        void onTick(object sender, EventArgs e)          //You need to know one Tick +- = one ms
        {
            //...Your Method/Function...
            #region Sec Time Counter  
            if (timeReference <= Game.GameTime)    //With this simple if & its last line, everything in will occur each sec or 1000ms
            {
                if (Game.Player.Character.Speed >= 25f) 
                { FloatingHelpText(1,"~b~Press ~INPUT_VEH_EXIT~ ~w~to ~y~have ~b~LOTS ~w~of ~g~FUN !"); isHelpActivated = true ;} //no ";" after this if because of next else, When player reach 25m/s = 90km/h it display the text/joke
                else 
                { 
                    if (isHelpActivated == true) //Check if help is actually displayed, avoid closing already closed display
                    { 
                          FloatingHelpText(0,"~b~Press ~INPUT_VEH_EXIT~ ~w~to ~y~have ~b~LOTS ~w~of ~g~FUN !");
                          isHelpActivated = false; 
                    }; 
                }; //If not, stop the display
                timeReference = Game.GameTime+1000 //With this simple line, each seconds or 1000ms, we add 1sec before next occurence
                }; //AS always, dont miss the ";" 
            }; //If an error show or if parts of the mods dont load my advice is to check each "if" from top to end !
            #endregion
        }
        #endregion
    }
    

    With this exemple it will stop displaying if speed <25m/s or <90km/h
    If you did any other way To end call the function again with 0 instead of 1 !


    Conclusion & End

    Then it should work ! If not fell free to ask !
    If anyone need help it will be a pleasure for me,
    I'm not a robot, due to the size of this (those?) tutorial, Mistake are possible !
    Any constructive advice or unseen miss report will be appreciated
    Also if anyone have any suggestion/modifications to make the code better I'm open minded ;)
    I really hope it will help someone, has it took me several day to fully understand and find how to :P
    See you & have fun !



  • @Kangouroux6 Thanks for sharing your code.
    Another way to do this, a different application, is when reading the help from a text file.
    This is used with the ontick event and only SHVDN3

    GTA.UI.Screen.ShowHelpTextThisFrame(textString);
    where textString is the text being read, line by line, from a text file.

    With SHVDN2 you could assign a timer easily:
    UI.ShowHelpMessage(string message, int duration, bool sound)



  • How wait, you're right and it's much easier ! I forget this function was existing xD Thanks i'll edit a bit so :')



  • @Kangouroux6 Brother, I've been racking my brain for days to figure out how to do this. Thank you so much, you saved me!
    It never crossed my mind that it would be something so simple and quick to implement.



  • @Kangouroux6 I had never used your version so I took a look and experimented.

    If I call the function from a key bind with your version it just flashes quickly on screen and disappears.
    Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 1, 10);

    Instead I did this:
    Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_HELP, 0, 0, 1, -1);

    By changing the last argument (int shape) to -1 the message will stay on the screen. You can remove it by pressing the same key bind once more.

    If you want the help notification to remain constantly on the screen you can change the 2nd parameter, to 1 and it will loop.

    Also, in the native database, it says values for the int shape parameter can range from -1 to 50. Any idea what the values change? Made no difference for me, only -1 keeps the notification on screen.



  • @Niziul Thanks for this feedback, I really appreciate !

    @JohnFromGWN Yes it's the same for me, I'll do another edit to add those missed details, Thanks for investigating :P
    I wasn't aware of the effect of -1 in shape, for me it was useless arguments xD
    As i tried with value between 1 & 30 i didn't noticed any effect ! (I suppose there is video settings which allow or not shape modifications for multiple HUD "windows" but I'm not sure at all !)



  • @Kangouroux6 It's nice to see someone else trying to make sense of native functions with extremely limited documentation and sharing their code and findings.

    Scripting can be the most powerful and interesting part of modding but the barriers to entry are significant due to lack of support, it is basically non existent. If it was available im sure more gamers would participate.



  • @JohnFromGWN That so true ! This is why I'm trying to share those (Really) hardly acquired knowledge ! But I have a lot of pleasure doing it too :P Thanks !



  • @JohnFromGWN I attempted to figure out scripting but all the code doesn't make much sense to me. Seen some ideas posted around the internet that would be good mods (I think so) and wanted to try making them but just don't get the code at all.



  • No need to make a function, SHVDN already includes it: GTA.UI.Screen.ShowHelpText(helpText, duration, beep, looped)



  • IMO the largest barrier for people getting into scripting is just the programming language aspect. Just like any language, it takes time and effort to learn a programming language. Trying to make scripts before you understand the language is like trying to write an essay in Spanish when you only know English.

    For anybody trying to get into scripting: start out by watching/reading tutorials on the programming language you'll be using before making scripts. Maybe read a book on the programming language. Google the little things you don't understand. Make some very basic apps; get a handle on the language. Then make some very basic scripts, don't start with the mod you want to make just yet (unless it's very basic). If you can't figure something out, make a post on the forum, or ask on the Discord!

    As an example of how long it could take: my first mod, which was very basic, took around a week of learning and programming. I could probably make that mod in 20 minutes nowadays.



  • @Jitnaught That function does not appear in SHVDN3?

    Update: the GTA.UI.Screen.ShowHelpText(helpText, duration, beep, looped) is not available or no longer available in DN3, at least based on Visual Studio.



  • @Jitnaught I'll agree with you up to a point. The Spanish analogy is an excellent one and appropriate for myself given it is a language I'm trying to learn.

    However I don't have any aspirations to ever write an essay in Spanish. My objectives are to be able to engage in a conversation with a native speaker and also to be able to watch a TV show like the Money Heist in Spanish without English subtitles.

    So now to get back to scripting. Personally I would love to reach a programmer's level but honestly I will never write a script mod, all I will write are snippets of code which so far have allowed me to do exactly what I wanted to do.

    About 7 months ago I didn't know the difference between a task, a scenario, and an animation. Today I can spawn entities fully customized, I can swap player between infinite number of peds with 100% matching ped variations such as outfits. I can easily create companion and passenger scripts, run speech, play audio, animate, run scenarios, and task sequences. I can move the camera and attach it to peds or vehicles. I know how to loop and I'm comfortable with conditionals, and all of this with just a few lines of code. My proudest accomplishment is creating a mod menu with LemonUI that allows me to do much of what Menyoo does but with a much higher degree of personalization.

    Now to get back to our analogy. I can find thousands of references for Spanish as well as use google translate. I can also find those references for C# but that's where the comparisons end. Unless I have documentation on Native functions and/or clear examples/source code (same goes for SHVDN functions) I can't really progress at the speed I want to. The barriers to progress are tenfold compared to learning Spanish. That leaves me with trial and error.

    As for help. You're the only expert here who helps with scripting. I remember being clearly turned off by Youtube tutorials when an arrogant Youtuber said, and I paraphrase, "I'm not going to teach you how do this because it's one of my trade secrets". Well I figured it out by myself and it was far from rocket science. So FY Youtube.

    And one last comment. I assemble my own computers and know Windows pretty much inside out. When I help someone here with installation issues I don't expect them to have that same level of knowledge of software that I do just as @a63nt-5m1th doesn't expect the people he helps have his incredbile knowledge of the GTA5 file system. The idea is to give them just what they need to fix their problems - at least at a minimum. If there was a book called C# for GTA5 modding I would read it from cover to cover. And yes, I've watched a few C# tutorials but invariably they deal in a large part with topics of little relevance for a part-timer/hobbyist like myself.

    As for Discord servers, I've been on the LemonUI server 3 times asking for help out of desperation and each time I left realizing only one thing, knowing what I didn't know - in other words, realizing the extent of my knowledge gaps and that I would need to solve issues on my own again.

    Ironically I was able to converse in Spanish, well at least for greetings, with Lemon who is from Chile.



  • @JohnFromGWN said in [Tutorial] Help Notification (Key or blips etc.) C# SHVDN3:

    @Jitnaught That function does not appear in SHVDN3?

    Update: the GTA.UI.Screen.ShowHelpText(helpText, duration, beep, looped) is not available or no longer available in DN3, at least based on Visual Studio.

    The function was added in version 3.2.0. https://github.com/crosire/scripthookvdotnet/commit/8ed4294b4a7906e5ffb7e71020aaa11c3398de27?diff=split#diff-ff318bcf4266a74d017ab8bf10ce3ffa0fa7f0398799d5b0a0f2196260e48a11R295



  • @Jitnaught Thanks. Had not checked for updates since September.



  • @Kangouroux6 I mean, it's completely pointless doing it that way if you are using ScriptHookVDotNet. But this is a good tutorial for people that wanna get into using ScriptHookV :thumbsup:



  • @JustDancePC There is nothing pointless about his tutorial. On the contrary, he is clearly demonstrating different ways of displaying help text, with the degree of difficulty, using both native functions and shvdn functions, neither of which are properly documented. These snippets of code are very useful to new modders and clarify what certain natives do and in this case that 3 of them need to be used together and sequentially, something which isn't obvious.

    @Kangouroux6 Thank you for an excellent post and please continue. We need more of thèse quick, easy to follow and useful tutorials rather than the irrelevant outdated crap available on youtube, many of which force you to try and recreate the code from the screen in fuzzy 720P instead of providing a pastebin.

    I gave up on youtube long ago as i mentioned above.



  • @JohnFromGWN That's exactly what i said, bruh. I said it's pointless displaying help texts using natives if you're using C# (and the title says it's a tutorial for C#), since SHVDN already has wrappers for these functions. But it's useful if you use SHV (C++), because you HAVE to use the natives.



  • @JustDancePC Nothing wrong and probably more efficient to work with natives and they are 100% compatible with C#. Only use SHVDN when I can't find a native equivalent. To each his own, right?



  • @JohnFromGWN Nothing wrong with using natives, you're right, even some stuff is done better using natives. But in this context, it's just a waste of time, but as you said, to each their own.



  • @JohnFromGWN said in [Tutorial] Help Notification (Key or blips etc.) C# SHVDN3:

    probably more efficient to work with natives

    Same amount of efficiency in terms of "run time". Less efficient in terms of "dev time".

    SHVDN's functions use Function.Call as well. Screen.ShowHelpText is nearly identical to Kangouroux6's function. The only differences are that the inputType parameter is "CELL_EMAIL_BCON" instead of "STRING" (I'm not aware of the effect this has), and it allows longer strings to be used. Efficiency is essentially identical.

    So as JustDancePC said, you can certainly go the manual native calling route, but it really is just a waste of time figuring out how to use the natives when SHVDN has already figured it out for you. Plus it's just extra bloat in your code. If you want to know if a native is already implemented in SHVDN, just search for the native in its GitHub repo.



  • @Jitnaught Just to clarify I agree with both of you that using 1 line of code instead of 3 is preferable. My comments were with respect to the use of natives vs shvdn functions. If I look at my own simple code, the majority of the natives I use are single line.

    In fact other than task sequences and modkits, I seldom myself have natives or shvdn functions that are multi line, for lack of a better term.



  • Hello. What i am doing wrong? My code not working. I want to see the message when click on num5. https://i.imgur.com/qLEZYmM.png



  • @sneakybeaky18 the function you chose refers to this frame which means it is used with ontick.

    Or just use GTA.UI.Screen.ShowHelpText(helpText, duration, beep, looped)



  • @JohnFromGWN said in [Tutorial] Help Notification (Key or blips etc.) C# SHVDN3:

    ShowHelpText

    Do you know how can i log any info in console? Or in text on game screen? I want to make neural network and making data collector and to debug it i need to see info on my screen or in console. I dont find any methods :( only UI.Notify and this on right screen notification.


Log in to reply
 

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