Speedo not working
#1

Why is this speedometer not showing when entering the vehicle?

Код:
new Text:bg;
new Text:barsus;
new Text:viteza;
new Text:vitezakm;
new Text:tipmasina;
Код:
 SetTimer("Speedometer", 200, true);
Код:
bg = TextDrawCreate(625.200195, 362.140075, "usebox");
	TextDrawLetterSize(bg, 0.000000, 5.283332);
	TextDrawTextSize(bg, 500.400024, 0.000000);
	TextDrawAlignment(bg, 1);
	TextDrawColor(bg, 0);
	TextDrawUseBox(bg, true);
	TextDrawBoxColor(bg, 102);
	TextDrawSetShadow(bg, 0);
	TextDrawSetOutline(bg, 0);
	TextDrawFont(bg, 0);

	barsus = TextDrawCreate(496.799926, 349.440002, "LD_SPAC:white");
	TextDrawLetterSize(barsus, 0.000000, 0.000000);
	TextDrawTextSize(barsus, 131.999908, 11.946675);
	TextDrawAlignment(barsus, 1);
	TextDrawColor(barsus, -1378294017);
	TextDrawSetShadow(barsus, 0);
	TextDrawSetOutline(barsus, 0);
	TextDrawFont(barsus, 4);
	
	vitezakm = TextDrawCreate(569.599914, 393.493255, "km/h");
	TextDrawLetterSize(vitezakm, 0.449999, 1.600000);
	TextDrawAlignment(vitezakm, 1);
	TextDrawColor(vitezakm, -1);
	TextDrawSetShadow(vitezakm, 0);
	TextDrawSetOutline(vitezakm, 1);
	TextDrawBackgroundColor(vitezakm, 51);
	TextDrawFont(vitezakm, 2);
	TextDrawSetProportional(vitezakm, 1);

	viteza = TextDrawCreate(506.399749, 348.693237, "100");
	TextDrawLetterSize(viteza, 0.874800, 7.677864);
	TextDrawAlignment(viteza, 1);
	TextDrawColor(viteza, -1);
	TextDrawSetShadow(viteza, 0);
	TextDrawSetOutline(viteza, 1);
	TextDrawBackgroundColor(viteza, 51);
	TextDrawFont(viteza, 2);
	TextDrawSetProportional(viteza, 1);


	tipmasina = TextDrawCreate(533.600158, 347.946716, "sultan");
	TextDrawLetterSize(tipmasina, 0.779600, 1.308799);
	TextDrawAlignment(tipmasina, 1);
	TextDrawColor(tipmasina, -1061109505);
	TextDrawUseBox(tipmasina, true);
	TextDrawBoxColor(tipmasina, 0);
	TextDrawSetShadow(tipmasina, 0);
	TextDrawSetOutline(tipmasina, 1);
	TextDrawBackgroundColor(tipmasina, 51);
	TextDrawFont(tipmasina, 0);
	TextDrawSetProportional(tipmasina, 1);
Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{


	    TextDrawShowForPlayer(playerid, bg);
		TextDrawShowForPlayer(playerid, barsus);
		TextDrawShowForPlayer(playerid, vitezakm);
	    TextDrawShowForPlayer(playerid, viteza);
		TextDrawShowForPlayer(playerid, tipmasina);

	}
	else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
	{
	    TextDrawHideForPlayer(playerid, bg);
		TextDrawHideForPlayer(playerid, barsus);
		TextDrawHideForPlayer(playerid, vitezakm);
		TextDrawHideForPlayer(playerid, tipmasina);
		TextDrawHideForPlayer(playerid, viteza);

	}
Код:
forward Speedometer(playerid);
public Speedometer(playerid)
{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
	    if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
	    {
			new string[32], string2[32];
			format(string, sizeof(string), "%s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]);
			TextDrawSetString(tipmasina, string);

			format(string2, sizeof(string2), "%d", GetPlayerSpeed(i, 0));
			TextDrawSetString(viteza, string2);
	    }
		}
		return 1;
}
Код:
TextDrawHideForAll(bg);
	    TextDrawHideForAll(barsus);
	    TextDrawHideForAll(vitezakm);
	    TextDrawDestroy(bg);
		TextDrawDestroy(barsus);
		TextDrawDestroy(vitezakm);
	    TextDrawHideForAll(viteza);
	    TextDrawDestroy(viteza);
		TextDrawDestroy(tipmasina);
		TextDrawHideForAll(tipmasina);
Reply
#2

You are creating a Textdraw for the whole server while trying to show it to a specific player.
To fix this you need to do the following:

1.Instead of using TextDrawCreate, use CreatePlayerTextDraw
This does not only apply to TextDrawCreate but also all other Textdraw functions.

2.You will also need to change the new's:
Instead of new Text use new PlayerText

RECOMMENDATION:
I also recommend using a single variable for all text draws. For example
Instead of :
Код:
new Text:bg;
new Text:barsus;
new Text:viteza;
new Text:vitezakm;
new Text:tipmasina;
Simply create
Код:
new PlayerText:Speedo[4];
Keep in mind I set 4, since it starts from 0.

then change all the text draw settings etc.

Later on if you want to show the text draw to players, instead of creating 5 lines, use a loop.
Код:
for(new i=0; i < 4; i++){
      TextDrawShowForPlayer(playerid, Speedo[i]);
      return 1;
}
Same applies for hiding the textdraws.
Reply
#3

Quote:
Originally Posted by Codeah
Посмотреть сообщение
You are creating a Textdraw for the whole server while trying to show it to a specific player.
To fix this you need to do the following:

1.Instead of using TextDrawCreate, use CreatePlayerTextDraw
This does not only apply to TextDrawCreate but also all other Textdraw functions.

2.You will also need to change the new's:
Instead of new Text use new PlayerText

RECOMMENDATION:
I also recommend using a single variable for all text draws. For example
Instead of :
Код:
new Text:bg;
new Text:barsus;
new Text:viteza;
new Text:vitezakm;
new Text:tipmasina;
Simply create
Код:
new PlayerText:Speedo[4];
Keep in mind I set 4, since it starts from 0.

then change all the text draw settings etc.

Later on if you want to show the text draw to players, instead of creating 5 lines, use a loop.
Код:
for(new i=0; i < 4; i++){
      TextDrawShowForPlayer(playerid, Speedo[i]);
      return 1;
}
Same applies for hiding the textdraws.
Yea, but my problem is that it is not showing, I will change it with your suggestions but how can I make it actually show and update, where should I put your code to show, when the player enters the vehicle?
Reply
#4

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Yea, but my problem is that it is not showing, I will change it with your suggestions but how can I make it actually show and update, where should I put your code to show, when the player enters the vehicle?
Yeah, it is not showing because you simply can't show a text draw made to display for the whole server (TextDrawCreate) to a specific player.
Reply
#5

Quote:
Originally Posted by Codeah
Посмотреть сообщение
You are creating a Textdraw for the whole server while trying to show it to a specific player.
To fix this you need to do the following:

1.Instead of using TextDrawCreate, use CreatePlayerTextDraw
This does not only apply to TextDrawCreate but also all other Textdraw functions.

2.You will also need to change the new's:
Instead of new Text use new PlayerText

RECOMMENDATION:
I also recommend using a single variable for all text draws. For example
Instead of :
Код:
new Text:bg;
new Text:barsus;
new Text:viteza;
new Text:vitezakm;
new Text:tipmasina;
Simply create
Код:
new PlayerText:Speedo[4];
Keep in mind I set 4, since it starts from 0.

then change all the text draw settings etc.

Later on if you want to show the text draw to players, instead of creating 5 lines, use a loop.
Код:
for(new i=0; i < 4; i++){
      TextDrawShowForPlayer(playerid, Speedo[i]);
      return 1;
}
Same applies for hiding the textdraws.
The size should be set as 5 not 4
Reply
#6

Oops, my bad.
Reply
#7

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
The size should be set as 5 not 4
Realised after I was wondering why I get all those errors.
Reply
#8

I get those warnings now and I am not sure why

Код:
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(7365) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(7366) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(7367) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(7368) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(7369) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41974) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41988) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(42264) : warning 209: function "S@@_OnPlayerStateChange" should return a value
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(50121) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(50122) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(50123) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(50124) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(50125) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


13 Warnings.
7365 - 7369 lines
Код:
TextDrawHideForPlayer(playerid, speedo[0]);
		TextDrawHideForPlayer(playerid, speedo[1]);
		TextDrawHideForPlayer(playerid, speedo[2]);
		TextDrawHideForPlayer(playerid, speedo[3]);
		TextDrawHideForPlayer(playerid, speedo[4]);
41974 - 50125 lines
Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
	{


	    /*TextDrawShowForPlayer(playerid, bg);
		TextDrawShowForPlayer(playerid, barsus);
		TextDrawShowForPlayer(playerid, vitezakm);
	    TextDrawShowForPlayer(playerid, viteza);
		TextDrawShowForPlayer(playerid, tipmasina);*/
		for(new i=0; i < 4; i++)
		{
      		TextDrawShowForPlayer(playerid, speedo[i]);
      		return 1;
		}

	}
	else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
	{
	    /*TextDrawHideForPlayer(playerid, bg);
		TextDrawHideForPlayer(playerid, barsus);
		TextDrawHideForPlayer(playerid, vitezakm);
		TextDrawHideForPlayer(playerid, tipmasina);
		TextDrawHideForPlayer(playerid, viteza);*/
		for(new i=0; i < 4; i++)
		{
      		TextDrawHideForPlayer(playerid, speedo[i]);
      		return 1;
		}

	}
Код:
TextDrawHideForAll(speedo[0]);
	    TextDrawHideForAll(speedo[1]);
	    TextDrawHideForAll(speedo[3]);
	    TextDrawHideForAll(speedo[2]);
		TextDrawHideForAll(speedo[4]);
And when I go in game and hop into a vehicle it is just a big orange box above the screen.
http://imgur.com/a/WjrDZ
Reply
#9

Anyone please..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)