Jump to content

Simple Speedometer help


Recommended Posts

Hi folks,

I am starting to learn to write scripts for Rage and am struggling as a beginner. It is a little bit intimidating just to print a Hello, World text.

 

I mean, I have figured out how to use Game.DisplayNotification, Game.DisplayHelp, etc, but I am trying to figure out how to draw text to the screen.

 

For my first script, I want to write a simple speedometer, with nothing fancy that just displays my player's current vehicle, with no other features. Here's my code:

I am able to load the plugin into Rage, but my speedometer handle isn't being called at all.

 

Attached is my code:

 

public static void Main()
        {
            GameFiber.StartNew(delegate
            {
                if(Game.LocalPlayer.Character.IsInAnyVehicle(false))
                {
                    Game.FrameRender += Speedometer;
                }
                while (true)
                {
                        GameFiber.Yield();
                }
            });
            
        }

        private static void Speedometer(object sender, GraphicsEventArgs e)
        {
                Ped playerPed = Game.LocalPlayer.Character;
                Game.LogTrivial("Speedometer is being called.");
                Vehicle vehicle = playerPed.CurrentVehicle;

                Rectangle drawRect = new Rectangle(1, 250, 230, 117);
                e.Graphics.DrawRectangle(drawRect, Color.FromArgb(200, Color.Black));
                e.Graphics.DrawText(vehicle.Speed.ToString(), "Arial Bold", 20.0f, new PointF(0f, 0f), Color.White, drawRect);
            
        }

I have looked at the Rage Plugin hook documentation, but it does not really explain much on Drawing text. I have watched Albo1125's videos on C#, and have also looked at his source code on git hub for days, but I still have no idea what I'm doing wrong.

 

Any help is much appreciated. Also will appreciate better places to learn more about Rage development.

 

Thanks!!

Edited by The Big House
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...