TextDraw's are showing the same for everyone?
#1

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

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

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

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]);
Reply
#5

Yeah that will show for player only
Reply
#6

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

Your welcome
Reply
#8

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)