Speedo Meter problem
#1

When i enter a car it doesnt shows it to me. I have a timer that runs this public every 1sec.
Код:
public UpdateMeter(playerid)
{
	for(new i=0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerInAnyVehicle(i) && speedometer[i] == 1)
		{
		  TextDrawShowForPlayer(playerid,Text:speedo[i]);
  			new vehicleid = GetPlayerVehicleID(playerid);
  			new Float:X, Float:Y, Float:Z, Float:KMH;
  			new Float:hp;
  			hp = GetVehicleHealth(vehicleid,hp);
      GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
  			KMH = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)), floatpower(Z, 2))), 100.0);
			if(KMH == 0)
			{
			  	VehicleInfo[vehicleid][Fuel] -= 0.00;
 			}
			else if( KMH >= 1 && KMH <= 65 )
			{
			  	VehicleInfo[vehicleid][Fuel] -= 0.01;
 			}
			else if( KMH >= 66 && KMH <= 120 )
			{
 				VehicleInfo[vehicleid][Fuel] -= 0.02;
 			}
			else
			{
		   	VehicleInfo[vehicleid][Fuel] -= 0.03;
 			}
		  if(VehicleInfo[vehicleid][Fuel] == 0)
			{
			  SCM(playerid,GREY,"No more fuel left.");
			  RemovePlayerFromVehicle(playerid);
			}
			new string[128];
			format(string, sizeof(string), "~b~~h~~h~Name: ~w~%s~n~~g~~h~Speed: ~w~%0.0f km/h~n~~y~~h~Fuel: ~w~%.1f l~n~~r~~h~Health: ~w~%.2f", CarModels[GetVehicleModel(GetPlayerVehicleID(playerid))-400],floatround(floatdiv(KMH, 1.609344)),VehicleInfo[vehicleid][Fuel],hp);
			TextDrawSetString(Text:speedo[i], string);
      TextDrawShowForPlayer(i,Text:speedo[i]);
		}
	}
}
Reply
#2

Two things.
One post your settimer

and 2 why are you using playerid for the timer when you loop through players

public UpdateMeter(playerid)
{
for(new i=0; i < MAX_PLAYERS; i++)

?
Reply
#3

1. som = SetTimer("UpdateMeter",1000,1);
2. woops. ook i removed it and changed all left playerid to i
testing it in game
Reply
#4

bump
Reply
#5

Show how you create your textdraw.
Reply
#6

It is fixed peps.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)