Changing textdraw
#1

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

you need to use SetPlayerTeam, GetPlayerTeam and a Timer to do that
Reply
#3

Yeah, sure, but I want to know how to make, that the textdraw would always update.
Reply
#4

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

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

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

Yes, this is what I need. Thank you a lot.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)