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
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
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