💾Persistent Records & Tablet

How to set up Pro Laser 4 tablet.

Introduction

By default, Pro Laser 4 will store the last 100 clocks to the player's machine, which will be loaded on player join.

The section below describes a centralized database for tracking clocks server side.

Dependencies

oxmysql - SQL interface resource. Alternatively you can modify sv_lidar.lua if you use another resource.

Documentation for oxmysql

Setup Pro Laser 4 Database Table

If you do not have an existing database you'd like to use, you can create one, see example below. Notice: this must be the same database you connect to in your server.cfg.

Example: I use a database called resources and my connection string looks like this in my server.cfg:

set mysql_connection_string "server=localhost;user=<USERNAME>;password=<PASSWORD>;database=resources;charset=utf8mb4;connectTimeout=60000;acquireTimeout=60000;timeout=60000

During testing, hangs/server crashes occurred when connectTimeout=60000;acquireTimeout=60000;timeout=60000 was not included, your mileage may vary. I would recommend including these just in case.

Import SQL / Execute

Now with your desired database selected you can execute setup.sql included with the resource, it will build a table with columns below.

Setup SQL Table Command
CREATE TABLE `prolaser4` (
	`rid` INT(11) NOT NULL AUTO_INCREMENT,
	`timestamp` DATETIME NOT NULL,
	`speed` INT(11) NOT NULL DEFAULT '0',
	`distance` FLOAT NOT NULL DEFAULT '0',
	`targetX` FLOAT NOT NULL DEFAULT '0',
	`targetY` FLOAT NOT NULL DEFAULT '0',
	`player` TEXT NOT NULL COLLATE 'latin1_swedish_ci',
	`street` TEXT NOT NULL COLLATE 'latin1_swedish_ci',
	`selfTestTimestamp` DATETIME NOT NULL,
	PRIMARY KEY (`rid`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=1;
Column
Datatype
Usage

rid

INT

Record ID / Primary Key

timestamp

DATETIME

Time at which clock occurred.

speed

INT

Estimated speed from clock.

distance

FLOAT

Estimated distance from clock.

targetX

FLOAT

Target entity's GTA X coordinate.

targetY

FLOAT

Target entity's GTA Y coordinate.

player

TEXT

Lidar user's name.

street

TEXT

Street (and cross street if detected) of target vehicles location.

selfTestTimestamp

DATETIME

Time at which the lidar self-test occurred, 0000-00-00 00:00:00 if self-test disabled in config.

Logging Configuration

Configure logging settings in config.lua. Then use /lidarrecords in game to open the tablet and review records.

Uncomment these two oxmysql lines from fxmanifest:

...
dependencies {
	'oxmysql',		-- uncomment for persistent records & record management tablet. See docs and configs.
}
...
server_scripts {
	'@oxmysql/lib/MySQL.lua', -- uncomment for persistent records & record management tablet. See docs and configs.
	...
}

Imgur Integration for Record Printing

The Pro Laser 4 can use Imgur as an upload endpoint for "printing" lidar records from the tablet. These are more screenshots than prints but, are roleplayed as such. In order to be able to upload these images to Imgur you will need to generate an API client ID.

  1. Register an application, select "OAuth 2 authorization without a callback URL"

  2. Copy Client ID field.

  3. Paste in to config in the following format: cfg.imgurApiKey = 'Client-ID XXXXXXXXXXXXXXX' where XXXXXXXXXXXXXXX is the client ID you copied in step 4.

  4. Restart Pro Laser 4 and test out your print functionality in the tablet.

Discord Webhook for Record Printing

The Pro Laser 4 can also use Discord as an upload endpoint for "printing" lidar records from the tablet. Discord webhook messages include record data and a screenshot of the record document. In order to be able to upload these images to Discord you will need a Discord webhook on a channel.

  1. Open "Edit Channel" for the channel where you would like these posted.

  2. Navigate to "Integrations" tab.

  3. Click "Webhooks", then "New Webhook" if you don't already have one.

  4. Then "Copy Webhook URL" and paste in cfg.discordWebhook. See example below.

  5. Restart Pro Laser 4 and test out your print functionality in the tablet.

config.lua
cfg.discordWebhook = 'https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXX/YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'

Note: customizing the icon or name for the webhook is not necessary, ProLaser4 will set the webhook name and image when posting.

Last updated