Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Grand Theft Auto Series

      1. Bugs*
      2. 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. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. 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. Red Dead Redemption 2

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

    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

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

UI notification at different places on screen


bhavinbhai2707
 Share

Recommended Posts

bhavinbhai2707

How to display notification on different places on screen like on top right corner or top left corner etc. . .plsss suggest me ;)

Link to comment
Share on other sites

mockba.the.borg

Hi bhavinbhai2707,

 

Actually, the "DRAW_TEXT" native takes a x, y position as an input. So you can draw text anywhere on the screen.

Keep in mind that x, y accept floating point values from 0 to 1, not screen pixels. So, middle of the screen would be .5.

You will need to play with the x and y values to achieve the position you want.

Here's a Lua function I wrote to place text on the screen, as an example only.

 

-- Draws a text onscreen with the option to have it blink
function ui.DrawTextUI(text, x, y, font, scale, color, blink)
font = font or FontChaletComprimeCologne
scale = scale or .5
color = color or {r=255, g=255, b=255, a=255}
local draw = not blink
if math.floor(game.GetSeconds()/10)%2 == 0 or draw then
natives.UI.SET_TEXT_FONT(font);
natives.UI.SET_TEXT_SCALE(0.0, scale);
natives.UI.SET_TEXT_COLOUR(color.r, color.g, color.b, color.a);
natives.UI.SET_TEXT_CENTRE(false);
natives.UI.SET_TEXT_OUTLINE();
natives.UI._SET_TEXT_ENTRY("STRING");
natives.UI.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(string.format("%s",text));
natives.UI._DRAW_TEXT(x, y);
end
end
Hope it helps.
Cheers,
Mockba.
  • Like 1
Link to comment
Share on other sites

bhavinbhai2707

 

Hi bhavinbhai2707,

 

Actually, the "DRAW_TEXT" native takes a x, y position as an input. So you can draw text anywhere on the screen.

Keep in mind that x, y accept floating point values from 0 to 1, not screen pixels. So, middle of the screen would be .5.

You will need to play with the x and y values to achieve the position you want.

Here's a Lua function I wrote to place text on the screen, as an example only.

 

-- Draws a text onscreen with the option to have it blink
function ui.DrawTextUI(text, x, y, font, scale, color, blink)
font = font or FontChaletComprimeCologne
scale = scale or .5
color = color or {r=255, g=255, b=255, a=255}
local draw = not blink
if math.floor(game.GetSeconds()/10)%2 == 0 or draw then
natives.UI.SET_TEXT_FONT(font);
natives.UI.SET_TEXT_SCALE(0.0, scale);
natives.UI.SET_TEXT_COLOUR(color.r, color.g, color.b, color.a);
natives.UI.SET_TEXT_CENTRE(false);
natives.UI.SET_TEXT_OUTLINE();
natives.UI._SET_TEXT_ENTRY("STRING");
natives.UI.ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(string.format("%s",text));
natives.UI._DRAW_TEXT(x, y);
end
end
Hope it helps.
Cheers,
Mockba.

 

Can you please show an example on how to do it plssss :) and how do i get x and y. . . . and what is blink over here ;) please suggest me

Link to comment
Share on other sites

mockba.the.borg

Hi bhavinbhai2707,

 

That is the Lua example right there. Unfortunately I don't have an example on another language to show.

To make the text blink I just check the game seconds and draw the text only if the second is even number. So if you set "blink" to "true" the text will blink.

x and y, as I said before, are not based on the screen resolution, but are in fact float numbers between 0 and 1 which represent a position in the screen.

To get x and y is up to your decision ... x=0 is the very left of the screen, x=1 is the very right of the screen.

What language do you usually code on?

 

Cheers,

Mockba.

 

  • Like 1
Link to comment
Share on other sites

bhavinbhai2707

Hi bhavinbhai2707,

 

That is the Lua example right there. Unfortunately I don't have an example on another language to show.

To make the text blink I just check the game seconds and draw the text only if the second is even number. So if you set "blink" to "true" the text will blink.

x and y, as I said before, are not based on the screen resolution, but are in fact float numbers between 0 and 1 which represent a position in the screen.

To get x and y is up to your decision ... x=0 is the very left of the screen, x=1 is the very right of the screen.

What language do you usually code on?

 

Cheers,

Mockba.

 

ohhhh X and Y i get it now. . . I am in my final year of school and learning c++ but i learned c# to make mods for GTA V because i heard its easier i am making my mod in c# language ;) . . . it would be great if u gave example in c# bot noways i am able to understand with the above code so thank you very much for the help :)

  • Like 1
Link to comment
Share on other sites

mockba.the.borg

Ok, good luck with your mod.

Unfortunately I have no examples in C# I could share, but I am sure you will find a lot online.

 

Cheers,

Mockba.

Link to comment
Share on other sites

bhavinbhai2707

Ok, good luck with your mod.

Unfortunately I have no examples in C# I could share, but I am sure you will find a lot online.

 

Cheers,

Mockba.

No problem man. . . .although i am almost there with it so thanxx ;)

  • Like 1
Link to comment
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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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