Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

GTA.UI.Screen.ShowSubtitle Not Working


josiewales

Recommended Posts

josiewales

I am trying to get some text to display on screen.
When I try this it works:
GTA.UI.Notify("Please enter a vehicle.");
 

But when I try this:

GTA.UI.Screen.ShowSubtitle("Test");

I get the error "GTA.UI does not contain a definition for screen".
 

I am using scripthookvdotnet2.dll and scripthookvdotnet3.dll together in the GTAV folder. If I take out either one I get errors when I reload my code.
I have also tried this with and without these two items but it makes no difference:
using GTA.UI;
using NativeUI;


Any idea ?

 

Link to post
Share on other sites
DuncanMac
Posted (edited)

Use one or the other, not both at the same time. If you're just starting out, use 3 as 2 may get phased out. You can keep both in your GTA 5 folder, but don't reference both in your code.

UI.ShowSubtitle("Show message for x seconds",4000); for donet 2
GTA.UI.Screen.ShowSubtitle("Show message for x seconds",4000);  for dotnet 3

Edited by DuncanMac
Link to post
Share on other sites
josiewales

Hi @DuncanMac

 

In relation to "GTA.UI.Screen.ShowSubtitle"

If I include or omit 'using GTA.UI' I get the error:

'UI does not contain a definition for screen'.

 

In Relation to "UI.ShowSubtitle"

If I include or omit 'using GTA.UI' I get the error:
UI does not exist in the current context.

 

GTA.UI.Notify works but is very laggy.

I should also point out that my code is going into the scripts folder as a .cs file and not as a .dll.

These are all the items that I have listed as using at the start.
'Using NativeUI' is not accepted so I don't use that one as it is not an option for me.

using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GTA;
using GTA.Math;
//using GTA.UI;
using GTA.Native;
//using NativeUI;
using System.Windows.Forms;
using System.Threading;
using System.Drawing;

 

Link to post
Share on other sites
DuncanMac
Posted (edited)

Check your references and syntax carefully. If you want GTA.UI, you should have donet 3 and ONLY donet 3 in your references.

 

If you are using SHVDN 3:

GTA.UI.Screen.ShowSubtitle("Text", 5000); //for a 5 second display

above line will not work with SHVDN 2 and don't put both references in the same script.

and GTA.UI is only for SHVDN 3

 

If you are using SHVDN 2:

UI.ShowSubtitle("Text", 5000)

 

P.S. I doubt you need all the references you have above? If you don't look at the Visual Studio (if that's what you're using) and you will see references in gray font when not in use.

 

Edit: I just saw you wrote that you are using a .cs file - that may cause issues, but not that error.

Although some "experts" say that's ok, that SH will compile, my experience is that this isn't the case.

It is better to compile yourself. I have scripts in .cs that do nothing, no error messages, unless compiled as .dll.

You can configure Visual Studio to compile dll directly to your scripts folder.

 

Edited by DuncanMac
Link to post
Share on other sites

.cs files in the scripts folder work fine. You'll see compilation issues in the log file, and if it compiles successfully you can also see the script being started (in the log).


If you want to show subtitles, your game should have subtitles enabled. Otherwise they simply do not show.

This also applies to users of your script - they should enable subtitles to see them. However, it's better to avoid them for things you always want to have shown, and use things like the help text or notification instead.

Link to post
Share on other sites
josiewales

@ikt thank you. I didn’t know about having to enable subtitles. The only reason I was using subtitles was to get an idea of whether a dynamic variable I was referencing from another dll file was updating... so kind of using it like a console because I find the regular cmd console takes up too much screen space when testing.

Link to post
Share on other sites

This is just a personal suggestion, but I like just printing/showing text onscreen. This is the method I use:

 

        public static void ShowText(float x, float y, string text, float size = 0.2f)
        {
            Function.Call(Hash.SET_TEXT_FONT, 0);
            Function.Call(Hash.SET_TEXT_SCALE, size, size);
            Function.Call(Hash.SET_TEXT_COLOUR, 255, 0, 0, 255);
            Function.Call(Hash.SET_TEXT_WRAP, 0.0, 1.0);
            Function.Call(Hash.SET_TEXT_CENTRE, 0);
            Function.Call(Hash.SET_TEXT_OUTLINE, true);
            Function.Call(Hash.BEGIN_TEXT_COMMAND_DISPLAY_TEXT, "CELL_EMAIL_BCON");
            Function.Call(Hash.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME, text);
            Function.Call(Hash.END_TEXT_COMMAND_DISPLAY_TEXT, x, y);
        }


(afaik this was for SHVDNv2, so might need some small adjustments for SHVDNv3)

Link to post
Share on other sites
DuncanMac
On 5/28/2021 at 2:21 PM, ikt said:

.cs files in the scripts folder work fine. You'll see compilation issues in the log file, and if it compiles successfully you can also see the script being started (in the log).I

 

Yes, they do work fine. But as I wrote before, I had at least one script, as .cs file, in the scripts folder, that did nothing until it was compiled. Don't recall what references were being used but I think it was for reading an xml file into the script.

And of course, if you have your script over several tabs in Visual Studio then you do need to compile. I guess the .cs files are not always perfectly compiled at run time or it was just bad luck - I only tried it once before compiling it.

Link to post
Share on other sites
DuncanMac
Posted (edited)
On 5/19/2021 at 12:36 PM, josiewales said:

I am trying to get some text to display on screen.
When I try this it works:
GTA.UI.Notify("Please enter a vehicle.");
 

But when I try this:

GTA.UI.Screen.ShowSubtitle("Test");

I get the error "GTA.UI does not contain a definition for screen".
 

 

 

 

I was looking at your code and two things came to mind. If GTA.UI.Notify worked then GTA.UI.Screen.ShowSubtitle should have worked as well - with dotnet3 only in your references and GTA.UI in your using statements. I also noticed you didn't specify the time argument, consequently i doubt anything would appear.

As for the error "GTA.UI does not contain a defintion for screen", if you were using dotnet3 and had using GTA.UI;, then you likely had that line of code outside the function brace } ??

 

Edited by DuncanMac
Link to post
Share on other sites
josiewales

Thanks for that - I had just presumed that if “Using xxx” was put at the very start it would apply to the entire code and wouldn’t need to be put inside an individual function. 

Link to post
Share on other sites
DuncanMac
Posted (edited)
1 hour ago, josiewales said:

Thanks for that - I had just presumed that if “Using xxx” was put at the very start it would apply to the entire code and wouldn’t need to be put inside an individual function. 

No, you are correct. The Using statement only needs to appear once in your code. Sorry I guess my comments weren't clear. Bottom line, did you get the show subtitles to work?

I'm also curious, how did you get an error message when you're not using a compiler. From the log file?

Edited by DuncanMac
Link to post
Share on other sites
josiewales

Its working as GTA.UI.Screen.ShowSubtitle("Agression On" + JC_Cadence);...not using any timer...no error....but its compiled within a .dll not a .cs so you were right all along.....many thanks!
 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.