bhavinbhai2707 Posted May 23, 2016 Share Posted May 23, 2016 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 More sharing options...
mockba.the.borg Posted May 23, 2016 Share Posted May 23, 2016 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. bhavinbhai2707 1 Link to comment Share on other sites More sharing options...
bhavinbhai2707 Posted May 23, 2016 Author Share Posted May 23, 2016 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 More sharing options...
mockba.the.borg Posted May 23, 2016 Share Posted May 23, 2016 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. bhavinbhai2707 1 Link to comment Share on other sites More sharing options...
bhavinbhai2707 Posted May 23, 2016 Author Share Posted May 23, 2016 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 mockba.the.borg 1 Link to comment Share on other sites More sharing options...
mockba.the.borg Posted May 24, 2016 Share Posted May 24, 2016 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 More sharing options...
bhavinbhai2707 Posted May 24, 2016 Author Share Posted May 24, 2016 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 mockba.the.borg 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now