SA-MP Forums Archive
TextDraws as server variable?? How to i change to Player Variable? - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: TextDraws as server variable?? How to i change to Player Variable? (/showthread.php?tid=139617)



TextDraws as server variable?? How to i change to Player Variable? - DarrenReeder - 05.04.2010

Hello, i have created a /stats sort of thing on the side of the screen with textdraws. I would like to know how i make the textdraw's different for EVery player on the server. at the moment the textdraw is a 'server variable' (i think?) and when one person updates the textdraw, it updates for everyone...

They are set as this:

Code:
new Text:TextDraw;
although i would like it to be somthing like

Code:
new Text:TextDraw[MAX_PLAYERS];
but this gets errors....any help would be great, thankS!


Re: TextDraws as server variable?? How to i change to Player Variable? - DarrenReeder - 05.04.2010

-bump-


Re: TextDraws as server variable?? How to i change to Player Variable? - Babul - 06.04.2010

on top of script (not in any function, place it between or in front of them):
Code:
new Text:TDStatus[MAX_PLAYERS];
a string for a textdraw must not be initialised empty, so dont forget the "_":
Code:
public OnGameModeInit()
{
	for(new p=0;p<GetMaxPlayers();p++)
	{
		TDStatus[p]=TextDrawCreate(0,421,"_");
		TextDrawLetterSize(TDStatus[p],0.20,0.80);
		TextDrawFont(TDStatus[p],2);
		TextDrawSetProportional(TDStatus[p],0);
		TextDrawSetShadow(TDStatus[p],0);
		TextDrawSetOutline(TDStatus[p],1);
	}
}
to show it up, you 1st need to set a string into it with format(), then show it to the desired player:
Code:
	new TDString[256];//those strings can be very long
	format(TDString,sizeof(TDString),"~b~~h~~h~Title~n~~w~your playerID: %d~n~",playerid);
	TextDrawSetString(TDStatus[playerid],TDString);
	TextDrawShowForPlayer(playerid,TDStatus[playerid]);
	ShowTDStatus(playerid);
i hope i didnt forget something...