TextDraw Problem
#1

I made this code, but my TD still blinking


Ongamemodeinit:

Код:
SetTimer("TD_Vehicle",200,1);
bottom:

Код:
forward TD_Vehicle();
public TD_Vehicle()
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if(IsPlayerInAnyVehicle(i) && IsPlayerConnected(i))
		{
		  if(IsPlayerNPC(i))return 1;
		  
			if(TDShowwed[i]==false)
			{
			  TextDrawShowForPlayer(i,vinfo[i]);
			  TDShowwed[i]=true;
			}
		    
		  new stringtd[256];
		  ///////////////////////////////	get valori/////////////////////////
		  new Float:X,Float:Y,Float:Z,Float:Distance;
		  GetPlayerPos(i,X,Y,Z);
			new af[50];
			if(autofix[i]==1)af="~p~~h~SI";
			if(autofix[i]==0)af="~p~NO";
			new a[50];
			if(vClosed[GetPlayerVehicleID(i)]==1) a="~y~Chiusa";
			if(vClosed[GetPlayerVehicleID(i)]==0) a="~r~~h~~y~~h~Aperta";
		  new PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i));
			PlayerVehicleModelID -= 400;
			new ninfo[15];
			Distance = floatsqroot(floatadd(floatadd(floatpower(floatsub(X, OldX[i]), 2), floatpower(floatsub(Y, OldY[i]), 2)), floatpower(floatsub(Z, OldZ[i]), 2)));
			if(nossed[GetPlayerVehicleID(i)]==1)
			{
				ninfo="~g~SI";
			}else{
				ninfo="~r~NO";
			}
	    UpdateVHealth(i);

	    new Float:vhea;
			GetVehicleHealth(GetPlayerVehicleID(i),vhea);
			new vheae[10];
			format(vheae,10,"%f",vhea);
			if(vhea==1000)
			{
				strdel(vheae,4,10);
			}else if(vhea<1000&&vhea>99)
			{
			  strdel(vheae,3,10);
			}else if(vhea<99&&vhea>9)
			{
			  strdel(vheae,2,10);
			}else if(vhea<10&&vhea>=0)
			{
			  strdel(vheae,1,10);
			}
	    ////////////////////////////////get valori//////////////////////////



	    /////////foramtta
			if(spedded[i]<=0)format(stringtd,sizeof(stringtd),"%s [%d]~n~~w~Health: %s%s~w~/1000~n~~w~Nos: %s~w~~n~Velocita': ~b~~h~%i~n~~w~Stato: %s~n~~w~Auto-Fix: %s~n~            ~r~SPEED",PlayerVehicle[PlayerVehicleModelID],GetVehicleModel(GetPlayerVehicleID(i)),vhealth[i],vheae,ninfo,floatround(floatmul(Distance,8.0), floatround_floor),a,af);
			if(spedded[i]>0){spedded[i]--;format(stringtd,sizeof(stringtd),"%s [%d]~n~~w~Health: %s%s~w~/1000~n~~w~Nos: %s~w~~n~Velocita': ~b~~h~%i~n~~w~Stato: %s~n~~w~Auto-Fix: %s~n~            ~r~~h~SPEED",PlayerVehicle[PlayerVehicleModelID],GetVehicleModel(GetPlayerVehicleID(i)),vhealth[i],vheae,ninfo,floatround(floatmul(Distance, 8.0), floatround_floor),a,af),spedded[i]=0;}
	    /////////foramtta
	    

	    if(floatround(floatmul(Distance, 8.0), floatround_floor)>30)
			{
				IsSpeeding[i]=true;
			}else{
			  IsSpeeding[i]=false;
			}
			
			
			

		  ///////////////////////show///////////////////////
		  if(TDShowwed[i]==false)
		  {
				vinfo[i]=TextDrawCreate(153,365,stringtd);
				TextDrawFont(vinfo[i],1);
				TextDrawSetShadow(vinfo[i],0);
				TextDrawLetterSize(vinfo[i],0.3,0.7);
				TextDrawUseBox(vinfo[i],true);
				TextDrawTextSize(vinfo[i], 296, 340);
				TextDrawSetOutline(vinfo[i],1);
				TextDrawBackgroundColor(vinfo[i],0x000000256);

				if(Addumed[i]==1)
				{
					TextDrawBoxColor(vinfo[i],0x0000ff210);
				}else{
	     		TextDrawBoxColor(vinfo[i],0x000000220);
				}

				TextDrawShowForPlayer(i,vinfo[i]);
		    TDShowwed[i]=true;
		  }else{
		  	TextDrawDestroy(vinfo[i]);
		  	vinfo[i]=TextDrawCreate(153,365,stringtd);
		  	TextDrawFont(vinfo[i],1);
				TextDrawSetShadow(vinfo[i],0);
				TextDrawLetterSize(vinfo[i],0.3,0.7);
				TextDrawUseBox(vinfo[i],true);
				TextDrawTextSize(vinfo[i], 296, 340);
				TextDrawSetOutline(vinfo[i],1);
				TextDrawBackgroundColor(vinfo[i],0x000000256);

				if(Addumed[i]==1)
				{
					TextDrawBoxColor(vinfo[i],0x0000ff210);
				}else{
	      		TextDrawBoxColor(vinfo[i],0x000000220);
				}

				TextDrawShowForPlayer(i,vinfo[i]);
		    TDShowwed[i]=true;
		  }
			/////////////////////////show///////////////////////

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



		}
		else if(TDShowwed[i]==true)
		{
		  TextDrawHideForPlayer(i,vinfo[i]);
		  TextDrawDestroy(vinfo[i]);
		  TDShowwed[i]=false;
		}
	}
	return 1;
}
sorry for my english...
Reply
#2

help me
Reply
#3

help me! addit
Reply
#4

up
Reply
#5

Change
pawn Код:
if(IsPlayerNPC(i))return 1;
with
pawn Код:
if(IsPlayerNPC(i)) continue;
because using return 1 will stop your loop while finding NPC.
Reply
#6

In my GM there aren't npc
Reply
#7

:
Reply
#8

Quote:
Originally Posted by ft941
In my GM there aren't npc
Then why do you use IsPlayerNPC? /logic
Reply
#9

becouse I want to add in future a npc, anyway the textdraw continues at appear and disappear when there are two or more player...
Reply
#10

So then be logical and add it anyway!

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)