SA-MP Forums Archive
TextDraw's are showing the same for everyone? - 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: TextDraw's are showing the same for everyone? (/showthread.php?tid=141604)



TextDraw's are showing the same for everyone? - DarrenReeder - 14.04.2010

hello, i am trying to make some textdraws that show the players stats (Gun materials to be exact..) and it shows in the bottom right hand corner of the screen. however the problem i have run into is that it shows the same information for everyone...anyone think they can help out? this is my code..

http://pastebin.com/4cE5Uxr2


Re: TextDraw's are showing the same for everyone? - SpiderPork - 14.04.2010

Because they're global. You have to make them for every player (new Example[MAX_PLAYERS]; ).


Re: TextDraw's are showing the same for everyone? - DarrenReeder - 14.04.2010

Quote:
Originally Posted by SpiderPork
Because they're global. You have to make them for every player (new Example[MAX_PLAYERS]; ).
Yes i tried that but it doesnt let me use

new Text:textdraw[MAX_PLAYERS]; but then i dont know what to put with ongamemodeinit?


Re: TextDraw's are showing the same for everyone? - Correlli - 14.04.2010

It's because you're using the same textdraw-variable for everyone.

pawn Код:
/* textdraw-variable */
Text:myTextdraw[MAX_PLAYERS];
pawn Код:
/* show player textdraw to the player */
TextDrawShowForPlayer(playerid, myTextdraw[playerid]);
Create it at OnPlayerConnect:
pawn Код:
/* create player textdraw */
myTextdraw[playerid] = TextDrawCreate(437.000000, 248.000000, "My Textdraw");
Destroy it at OnPlayerDisconnect:
pawn Код:
/* destroy player textdraw */
TextDrawDestroy(playerid, myTextdraw[playerid]);



Re: TextDraw's are showing the same for everyone? - Thrarod - 14.04.2010

Yeah that will show for player only


Re: TextDraw's are showing the same for everyone? - DarrenReeder - 14.04.2010

aha, i can create it for onplayerconnect...didnt realise, on samp wiki it said to create it at ongamemodeinit... (thats why i had problems with the [MAX_PLAYERS] thing)..

Thanks,

P.S.
this is my first time using textdraws


Re: TextDraw's are showing the same for everyone? - Thrarod - 14.04.2010

Your welcome


Re: TextDraw's are showing the same for everyone? - Correlli - 14.04.2010

Quote:
Originally Posted by DarrenReeder - LSR:GTA, Owner
aha, i can create it for onplayerconnect...didnt realise, on samp wiki it said to create it at ongamemodeinit... (thats why i had problems with the [MAX_PLAYERS] thing)..
That is correct if you are creating a textdraw for everyone, like a textdraw with link of your website (www.mywebsite.com), but in player case you should use OnPlayerConnect.

You could use a loop for MAX_PLAYERS or GetMaxPlayers() and create all textdraws at once in OnGameModeInit, but that isn't a good idea. It's best if you create it at OnPlayerConnect and destroy it at OnPlayerDisconnect.


Re: TextDraw's are showing the same for everyone? - Thrarod - 14.04.2010

And if you dont destroy textdraw on OnPlayerDisconnect other player may get affected by that


Re: TextDraw's are showing the same for everyone? - Correlli - 14.04.2010

Quote:
Originally Posted by Thrarod
And if you dont destroy textdraw on OnPlayerDisconnect other player may get affected by that
You'll exceed sa:mp textdraw limit in that case, which is 2048 textdraws.