Changing textdraw - 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: Changing textdraw (
/showthread.php?tid=349826)
Changing textdraw -
lithuania154 - 10.06.2012
Hello, I have a problem. I need a textdraw which shows how many players are in team blue. For example, all server see's how many players are on team blue, but when anyone writes command /blue, that number pluses by one.
Re: Changing textdraw -
JaKe Elite - 10.06.2012
you need to use SetPlayerTeam, GetPlayerTeam and a Timer to do that
Re: Changing textdraw -
lithuania154 - 10.06.2012
Yeah, sure, but I want to know how to make, that the textdraw would always update.
Re: Changing textdraw -
ReVo_ - 10.06.2012
pawn Код:
new
g_Blues = 0,
Text:g_Textdraw
;
if(strcmp(cmdtext, "/blue", true) == 0)
{
if(GetPVarInt(playerid, "blue") == 1) return 1; // Why add one again if the player already did this command
SetPVarInt(playerid, "blue", 1);
g_Blues++;
new TD_String[20];
format(TD_String, sizeof TD_String, "Blue: %d", g_Blues);
TextDrawSetString(g_Textdraw, TD_String);
return 1;
}
You want this?
or you want to count how much players are in team blue without the command /blue?
Re: Changing textdraw -
ReVo_ - 10.06.2012
pawn Код:
new Text:g_Textdraw;
#define TEAM_BLUE 1
public OnPlayerSpawn(playerid) {
new
g_Blue
;
for(new i = 0, j = GetMaxPlayers(); i < j; i++) {
if(GetPlayerTeam(i) == TEAM_BLUE) {
g_Blue ++;
}
}
new TD_String[20];
format(TD_String, sizeof TD_String, "Blue: %d", g_Blue);
TextDrawSetString(g_Textdraw, TD_String);
}
or this?
and if u change team of a player with a command create a function with this code.. exemple:
pawn Код:
stock UpdateTD() {
new
g_Blue
;
for(new i = 0, j = GetMaxPlayers(); i < j; i++) {
if(GetPlayerTeam(i) == TEAM_BLUE) {
g_Blue ++;
}
}
new TD_String[20];
format(TD_String, sizeof TD_String, "Blue: %d", g_Blue);
TextDrawSetString(g_Textdraw, TD_String);
}
in OnPlayerSpawn: UpdateTD();
in ur function UpdateTD();
remember to use SetPlayerTeam for teams..
Re : Changing textdraw -
ricardo178 - 10.06.2012
Set a timer that updates every 3 second.
Use a "for" to loop tough all players,
Gettheir team,
format a string with it,
set textdraw string to it.
Re: Changing textdraw -
lithuania154 - 10.06.2012
Yes, this is what I need. Thank you a lot.