jeanclau Posted January 25, 2018 Share Posted January 25, 2018 How to make speedmeter ? Link to comment Share on other sites More sharing options...
hexisgod Posted January 26, 2018 Share Posted January 26, 2018 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*/ Link to comment Share on other sites More sharing options...
jeanclau Posted January 26, 2018 Author Share Posted January 26, 2018 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. Link to comment Share on other sites More sharing options...
hexisgod Posted January 26, 2018 Share Posted January 26, 2018 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) Link to comment Share on other sites More sharing options...
jeanclau Posted January 26, 2018 Author Share Posted January 26, 2018 It does not show speed Link to comment Share on other sites More sharing options...
hexisgod Posted January 27, 2018 Share Posted January 27, 2018 12 часа назад, jeanclau сказал: It does not show speed I didn't know anything about this function!) mp.game.graphics.drawText Use some CEF for show speed info) Link to comment Share on other sites More sharing options...
Flow Posted February 28, 2018 Share Posted February 28, 2018 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? Link to comment Share on other sites More sharing options...
hexisgod Posted February 28, 2018 Share Posted February 28, 2018 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 Link to comment Share on other sites More sharing options...
Flow Posted February 28, 2018 Share Posted February 28, 2018 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? Link to comment Share on other sites More sharing options...
hexisgod Posted February 28, 2018 Share Posted February 28, 2018 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.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now