Team Count Txtdraw - 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: Team Count Txtdraw (
/showthread.php?tid=427023)
Team Count Txtdraw -
(_AcE_) - 31.03.2013
How do I make a textdraw to show the count of the players on each team? I have this:
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;?
Re: Team Count Txtdraw -
Pottus - 31.03.2013
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.
Re: Team Count Txtdraw -
(_AcE_) - 31.03.2013
What about if I put it in OnPlayerUpdate? Will it update or shall I set a timer to update every textdraw?
Re: Team Count Txtdraw -
Pottus - 31.03.2013
You only need to update in two places, when a player leaves and when a player joins OnPlayerUpdate() is not appropriate for this.
Re: Team Count Txtdraw -
(_AcE_) - 31.03.2013
Ok, I have a /switchteams but I understand. Thanks alot!
Re: Team Count Txtdraw -
Neil. - 31.03.2013
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.