05.02.2011, 12:32
(
Последний раз редактировалось Kwarde; 05.02.2011 в 12:56.
Причина: Solved
)
It is solved!
Jo,
I'm trying to learn more about float functions etc. (I'm not good in math :/)
However I made a speed-o-meter, but it's only working for 50% : It's only working when I drive to the North or the East. (It displays the speed okay)
Here's the function:
And this is where I update the textdraw:
ps I made the next macro's that I'm using:
Does anyone know why this's happening?
- Kevin
Jo,
I'm trying to learn more about float functions etc. (I'm not good in math :/)
However I made a speed-o-meter, but it's only working for 50% : It's only working when I drive to the North or the East. (It displays the speed okay)
Here's the function:
pawn Код:
func:GetVehicleSpeed(vehicleid)
{
new Float:v_vX, Float:v_vY, Float:v_vZ, Float:XYZ, Float:_ret;
GetVehicleVelocity(vehicleid, v_vX, v_vY, v_vZ);
_ret = floatmul( ( ( (v_vX) + (v_vX) ) * 2 ) + ( ( (v_vY) + (v_vY) ) * 2 ) + ( ( (v_vZ) + (v_vZ) ) * 2 ) , v_vX + v_vY + v_vZ);
_ret = floatpower(_ret, 2);
XYZ = v_vX + v_vY + v_vZ;
return floatround(_ret + XYZ * 99, floatround_ceil);
}
pawn Код:
CB:UpdateVehicles()
{
new str[15];
loop:MAX_VEHICLES(i, 0){
if(!IsAnyPlayerInVehicle(i)) continue;
if(GetVehicleSpeed(i) == 0) format(str, 15, "Speed: 0");
else if(GetVehicleSpeed(i) > 0 && GetVehicleSpeed(i) < 80) format(str, 15, "Speed: ~g~%d", GetVehicleSpeed(i));
elseif(GetVehicleSpeed(i) > 80 && GetVehicleSpeed(i) < 120) format(str, 15, "Speed: ~y~%d", GetVehicleSpeed(i));
elseif(GetVehicleSpeed(i) > 120) format(str, 15, "Speed: ~r~%d", GetVehicleSpeed(i));
}
ploop(i) TextDrawSetString(VehicleSpeed[i], str);
return 1;
}
pawn Код:
#define func:%0(%1) stock %0(%1)
#define CB:%0(%1) forward %0(%1); public %0(%1)
#define loop:%0(%1, %2) for(new %1 = %2; %1 < %0; %1++)
#define ploop(%0) for(new %0 = 0; %0 < MAX_SLOTS; %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
- Kevin