Quantcast

Jump to content

» «
Photo

[.Net][C#]Possible text displaying functions?

8 replies to this topic
Tsproggy
  • Tsproggy

    Basement Dweller

  • Members
  • Joined: 29 Oct 2011

#1

Posted 31 December 2012 - 11:02 PM Edited by Tsproggy, 01 January 2013 - 03:07 AM.

Hello, I've been searching through the pages of the forum and can't seem to find a topic on displaying any text to the player's screen. I've tried using like.. 3 text displaying functions in the .Net Scripthook but have only been successful in displaying text to the in game console. I've heard that in order to have text display in the top left in a black box you need to edit GTA IV's strings which are in a specific file, I don't really want to do that. I would rather have it be something quick, like maybe a multiplayer message in singleplayer if possible, maybe even make an invisible form with some text in it if I have to.

Are there some functions I'm missing that maybe you guys could direct me to so that I can display some quick text to my player without having to look at my console screen? I wouldn't mind it so much if it didn't do things like stop my car completely just to look etc.

UPDATE:
Nevermind, I thought the Game.DisplayText("Text") function didn't work but turns out it does just fine.

perkins
  • perkins

    Player Hater

  • Members
  • Joined: 30 Dec 2012

#2

Posted 01 January 2013 - 05:27 AM

When '1' is pressed, displays "Happy New Years" for 2 seconds on bottom center of screen.

CODE

private void msg(string message, Int32 time)
{
   GTA.Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", message, time, 1);
}

private void BasicKeyExample_KeyDown(object sender, GTA.KeyEventArgs e)
{
    if (e.Key == Keys.D1)
    {
        msg("Happy New Years", 2000);
    }
}

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#3

Posted 07 January 2013 - 04:56 PM

QUOTE (perkins @ Tuesday, Jan 1 2013, 05:27)
When '1' is pressed, displays "Happy New Years" for 2 seconds on bottom center of screen.

CODE

private void msg(string message, Int32 time)
{
   GTA.Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", message, time, 1);
}

private void BasicKeyExample_KeyDown(object sender, GTA.KeyEventArgs e)
{
    if (e.Key == Keys.D1)
    {
        msg("Happy New Years", 2000);
    }
}

msg("~y Happy New Years", 2000); - shows tet in yellow
msg("~r Happy New Years", 2000); - shows text in red

and so on... ~[first letter of color name]

julionib
  • julionib

    Coder

  • Members
  • Joined: 13 Sep 2012
  • Brazil

#4

Posted 17 January 2013 - 06:08 PM

QUOTE
msg("~r Happy New Years", 2000); - shows text in red


nice, this one its new for me, thx

hardsty1e
  • hardsty1e

    GLITCHED

  • Members
  • Joined: 02 May 2009
  • None

#5

Posted 18 January 2013 - 05:18 PM Edited by hardsty1e, 18 January 2013 - 05:34 PM.

if you wanted to style up your text msg more by adding icons to text messages like

msg("~r~ Press user posted image or [F] for Flares ~w~", 2000);

~PAD_A~ - user posted image

~INPUT_F~ - [F] cant find image but shows a boxed F

~INPUT_MELEE_KICK~ - [Q] no image

more at "https://sites.google...my/x-gxt-editor"

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#6

Posted 05 May 2013 - 06:06 PM

I've just noticed ~INPUT_FRONTEND_LB~ shows a boxed E or the Pad LB button, depending on the input your using. It changes immediately when you switch inputs.

I am assuming all ~INPUT_FRONTEND... will do the same for the correspondent keys, but I haven't tested.

In case someone finds it useful.

pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#7

Posted 14 July 2013 - 06:47 AM Edited by pedro2555, 14 July 2013 - 07:51 AM.

Finally managed to display text in the upper left corner in that black box.

No native way to do it, nor even with DoNetScripthook only. It's a function available with AdvancedHook.dll.

A rude C# script :

CODE

using AdvancedHookManaged;
using GTA;

public class TestScript : Script
{
   public TestScript()
   {
       AGame.PrintText("The quick brown fox jumps over the lazy dog.");
       // or AGame.PrintTextForever("The quick brown fox jumps over the lazy dog.");
   }
}

nordi
  • nordi

    Player Hater

  • Members
  • Joined: 17 Mar 2014
  • France

#8

Posted 24 March 2014 - 06:40 PM Edited by nordi, 24 March 2014 - 06:42 PM.

 



msg("~y Happy New Years", 2000); - shows tet in yellow
msg("~r Happy New Years", 2000); - shows text in red

and so on... ~[first letter of color name]

 

 

 

For some reason, it do not work for me:

string Text = "My choice: ~r~ " +choice + " \n";
e.Graphics.DrawText(Text, Game.Resolution.Width, Game.Resolution.Height, Color.White);

it display: My choice: ~r~  MERIT.

 

EDIT: I also tried with "string Text = "My choice: ~r " +choice + " \n";"  but still not working.


pedro2555
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal

#9

Posted 24 March 2014 - 07:49 PM

it only works with native GTA IV functions, which DrawText isn't





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users