How to get carid.
#1

Hello, I was trying to get carid in speedometer, but I fail, so I want to ask your help.
Heres my code:

Код:
public CheckStatus()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(IsPlayerInAnyVehicle(i))
			{

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

				if(TextDrawsShown[i] == false)
				{
				  TextDrawShowForPlayer(i, Text:Black0);
				  TextDrawShowForPlayer(i, Text:White1);
				  TextDrawShowForPlayer(i, Text:White2);
				  TextDrawShowForPlayer(i, Text:BlackHealth);
				  TextDrawShowForPlayer(i, Text:DarkRedHealth);
				  TextDrawShowForPlayer(i, Text:BlackSpeed);
				  TextDrawShowForPlayer(i, Text:DarkYellowSpeed);
				  TextDrawShowForPlayer(i, Text:Marker);
				  TextDrawsShown[i] = true;
				}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

			  new String[128];
		    new Float:X, Float:Y, Float:Z, Float:Distance;
	      GetPlayerPos(i, X, Y, Z);
	      Distance = floatsqroot(floatpower(floatabs(floatsub(X,OldX[i])),2)+floatpower(floatabs(floatsub(Y,OldY[i])),2)+floatpower(floatabs(floatsub(Z,OldZ[i])),2));
				new PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i));
				PlayerVehicleModelID -= 400;
				format(String,sizeof(String),"~p~Vehicle:~n~~w~%s~n~~p~Health:~n~~n~Speed:~n~~w~%ikm/h~n~ID:~", PlayerVehicle[PlayerVehicleModelID], floatround(Distance*10, floatround_floor));
				if(VHSCreated[i] == true)
				{
					TextDrawDestroy(VHS[i]);
				}
				VHS[i] = TextDrawCreate(485.000000,355.000000,String);
				TextDrawAlignment(VHS[i],0);
				TextDrawBackgroundColor(VHS[i],0x000000ff);
				TextDrawFont(VHS[i],1);
				TextDrawLetterSize(VHS[i],0.299999,1.000000);
				TextDrawColor(VHS[i],0xffffffff);
				TextDrawSetOutline(VHS[i],1);
				TextDrawSetProportional(VHS[i],1);
				TextDrawSetShadow(VHS[i],1);
      	TextDrawShowForPlayer(i, VHS[i]);
      	VHSCreated[i] = true;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

				new Float:CarHealth;
				GetVehicleHealth(GetPlayerVehicleID(i), CarHealth);
				if(LightRedHealthCreated[i] == true)
				{
					TextDrawDestroy(LightRedHealth[i]);
				}
				LightRedHealth[i] = TextDrawCreate(488.000000,386.000000,"_");
				TextDrawUseBox(LightRedHealth[i],1);
				TextDrawBoxColor(LightRedHealth[i],0xff000099);
				for(new j=0; j<50; j++)
				{
				  if(CarHealth >= 1000) { TextDrawTextSize(LightRedHealth[i],589.000000,0.000000); }
				  else if(CarHealth >= j*20 && CarHealth < (j+1)*20) { TextDrawTextSize(LightRedHealth[i],484.0+(j*2.1),0.000000); }
				}
				TextDrawAlignment(LightRedHealth[i],0);
				TextDrawBackgroundColor(LightRedHealth[i],0x000000ff);
				TextDrawFont(LightRedHealth[i],3);
				TextDrawLetterSize(LightRedHealth[i],1.000000,0.199999);
				TextDrawColor(LightRedHealth[i],0xffffffff);
				TextDrawSetOutline(LightRedHealth[i],1);
				TextDrawSetProportional(LightRedHealth[i],1);
				TextDrawSetShadow(LightRedHealth[i],1);
      	TextDrawShowForPlayer(i, LightRedHealth[i]);
      	LightRedHealthCreated[i] = true;
				if(CarHealth < 250)
				{
					if(ExclamationShown[i] == true)
					{
						TextDrawHideForPlayer(i, Text:Exclamation);
					  ExclamationShown[i] = false;
					}
					else
					{
						TextDrawShowForPlayer(i, Text:Exclamation);
					  ExclamationShown[i] = true;
					}
				}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

				if(LightYellowSpeedCreated[i] == true)
				{
					TextDrawDestroy(LightYellowSpeed[i]);
				}
				LightYellowSpeed[i] = TextDrawCreate(537.000000,404.000000,"_");
				TextDrawUseBox(LightYellowSpeed[i],1);
				TextDrawBoxColor(LightYellowSpeed[i],0xffff0066);
				for(new k=0; k<50; k++)
				{
				  if(Distance >= 21) { TextDrawTextSize(LightYellowSpeed[i],589.000000,0.000000); }
				  else if(Distance >= k*0.42 && Distance < (k+1)*0.42) { TextDrawTextSize(LightYellowSpeed[i],533.0+(k*1.12),0.000000); }
				}
				TextDrawAlignment(LightYellowSpeed[i],0);
				TextDrawBackgroundColor(LightYellowSpeed[i],0x000000ff);
				TextDrawFont(LightYellowSpeed[i],3);
				TextDrawLetterSize(LightYellowSpeed[i],1.000000,1.200000);
				TextDrawColor(LightYellowSpeed[i],0xffffffff);
				TextDrawSetOutline(LightYellowSpeed[i],1);
				TextDrawSetProportional(LightYellowSpeed[i],1);
				TextDrawSetShadow(LightYellowSpeed[i],1);
      	TextDrawShowForPlayer(i, LightYellowSpeed[i]);
      	LightYellowSpeedCreated[i] = true;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	      OldX[i] = X; OldY[i] = Y; OldZ[i] = Z;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

			}
			else
			{
			  if(TextDrawsShown[i] == true)
			  {
					TextDrawHideForPlayer(i, Text:Black0);
					TextDrawHideForPlayer(i, Text:White1);
					TextDrawHideForPlayer(i, Text:White2);
					TextDrawHideForPlayer(i, Text:BlackHealth);
					TextDrawHideForPlayer(i, Text:DarkRedHealth);
					TextDrawHideForPlayer(i, Text:BlackSpeed);
					TextDrawHideForPlayer(i, Text:DarkYellowSpeed);
					TextDrawHideForPlayer(i, Text:Marker);
					TextDrawHideForPlayer(i, Text:Exclamation);
				  TextDrawsShown[i] = false;
				}
				TextDrawHideForPlayer(i, Text:VHS[i]);
				TextDrawHideForPlayer(i, Text:LightRedHealth[i]);
				TextDrawHideForPlayer(i, Text:LightYellowSpeed[i]);
			}
		}
	}
}
I want get carID under Speed... I hope you understand me...
Reply
#2

How to get car id?
Hmm

GetPlayerVehicleID(playerid);
Reply
#3

Код:
error 017: undefined symbol "playerid"
ehmm.. how to fix this?
Reply
#4

Wherever it says playerid in that code, replace with i.
Reply
#5

Just make playerid param
Reply
#6

Quote:
Originally Posted by kukars22
Код:
error 017: undefined symbol "playerid"
ehmm.. how to fix this?
You're making a loop for all players, then use 'i' instead of 'playerid'.
pawn Код:
GetPlayerVehicleID(i);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)