Car stats- View car statistics with a simple command

cars
simple
commands

#1

I decided I’d do a bit of lua work so I coded up a simple command that sends stats about the car/vehicle you’re in to your chat.
Feedback is welcome and encouraged.

Displays:

  • Name (not spawn name) of the car
  • Max speed in MPH
  • Acceleration rate
  • Number of gears
  • Capacity

preview
Enjoy, everyone!
Usage: /carstats when you’re in a vehicle

carstats.zip (1.0 KB)


#2

This is actually pretty cool! Nice release. :slight_smile:


#3

Very unique…


+1


#4

yes this is very unique and pretty neat! I will definitely put this in my upcoming community! This is useful info! Thanks Setro!


#5

how to convert max speed to KMH?


#6

If you can code just a litle you will find out very easy :wink:


#8

This looks very cool, definitely going to suggest this to my community. Let us know if you update it with more content!


#9

Do you know that you are not able to get real maxspeed and gears?


#10

What do you mean I’m not able to get the real max speed and gears? These are the natives for the vehicle, they’re not fake.


#11

Sure. Replace the contents of the server.lua with this:

RegisterNetEvent('carstats');
AddEventHandler('carstats', function()
local ped = PlayerPedId()
	if IsPedInAnyVehicle(ped, false) then
		local veh = GetVehiclePedIsIn(ped, false)
		local model = GetEntityModel(veh, false)
		local hash = GetHashKey(model)
		TriggerEvent('chatMessage', "", {255, 0, 0}, "^3Name (not spawn name):^7 ".. GetDisplayNameFromVehicleModel(model))
		TriggerEvent('chatMessage', "", {255, 0, 0}, "^3Max speed (MPH):^7 ".. round(GetVehicleMaxSpeed(model) * 3.6,1))
		TriggerEvent('chatMessage', "", {255, 0, 0}, "^3Acceleration rate:^7 ".. round(GetVehicleModelAcceleration(model),1))
		TriggerEvent('chatMessage', "", {255, 0, 0}, "^3Number of gears:^7 ".. GetVehicleHighGear(veh))
		TriggerEvent('chatMessage', "", {255, 0, 0}, "^3Capacity:^7 ".. GetVehicleMaxNumberOfPassengers(veh) + 1)
	end
end)

--snippet borrowed from http://lua-users.org/wiki/SimpleRound
function round(num, numDecimalPlaces)
  local mult = 100^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

I’m coding it based off of what the numbers I found on sources say. If it seems off let me know and I’ll look further.


#12

I don’t see a way to find that info out, sorry.


#13

Thanks man!
Awesome Script!
+1


#14

its all good



#15

Great release!

Maybe in the future try adding the spawn name that way we can blacklist the vehicles we don’t know the spawn names too and are too lazy to look it up… lol…

Anyways, Great job!