JAY.ANN Posted August 22, 2022 Share Posted August 22, 2022 Is there a way to count vehicle acceleration from 0 to 100 km/h using vehicle handling data? Link to comment
WorthlessCynomys Posted August 23, 2022 Share Posted August 23, 2022 With enough testing and tweaking I'm sure it is possible, however you can cheat. You can create every vehicle with a ped in it, give them a forwards control state and measure the time it takes them to accelerate to 100 km/h. This is a way easier solution. Do it with 20 peds in 20 vehicles in the same time and it should be quick enough to do it every now and then. 1 Link to comment
Smokahontas Posted August 23, 2022 Share Posted August 23, 2022 local screenWidth, screenHeight = guiGetScreenSize ( ) function getAccelerationTime(vehicle) local acc = 0 local maxVelocity = getVehicleHandling(vehicle).maxVelocity local gearRatio = getVehicleHandling(vehicle).driveType == 'f' and getVehicleHandling(vehicle).engineAcceleration or getVehicleHandling(vehicle).engineAcceleration*getVehicleHandling(vehicle).numberOfGears acc = 100/maxVelocity*gearRatio return acc end function showAccelerationTime() if not isPedInVehicle(localPlayer) then return false end local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle or getVehicleEngineState(vehicle) == false then return false end local acc = getAccelerationTime(vehicle) dxDrawText(string.format("%0.2f", acc).." sec", 0, 0, screenWidth, screenHeight, tocolor(255, 255, 255), 1, "pricedown", "center", "center") end addEventHandler("onClientRender", root, showAccelerationTime) Link to comment
JAY.ANN Posted August 23, 2022 Author Share Posted August 23, 2022 7 hours ago, WorthlessCynomys said: With enough testing and tweaking I'm sure it is possible, however you can cheat. You can create every vehicle with a ped in it, give them a forwards control state and measure the time it takes them to accelerate to 100 km/h. This is a way easier solution. Do it with 20 peds in 20 vehicles in the same time and it should be quick enough to do it every now and then. I thought about this way, but it seems too complicated 4 hours ago, Smokahontas said: local screenWidth, screenHeight = guiGetScreenSize ( ) function getAccelerationTime(vehicle) local acc = 0 local maxVelocity = getVehicleHandling(vehicle).maxVelocity local gearRatio = getVehicleHandling(vehicle).driveType == 'f' and getVehicleHandling(vehicle).engineAcceleration or getVehicleHandling(vehicle).engineAcceleration*getVehicleHandling(vehicle).numberOfGears acc = 100/maxVelocity*gearRatio return acc end function showAccelerationTime() if not isPedInVehicle(localPlayer) then return false end local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle or getVehicleEngineState(vehicle) == false then return false end local acc = getAccelerationTime(vehicle) dxDrawText(string.format("%0.2f", acc).." sec", 0, 0, screenWidth, screenHeight, tocolor(255, 255, 255), 1, "pricedown", "center", "center") end addEventHandler("onClientRender", root, showAccelerationTime) Thank you, I gonna test it and answer about the results! Link to comment
JAY.ANN Posted August 23, 2022 Author Share Posted August 23, 2022 (edited) 4 hours ago, Smokahontas said: local screenWidth, screenHeight = guiGetScreenSize ( ) function getAccelerationTime(vehicle) local acc = 0 local maxVelocity = getVehicleHandling(vehicle).maxVelocity local gearRatio = getVehicleHandling(vehicle).driveType == 'f' and getVehicleHandling(vehicle).engineAcceleration or getVehicleHandling(vehicle).engineAcceleration*getVehicleHandling(vehicle).numberOfGears acc = 100/maxVelocity*gearRatio return acc end function showAccelerationTime() if not isPedInVehicle(localPlayer) then return false end local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle or getVehicleEngineState(vehicle) == false then return false end local acc = getAccelerationTime(vehicle) dxDrawText(string.format("%0.2f", acc).." sec", 0, 0, screenWidth, screenHeight, tocolor(255, 255, 255), 1, "pricedown", "center", "center") end addEventHandler("onClientRender", root, showAccelerationTime) It doesn't work correctly. It outputs 26.67 sec at the Admiral but my stopwatch says that it's 6.35 sec. I guess it may be because of Drag Multiplier and Interia values Edited August 23, 2022 by JAY.ANN Link to comment
Smokahontas Posted August 24, 2022 Share Posted August 24, 2022 Just type /check function checkVehicleSpeed() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local accel = getVehicleHandling(vehicle).engineAcceleration local seconds = 100/accel outputChatBox("Your vehicle takes " .. seconds .. " seconds to get from 0 to 100km/h") end addCommandHandler("check", checkVehicleSpeed) 1 Link to comment
JAY.ANN Posted August 24, 2022 Author Share Posted August 24, 2022 12 hours ago, Smokahontas said: Just type /check function checkVehicleSpeed() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local accel = getVehicleHandling(vehicle).engineAcceleration local seconds = 100/accel outputChatBox("Your vehicle takes " .. seconds .. " seconds to get from 0 to 100km/h") end addCommandHandler("check", checkVehicleSpeed) This one works fine, thank you so much! Solved 1 Link to comment
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