SA-MP Forums Archive
How do i add Textdraws in a Gamemode? - 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: How do i add Textdraws in a Gamemode? (/showthread.php?tid=651763)



How do i add Textdraws in a Gamemode? - BrightLeaN - 27.03.2018

Hey,
So i made something with a Textdraweditor and got some codes, idk where do i need to put them they just don't show up

So this is what i edited from a tutorial,
Код:
public sekunde()
{
	new string[128];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(i))continue;
		if(!IsPlayerInAnyVehicle(i))continue;
		format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
		textdraw_1 = TextDrawCreate(556.000000, 337.000000, "string");
		TextDrawFont(textdraw_1, 2);
		TextDrawLetterSize(textdraw_1, 0.429166, 2.049999);
		TextDrawTextSize(textdraw_1, 400.000000, 17.000000);
		TextDrawSetOutline(textdraw_1, 1);
		TextDrawSetShadow(textdraw_1, 0);
		TextDrawAlignment(textdraw_1, 1);
		TextDrawColor(textdraw_1, 1296911871);
		TextDrawBackgroundColor(textdraw_1, 255);
		TextDrawBoxColor(textdraw_1, 50);
		TextDrawUseBox(textdraw_1, 0);
		TextDrawSetProportional(textdraw_1, 1);
		TextDrawSetSelectable(textdraw_1, 0);
	}
	return 1;
}
This is how the original looks like
Код:
public sekunde()
{
	new string[128];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(i))continue;
		if(!IsPlayerInAnyVehicle(i))continue;
		format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
		GameTextForPlayer(i, string, 1000, 3);
	}
	return 1;
}
And i got more of the Textdraws but like i said i don't know where i need to put them


Re: How do i add Textdraws in a Gamemode? - ForCop - 27.03.2018

Quote:
Originally Posted by BrightLeaN
Посмотреть сообщение
Hey,
So i made something with a Textdraweditor and got some codes, idk where do i need to put them they just don't show up

So this is what i edited from a tutorial,
Код:
public sekunde()
{
	new string[128];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(i))continue;
		if(!IsPlayerInAnyVehicle(i))continue;
		format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
		textdraw_1 = TextDrawCreate(556.000000, 337.000000, "string");
		TextDrawFont(textdraw_1, 2);
		TextDrawLetterSize(textdraw_1, 0.429166, 2.049999);
		TextDrawTextSize(textdraw_1, 400.000000, 17.000000);
		TextDrawSetOutline(textdraw_1, 1);
		TextDrawSetShadow(textdraw_1, 0);
		TextDrawAlignment(textdraw_1, 1);
		TextDrawColor(textdraw_1, 1296911871);
		TextDrawBackgroundColor(textdraw_1, 255);
		TextDrawBoxColor(textdraw_1, 50);
		TextDrawUseBox(textdraw_1, 0);
		TextDrawSetProportional(textdraw_1, 1);
		TextDrawSetSelectable(textdraw_1, 0);
	}
	return 1;
}
This is how the original looks like
Код:
public sekunde()
{
	new string[128];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(i))continue;
		if(!IsPlayerInAnyVehicle(i))continue;
		format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
		GameTextForPlayer(i, string, 1000, 3);
	}
	return 1;
}
And i got more of the Textdraws but like i said i don't know where i need to put them
Код:
new Text:textdraw_1[MAX_PLAYERS];


public OnGameModeInit()
{
	for(new i=0; i<MAX_PLAYERS; i++)  // we add at the end OnGameModeInit
	{
		textdraw_1[i] = TextDrawCreate(556.000000, 337.000000, "");
		TextDrawFont(textdraw_1[i], 2);
		TextDrawLetterSize(textdraw_1[i], 0.429166, 2.049999);
		TextDrawTextSize(textdraw_1[i], 400.000000, 17.000000);
		TextDrawSetOutline(textdraw_1[i], 1);
		TextDrawAlignment(textdraw_1[i], 1);
		TextDrawColor(textdraw_1[i], 1296911871);
		TextDrawBoxColor(textdraw_1[i], 50);
		TextDrawSetProportional(textdraw_1[i], 1);
	}
	SetTimer("sekunde",90, true);
	return true;
}
forward sekunde();
public sekunde()
{
	new string[15];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(i) && !IsPlayerInAnyVehicle(i)) continue;
		format(string,sizeof(string),"%ikm/h", getPlayerSpeed(i));
		TextDrawSetString(textdraw_1[i], string);
	}
	return true;
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
	if(newstate == PLAYER_STATE_DRIVER)  TextDrawShowForPlayer(playerid, textdraw_1[playerid]);
	if(oldstate == PLAYER_STATE_DRIVER)  TextDrawHideForPlayer(playerid, textdraw_1[playerid]);
	return true;
}

public OnPlayerDisconnect(playerid, reason) {
	TextDrawHideForPlayer(playerid, textdraw_1[playerid]);
	return true;
}



Re: How do i add Textdraws in a Gamemode? - BrightLeaN - 27.03.2018

Thank you for helping me,
i changed the code with yours now, but i get an error btw. its a speedometer
Код:
(658) : error 029: invalid expression, assumed zero
(659) : error 001: expected token: ";", but found "{"
(662) : error 028: invalid subscript (not an array or too many subscripts): "textdraw_1"
(662) : warning 215: expression has no effect
(662) : error 001: expected token: ";", but found "]"
(662) : error 029: invalid expression, assumed zero
(662) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.



Re: How do i add Textdraws in a Gamemode? - ForCop - 27.03.2018

Quote:
Originally Posted by BrightLeaN
Посмотреть сообщение
Thank you for helping me,
i changed the code with yours now, but i get an error btw. its a speedometer
Код:
(658) : error 029: invalid expression, assumed zero
(659) : error 001: expected token: ";", but found "{"
(662) : error 028: invalid subscript (not an array or too many subscripts): "textdraw_1"
(662) : warning 215: expression has no effect
(662) : error 001: expected token: ";", but found "]"
(662) : error 029: invalid expression, assumed zero
(662) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
delete the code that you wrote in the gamemode that you indicated above!
then add mine.


Re: How do i add Textdraws in a Gamemode? - BrightLeaN - 27.03.2018

Код:
(660) : error 028: invalid subscript (not an array or too many subscripts): "textdraw_1"
(660) : warning 215: expression has no effect
(660) : error 001: expected token: ";", but found "]"
(660) : error 029: invalid expression, assumed zero
(660) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Код:
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		textdraw_1[i] = TextDrawCreate(556.000000, 337.000000, "");
		TextDrawFont(textdraw_1[i], 2);
		TextDrawLetterSize(textdraw_1[i], 0.429166, 2.049999);
		TextDrawTextSize(textdraw_1[i], 400.000000, 17.000000);
		TextDrawSetOutline(textdraw_1[i], 1);
		TextDrawAlignment(textdraw_1[i], 1);
		TextDrawColor(textdraw_1[i], 1296911871);
		TextDrawBoxColor(textdraw_1[i], 50);
		TextDrawSetProportional(textdraw_1[i], 1);
	}
	SetTimer("sekunde",90, true);
	return 1;
}
also on the top i did new textdraw_01;
That is so wierd


Re: How do i add Textdraws in a Gamemode? - ForCop - 27.03.2018

you add this? new Text:textdraw_1[MAX_PLAYERS];

you have "new Text:textdraw_1;", remove plase.

I've already said to delete everything you wrote about this textdraw


Re: How do i add Textdraws in a Gamemode? - BrightLeaN - 27.03.2018

Thank you alot!♥, i got 3 more Texdraws but without any function for now like in which car is the person and stuff, how should i add these or are they any tutorials about a full speedo?


Re: How do i add Textdraws in a Gamemode? - ForCop - 27.03.2018

Quote:
Originally Posted by BrightLeaN
Посмотреть сообщение
Thank you alot!♥, i got 3 more Texdraws but without any function for now like in which car is the person and stuff, how should i add these or are they any tutorials about a full speedo?
yes, getPlayerSpeed(playerid) you have this function?


Re: How do i add Textdraws in a Gamemode? - BrightLeaN - 27.03.2018

yeah i got getPlayerSpeed, that is how the speedo is made


Re: How do i add Textdraws in a Gamemode? - ForCop - 27.03.2018

Quote:
Originally Posted by BrightLeaN
Посмотреть сообщение
yeah i got getPlayerSpeed, that is how the speedo is made
ok success.