DrawRectangle

From GT-MP
Jump to: navigation, search
DrawRectangle
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

Will draw a rectangle on the screen for one frame tick. Has to be used on onUpdate if you want to make it reappear all the time.


Dialog-warning.png NOTE: On some resolutions, creating rectangles with 1 pixels will not be displayed. Use 2 pixels if you wish to create "lines".

Syntax

In Javascript
Client-Side Function

API.drawRectangle(double xPos, double yPos, double wSize, double hSize, int r, int g, int b, int alpha);

Required Arguments

  • xPos: parameter input should be in double type.
  • yPos: parameter input should be in double type.
  • wSize: parameter input should be in double type.
  • hSize: parameter input should be in double type.
  • r: parameter input should be in int type.
  • g: parameter input should be in int type.
  • b: parameter input should be in int type.
  • alpha: parameter input should be in int type.

Usage example(s)

This will create a black transparent rectangle in the middle of your screen, note the calculations to get it centered onto the screen that will work for every resolution.

In Javascript
Client-Side Function

var rectEnabled = true;
var height = 500;
var width = 300;

API.onUpdate.connect(function () {
	if (rectEnabled) {
		var res = API.getScreenResolutionMaintainRatio();
		API.drawRectangle((res.Width / 2) - (width / 2), (res.Height / 2) - (height / 2), width, height, 0, 0, 0, 200);
	}
});

References