Team Count Txtdraw
#1

How do I make a textdraw to show the count of the players on each team? I have this:
pawn Код:
bluecount++;
redcount++;
For when they spawn and I have it check to see what team they are when they leave and i do bluecount--; or the opposite OnPlayerDisconnect.

How will I make that a value to add on textdraws? I would like it to say:

TEAMS: 3 / 4

Say there are 3 blue team members and 4 red team members.

Will it be like this:

"TEAMS: %s / %s", bluecount, redcount

I did this but they never showed up. Should I start off by putting ongamemodeinit bluecount = 0; and redcount=0;?
Reply
#2

Basically you need to show the textdraw TextDrawShowForPlayer(playerid, TextDraw); for the player when they connect then keep setting the textdraw string TextDrawSetString(TextDraw, string); as players connect and disconnect and it will update the textdraw for every player.
Reply
#3

What about if I put it in OnPlayerUpdate? Will it update or shall I set a timer to update every textdraw?
Reply
#4

You only need to update in two places, when a player leaves and when a player joins OnPlayerUpdate() is not appropriate for this.
Reply
#5

Ok, I have a /switchteams but I understand. Thanks alot!
Reply
#6

Here's an example of how you do it.

Set blue and red teams = 0 on OnGameModeInit
If a player connected, (I assume you have your teams classified onto Dialogs) so on your dialogs, if a player picks the blue one, then blue++, likewise if it's red; red++.
Now, on OnPlayerSpawn, use set a Global Textdraw which updates only once a player connects (TextDrawSetString on OnPlayerConnect).

Something like this:
pawn Код:
new txt[7];
format(txt,7,"%d/%d", blue, red);
TextDrawSetString(yourtdvar, txt);
Then onplayerdisconnect, check if the player who disconnected is on blue (then blue--) otherwise (red--) and update your global td once again.

Never use OPU on such occasion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)