[Tutorial] Text draw tips
#21

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.
Reply
#22

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?
Reply
#23

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.
Reply
#24

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.

Reply
#25

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?
Reply
#26

Hello One, Hello Two
Reply
#27

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.
Reply
#28

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
Reply
#29

thanks trying now
Reply
#30

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;
	}
Reply
#31

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.
Reply
#32

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.
Reply
#33

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 ©
Reply
#34

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");
Reply
#35

The easiest way is to use Zamaroth TextDrawEditor
Reply
#36

good job!
Reply
#37

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

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.
Reply
#39

Thank you.
Reply
#40

Yes very simple
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)