[HELP] Get Vehicle Speed

Basically im looking for a native or something that gives me the speed of a specific player. Command would be like
/getspeed (id)
this would print me the current speed of that person in chat.
anyone know the native to get a players speed?

You could just use GetEntitySpeed

1 Like

i love you. dont know how i could forget about that lol

im terribly sorry but im REALLY new to fivem scripting and stuff.
basically i tried registering a command to get the speed as decribed before in the discussion linked.
ive done that but when i go ingame and the resource is started the command doesnt pop up. again its probably a stupid mistake but im new xD

RegisterCommand(ā€œgetspeedā€, function(source, args, raw)
    entity target = args[1];
    float GET_ENTITY_SPEED(target);
    float speed = GET_ENTITY_SPEED(target);
    float kmh = (speed * 3.6);
    TriggerEvent(ā€œchatMessageā€, ā€˜ADMINISTRATION TEAM’,{255, 0, 0}, kmh)
end)

Natives in Lua should be in PascalCase, so like GET_ENTITY_SPEED() becomes GetEntitySpeed()

In lua there’s not really data typing like that, just write local to make a variable

In Lua you don’t need to put a semicolon after each line

Don’t think the lua compiles likes those symbol try usig " and ’ not those you did

Guess you need to get the vehicle of the target as i guess you are not entering a vehicle id :stuck_out_tongue:

well yeah but i mean the command working in actually showing what speed the person is going is one thing, but like its not even showing up/working at all

Well it won’t work if you have syntax errors then the script won’t even run

RegisterCommand("getspeed", function(source, args, raw)

local ped = PlayerPedId(args[1])
local veh = GetVehiclePedIsUsing(ped)
local speed = GetEntitySpeed(veh)
local kmh = (speed * 3.6)
TriggerEvent(ā€œchatMessageā€, ā€œADMINISTRATION TEAMā€,{255, 0, 0}, kmh)
end)

what about now