SA-MP Forums Archive
Speedometer issue - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speedometer issue (/showthread.php?tid=625509)



Speedometer issue - AndreiWow - 02.01.2017

Uh, I join the server and enter a vehicle, everything is working fine, the speedo is working fine, for others that come it is not working, just showing 000(the default textdraw).


Код:
forward Speedometer(playerid);
public Speedometer(playerid)
{
	new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
	vehicleid = GetPlayerVehicleID(playerid);
	//new Float:vehicle_health,final_vehicle_health,health_string[256];
	if(vehicleid != 0)
	{
		GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
		final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*250.666667; // 250.666667 = kmph  // 199,4166672= mph
		final_speed_int = floatround(final_speed,floatround_round);
		format(speed_string,256,"%i",final_speed_int);
		TextDrawSetString(speedo0[playerid], speed_string);
	}
	else
	{
		TextDrawSetString(speedo0[playerid], " ");
		TextDrawSetString(speedo1[playerid], " ");
	}
    return 1;
}
OnPlayerEnterVehicle
Код:
TextDrawShowForPlayer(playerid, speedo0[playerid]);
	TextDrawShowForPlayer(playerid, speedo1[playerid]);
	TextDrawShowForPlayer(playerid, speedo2[playerid]);
 	TextDrawShowForPlayer(playerid, speedo3[playerid]);
Why


Re: Speedometer issue - Freaksken - 02.01.2017

You need to use player TextDraws instead of global TextDraws: click.

And instead of making a timer for every player, create just one that iterates over every player.
Lots of timers is a bad idea.

EDIT:
I feel like I should explain some things a bit more: EDIT2:
Wow, third thread about the same thing ...
https://sampforum.blast.hk/showthread.php?tid=625485
https://sampforum.blast.hk/showthread.php?tid=625496


Re: Speedometer issue - AndreiWow - 03.01.2017

And still noone solved my problem, if I use player text draw I get alot of warnings for tag mismatch, and thats how most of the speedos are made at the tutorials on forum, using global textdraws.


Re: Speedometer issue - KillerStrike23 - 03.01.2017

Use This i am using it in my gm and it works like a charm!


Respuesta: Speedometer issue - Whillyrez - 03.01.2017

Is there any other textdraw called like that?


Re: Speedometer issue - Freaksken - 03.01.2017

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
And still noone solved my problem
I've just told you what you need to do.

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
if I use player text draw I get alot of warnings for tag mismatch
That's because you need to use the player textdraw functions with player textdraws + an array (you would've known that if you read the wiki page I linked).
You can't use for example TextDrawSetString for both global textdraws and player textdraws.
TextDrawSetString is for global textdraws.
PlayerTextDrawSetString is for player textdraws.

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
and thats how most of the speedos are made at the tutorials on forum, using global textdraws.
Then clearly those tutorials are bad, or you didn't understand a good one.
Judging from your comment on this one, that's what you're referring to. That tutorial is from august 2010, that's 6.3 years! Of course it's outdated!


Re: Speedometer issue - AndreiWow - 03.01.2017

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
I've just told you what you need to do.


That's because you need to use the player textdraw functions with player textdraws + an array (you would've known that if you read the wiki page I linked).
You can't use for example TextDrawSetString for both global textdraws and player textdraws.
TextDrawSetString is for global textdraws.
PlayerTextDrawSetString is for player textdraws.


Then clearly those tutorials are bad, or you didn't understand a good one.
Judging from your comment on this one, that's what you're referring to. That tutorial is from august 2010, that's 6.3 years! Of course it's outdated!
This is what I get with player textdraws.


Код:
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(9054) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(9055) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(9056) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(9057) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40316) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40317) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40318) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40319) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40349) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40350) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40351) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(40352) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41814) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41815) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41816) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41817) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41875) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41876) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41877) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(41878) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43681) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43682) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43683) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43684) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43690) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43691) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43692) : warning 213: tag mismatch
C:\Users\andrei\Desktop\Scripting SA-MP\Advanced Roleplay (IBP)\gamemodes\panda.pwn(43693) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


28 Warnings.



Re: Speedometer issue - Banditul18 - 03.01.2017

Well, show us some of this lines , to know what you do there
Edit: Show how you declare the text , like " new Text: speedo " or how you have


Re: Speedometer issue - Sew_Sumi - 03.01.2017

If you've simply started replacing TextDrawSetString with PlayerTextDrawSetString, and haven't converted the complete textdraws, then that's your issue...

You need to be constant, rather than simply throwing things together to try and "hope" to fix it.


Everything Text: related to this HAS to be changed to PlayerText: along with the TextDrawCreate and all of the rest.


Re: Speedometer issue - AndreiWow - 03.01.2017

I changed everything with the right format, still get the tag mismatch issue, used PlayerText: but I reverted back to global textdraw and show it to one player, it worked so no need anymore, thanks.