RAGE Multiplayer Community

# Speedmeter?

## Recommended Posts

Hey man!

You can make it on clien-side:

```/*Mathematic logic -> we math a speed*/
let velocity_length = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z);

/*now we know vehicle speed "velocity_length"*/

/*Than if you want use - see under*/
let velocity_human_length = velocity_length * 3.6; // \${speed} km/h

let velocity_human_length = velocity_length * 2.236936; // \${speed} mp/h

/* that it good*/```

##### Share on other sites

6 hours ago, hexisgod said:

Hey man!

You can make it on clien-side:

```/*Mathematic logic -> we math a speed*/
let velocity_length = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z);

/*now we know vehicle speed "velocity_length"*/

/*Than if you want use - see under*/
let velocity_human_length = velocity_length * 3.6; // \${speed} km/h

let velocity_human_length = velocity_length * 2.236936; // \${speed} mp/h

/* that it good*/```

function getspeed() {

let vehicle = mp.players.local.vehicle;
if (vehicle) {
let x = mp.players.local.position.x;
let y = mp.players.local.position.y;
let z = mp.players.local.position.z;
let speed = Math.sqrt(x * x + y * y + z * z);
let displayspeed = Math.ceil(speed * (speed / 20) * 2);
mp.game.graphics.drawText(`\${displayspeed}`, 0.5, 0.005, 1, 255, 255, 255, 255, 1.2, 1.2, false, true, 0);
}
}

I tried some methods, but I can't figure out why it does not work.

##### Share on other sites

```function getSpeed() {
if(mp.players.local.isInAnyVehicle(true)) {
let vehicle_velocity = mp.players.local.vehicle.getVelocity(); /*find vehicleVelocity (x, y, z)*/
let vehicle_speed = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z); /*find vehicle speed*/

/* if y want use km/h */
let vehicle_speed_converter = velocity_length * 3.6;

/* if y want use mp/h */
let vehicle_speed_converter = velocity_length * 2.236936;

mp.game.graphics.drawText(`Speed: \${vehicle_speed_converter.toFixed(0)}`, [0.5, 0.005], {
font: 7,
color: [255, 255, 255, 185],
scale: [0.5, 0.5],
outline: false
});
}
}```

You can use it)

##### Share on other sites

12 часа назад, jeanclau сказал:

It does not show speed

Use some CEF for show speed info)

##### Share on other sites

• 1 month later...
Am 26.1.2018 um 14:01 schrieb hexisgod:
```function getSpeed() {
if(mp.players.local.isInAnyVehicle(true)) {
let vehicle_velocity = mp.players.local.vehicle.getVelocity(); /*find vehicleVelocity (x, y, z)*/
let vehicle_speed = Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z); /*find vehicle speed*/

/* if y want use km/h */
let vehicle_speed_converter = velocity_length * 3.6;

/* if y want use mp/h */
let vehicle_speed_converter = velocity_length * 2.236936;

mp.game.graphics.drawText(`Speed: \${vehicle_speed_converter.toFixed(0)}`, [0.5, 0.005], {
font: 7,
color: [255, 255, 255, 185],
scale: [0.5, 0.5],
outline: false
});
}
}```

You can use it)

How would you use this if you put it in client package so you can update a div container in cef browser with speed in real time?

##### Share on other sites

21 минуту назад, cmdflow сказал:

How would you use this if you put it in client package so you can update a div container in cef browser with speed in real time?

You create browser, then you can you browsers.execute('something code');
You can use framework for cef:
React+Redux
VUE
or use JQuery

##### Share on other sites

But it's a push action right? So from client package file with a function which is repeatet every second (or even less) to execute the "browser.execute" thingy? Or is it possible to pull and write a client side speedmeter which is pulled from the cef page itself?

##### Share on other sites

10 минут назад, cmdflow сказал:

But it's a push action right? So from client package file with a function which is repeatet every second (or even less) to execute the "browser.execute" thingy? Or is it possible to pull and write a client side speedmeter which is pulled from the cef page itself?

On the client, we process all data, get the final speed, and with browser.execute transfer the data to cef..

## Create an account

Register a new account