SA-MP Forums Archive
[Tutorial] Text draw tips - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Text draw tips (/showthread.php?tid=2867)

Pages: 1 2 3


Re: Text draw tips - Betamaster - 22.06.2007

Quote:
Originally Posted by Simbad De Zeeman
Hi, i had an old speedometer, and i replaced the GameTextForPlayer(i, strings, 1500, 5); for
Code:
//GameTextForPlayer(i, strings, 1500, 5);
TextDrawDestroy(gText);
gText = TextDrawCreate(10.0, 100.0, strings);
TextDrawShowForPlayer(i, gText);
oldpos[i][0] = newpos[i][0];
oldpos[i][1] = newpos[i][1];
it works fine on my screen, but when a new player is connected, he get the speedometer, and mines dissappear
then when a new player connects, that player will get the speedo, and the old player's speedo meter dissapear..

did i make a stupid mistake?
Have a read of this post then read my response.


Re: Betamaster: Text draw tips - Simbad De Zeeman - 23.06.2007

ehm.. ok, i did my best :P im not very good in this stuff i think :P look:

Code:
 for(new k = 0; k < MAX_PLAYERS; k++) {
	for(new gText = 0; gText < MAX_PLAYERS; gText++) {
		if(IsPlayerConnected(k)) {
			TextDrawDestroy(gText);
        	gText = TextDrawCreate(10.0, 100.0, strings);
			TextDrawShowForPlayer(k, gText);
			oldpos[i][0] = newpos[i][0];
			oldpos[i][1] = newpos[i][1];
				}
  			}
		}
now everyone's speedo's are displayed to everyone, GAOS!!!
can you help me?


Re: Text draw tips - Mauzen - 27.06.2007

its the same problem like earlier here, make gText an array and the index of it 'k', the playerid.


btw. is it possible jump to the next line in a single TextDraw? \n and \r\n does not work.


Re: Text draw tips - Mauzen - 29.06.2007

sry for a noob question again, but why does this code not work?

Code:
public carhealth() {
	new Float:tmp;
	new tmpp[256];
	new tmppp[256];
	for(new i = 0; i < MAX_PLAYERS; i ++) {

		if(IsPlayerInAnyVehicle(i)) {
			GetVehicleHealth(GetPlayerVehicleID(i), tmp);
			format(tmpp,255,"%f",tmp / 10);
			valstr(tmppp,strval(tmpp));
			TextDrawDestroy(carhp[i]);
			carhpshown[i] = 0;
			format(tmpp,255,"%d km/h~n~%s%",kmph[i], tmppp);
			carhp[i] = TextDrawCreate(500, 380, tmpp);
			TextDrawUseBox(carhp[i], 1);
			TextDrawBoxColor(carhp[i], 0x88888877);
			TextDrawShowForPlayer(i, carhp[i]);
			carhpshown[i] = 1;
		} else {
			if(carhpshown[i] == 1) {
				TextDrawDestroy(carhp[i]);
				carhpshown[i] = 0;
			}
		}
 	}
}
It should display the speed and health of a car to players, but its the same like before, when more than one player is in a car, it is only visible for the player with the highest id.
I used arrays as said here, but i still cant find the error.




Re: Text draw tips - michael2572 - 29.06.2007

When I try to draw numbers, it seems to insert a return. As in, if I coded ("Hello 1, hello 2"), I'd get a TD that looks like this:

Hello
1 hello
2

Any explanation?


Re: Text draw tips - boylett - 29.06.2007

Hello One, Hello Two


Re: Text draw tips - Betamaster - 30.06.2007

Quote:
Originally Posted by Shield42
When I try to draw numbers, it seems to insert a return. As in, if I coded ("Hello 1, hello 2"), I'd get a TD that looks like this:

Hello
1 hello
2

Any explanation?
Your text area is probably not large enough so the text is wrapping.


Re: Text draw tips - michael2572 - 01.07.2007

Need to increment, and yes my text area is large enough. I know that for a fact because if I was to do "hello 1 2" it would draw:

hello
1
2

instead of
hello
1 2


Re: Text draw tips - johnathon956 - 16.03.2010

thanks trying now


Re: Text draw tips - [Mr]Fred - 09.05.2010

The text appears, but he never goes away.
Can someone help me with this problem?
The code:
Code:
  	if(strcmp(cmdtext, "/infernus", true)==0)
	{
		if( PVeh[playerid] > 0 )
		{
			if(GetPlayerVehicleID(playerid) != PVeh[playerid])
			{
				if(IsPlayerInAnyVehicle(playerid))
				{
					RemovePlayerFromVehicle(playerid);
				}
				HidePlayerInfoTextDraws(playerid);
				new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
				GetPlayerPos(playerid, X, Y, Z);
				GetPlayerFacingAngle(playerid, Ang);
				GetPlayerName(playerid, Name, sizeof( Name ));
				PutPlayerInVehicle(playerid, PVeh[playerid], 0);
				SetVehiclePos(PVeh[playerid], X, Y, Z);
				SetVehicleZAngle(PVeh[playerid], Ang);
				SetVehicleHealth(PVeh[playerid], 1000.0);
				LinkVehicleToInterior(PVeh[playerid], GetPlayerInterior(playerid));
				TextDrawShowForPlayer(playerid, Text:VehicleCalled);
			 	HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
			}
			else
			{
                HidePlayerInfoTextDraws(playerid);
				TextDrawShowForPlayer(playerid, Text:VehicleError);
			 	HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
			}
		}
		else
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				RemovePlayerFromVehicle(playerid);
			}
			HidePlayerInfoTextDraws(playerid);
			new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
			GetPlayerPos(playerid, X, Y, Z);
			GetPlayerFacingAngle(playerid, Ang);
			GetPlayerName(playerid, Name, sizeof( Name ));
			PVeh[playerid] = CreateVehicle(522, X, Y , Z, Ang, 75,3, 5000000);
			PutPlayerInVehicle(playerid, PVeh[playerid], 0);
			LinkVehicleToInterior(PVeh[playerid], GetPlayerInterior(playerid));
            TextDrawShowForPlayer(playerid, Text:VehicleCreated);
			HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
			SetVehicleParamsForPlayer(PVeh[playerid], playerid, 0, 0);
			for(new i=0; i <= MAX_PLAYERS; i++)
			{
				if ( IsPlayerConnected(i) )
				{
					if ( i != playerid )
					{
						SetVehicleParamsForPlayer(PVeh[playerid], i, 0, 1);
					}
				}
			}
		}
		return 1;
	}



Re: Text draw tips - Warfish - 25.08.2010

ok my textdraws are coursed! I have scrited a whole minigame server and when I've saw textdraws on onther servers, I said 'I MUST have textdraws in my minigames!' so i created textdraws, no problems in the beginning. but after a while, some textdraws appeared and disappeared randomly! also my friend had the same problem on his server so he has removed a lot of textdraws. But by my know, I did noting wrong!

Does anyone a way to get rid of that problem? I know it is possible, there are server with loads of textdraws and there aren't bugged at all!

ps: I am an advanced scripter.


Re: Text draw tips - Betamaster - 14.09.2010

If you use text draws in filterscripts make sure you destroy them on filterscript exit. Also, if you use filterscripts in your gamemode and in filterscripts, make sure you destroy all of them on gamemode/filterscript exit then recreate them in your filterscripts after the filterscripts are created in your gamemode. If you don't do this, things like /rcon gmx and /rcon reloadfs blah will mess up your text draws.


Re: Text draw tips - MBX97 - 18.09.2010

i'm Actually not a good Scripter but i can make things Commands , dialogs , pickups , anything unless string so if any 1 want me as a hard scripter i'll be glad to help
_______________________________________________
© MBX97 , All Rights Reserved ©


Re: Text draw tips - Luka P. - 15.10.2010

I don't know if anybody posted this yet (though this is my own code), but if you want to use one textdraw per player - and you want to use it in more scripts then you can simply do.

pawn Code:
// This will create the textdraw at position x:0,y:0 with the text "hey" and it will be stored in "This is my textdraw" player-variable
SetPVarInt(playerid, "This is my textdraw", _:TextDrawCreate(0, 0, "hey"));

// Now, to modify this textdraw in another script, you use for example:
TextDrawSetString(_:GetPVarInt(playerid, "This is my textdraw"), "new text");



Re: Text draw tips - Stefan_Toretto - 11.12.2010

The easiest way is to use Zamaroth TextDrawEditor


Re: Text draw tips - SkizzoTrick - 11.12.2010

good job!


Re: Text draw tips - [aKa]sEnZaTzIE - 12.12.2010

Thanks a lot man , im a beginner scripter, and i will try this , this is so helpfull .


Re: Text draw tips - Warfish - 31.12.2010

Quote:
Originally Posted by Betamaster
View Post
If you use text draws in filterscripts make sure you destroy them on filterscript exit. Also, if you use filterscripts in your gamemode and in filterscripts, make sure you destroy all of them on gamemode/filterscript exit then recreate them in your filterscripts after the filterscripts are created in your gamemode. If you don't do this, things like /rcon gmx and /rcon reloadfs blah will mess up your text draws.
wow thanks man! So I think that can be my problem, because in my minigames server, i use SendRconCommand("gmx") to go to the next mode.

And I dont what tu use other 'text draw editor's' because that only brings more problems with other thins! I've had some problems with a CP streamer, it took me a while before I did find out that the cp streamer whas the problem, so i made one my self.


Re: Text draw tips - Garciano44 - 27.02.2011

Thank you.


Re: Text draw tips - boyan96 - 11.04.2011

Yes very simple