GetVehicleVelocity problem
#1

So.. I want to make an automatic speedtrap system.
This is the code from my speedo
pawn Код:
new String[128];
new Float:X, Float:Y, Float:Z, Float:Speed;
new vehicle = GetPlayerVehicleID(i);
GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 230);
format(String,sizeof(String),"~b~ D-Board~n~~r~Fuel: ~w~%i~n~~r~km/h: ~w~%i", Gas[vehicle], floatround(Speed, floatround_floor));
And this is the speedtrap system. I setted it to sent cops a message but the speed is always 0.

pawn Код:
new carid = GetPlayerVehicleID(playerid);
new Float:X, Float:Y, Float:Z, Float:viteza;
new vehicle = GetPlayerVehicleID(carid);
GetVehicleVelocity(GetPlayerVehicleID(carid), X, Y, Z);
viteza = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 230);
format(str,sizeof(str), "[RADAR] Car bla bla with speed %d!",viteza);//here the speed is 0
SendClientMessage(i, TEAM_BLUE_COLOR, str);
Reply
#2

up..
Reply
#3

pawn Код:
new carid = GetPlayerVehicleID(playerid);
GetVehicleVelocity(GetPlayerVehicleID(carid), X, Y, Z);
Watch closely, and you'll see what you did wrong.
Reply
#4

I don't see anything
Reply
#5

Lets make it a bit more clear

new carid = GetPlayerVehicleID(playerid);
GetVehicleVelocity(GetPlayerVehicleID(carid), X, Y, Z);

or if we put it together

GetVehicleVelocity(GetPlayerVehicleID(GetPlayerVehicleID(playerid)), X, Y, Z);

And use %.0f instead of %d in format because its a float
Reply
#6

Solved. TC.
Reply
#7

I forgot. I want it to show the number plate, but it shows another text.
pawn Код:
new plate = CarInfo[vehicle][cPlate];
format(str,sizeof(str), "[RADAR] Masina mergand cu viteza de %i, numar : %s",floatround(viteza, floatround_floor), plate);
Reply
#8

Quote:
Originally Posted by pantelimonfl
Посмотреть сообщение
I forgot. I want it to show the number plate, but it shows another text.
pawn Код:
new plate = CarInfo[vehicle][cPlate];
format(str,sizeof(str), "[RADAR] Masina mergand cu viteza de %i, numar : %s",floatround(viteza, floatround_floor), plate);
Up...
Reply
#9

plate doesnt look like a string (%s) more like and int (%d, %i)
Reply
#10

even i put %d it show a stupid text.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)