Team score textdraw problem
#1

Hello,i've created this textdraws to show the score of blue and red team,but it doesn't work!

Here is all:

pawn Код:
new Text:BTSTxd;
new Text:RTSTxd;
OnGameModeInit:

pawn Код:
for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, BTSTxd);
            TextDrawShowForPlayer(i, RTSTxd);
        }
    }
pawn Код:
BTSTxd = TextDrawCreate(505.000000, 303.000000, "Blue Team:");
    TextDrawBackgroundColor(BTSTxd, 255);
    TextDrawFont(BTSTxd, 2);
    TextDrawLetterSize(BTSTxd, 0.350000, 1.200000);
    TextDrawColor(BTSTxd, 1097465770);
    TextDrawSetOutline(BTSTxd, 1);
    TextDrawSetProportional(BTSTxd, 1);

    RTSTxd = TextDrawCreate(505.000000, 324.000000, "Red Team:");
    TextDrawBackgroundColor(RTSTxd, 255);
    TextDrawFont(RTSTxd, 2);
    TextDrawLetterSize(RTSTxd, 0.350000, 1.200000);
    TextDrawColor(RTSTxd, -16776961);
    TextDrawSetOutline(RTSTxd, 1);
    TextDrawSetProportional(RTSTxd, 1);
OnPlayerConnect:

pawn Код:
TextDrawShowForPlayer(playerid, BTSTxd);
    TextDrawShowForPlayer(playerid, RTSTxd);
And this is how the score of each team is counted (1 kill = 1 score for the team)

pawn Код:
forward TeamScore(playerid);
The timer on OnGameModeInit:

pawn Код:
ScoreTimer = SetTimer("TeamScore",1000,1);
And the public:

pawn Код:
public TeamScore()
{
    new BlueTeamScore[100];
    format(BlueTeamScore,sizeof(BlueTeamScore),"Blue Team: %d",TeamBlueScore);
    TextDrawSetString(BTSTxd,BlueTeamScore);
    new RedTeamScore[100];
    format(RedTeamScore,sizeof(RedTeamScore),"Red Team: %d",TeamRedScore);
    TextDrawSetString(RTSTxd,RedTeamScore);
    return 1;
}
OnPlayerDeath:

pawn Код:
if(GetPlayerTeam(killerid) == TEAM_BLUE)
{
TeamBlueScore ++;
}
if(GetPlayerTeam(killerid) == TEAM_RED)
{
TeamRedScore ++;
}
The problem is,it doesnt update the textdraws when a player from a team make a kill,it stays everytime on 0.

Thanks all for help!
Reply
#2

Put this in TeamScore, and kill someone
pawn Код:
printf("True values: %d:%d", TeamBlueScore, TeamRedScore);
It'll show up in server console
We need to be sure that scores are updated correctly
Reply
#3

I am not sure but I think you need to show players textdraw after you set string.
add this at the end of the public TeamScore()
Код:
for(new i; i < MAX_PLAYERS; i ++)
{
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, BTSTxd);
            TextDrawShowForPlayer(i, RTSTxd);
        }
}
and also the code above is useless in OnGameModeInit.
Reply
#4

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Put this in TeamScore, and kill someone
pawn Код:
printf("True values: %d:%d", TeamBlueScore, TeamRedScore);
It'll show up in server console
We need to be sure that scores are updated correctly
Thanks,10 minutes and i'll try,and i'll post the results.

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
I am not sure but I think you need to show players textdraw after you set string.
add this at the end of the public TeamScore()
Код:
for(new i; i < MAX_PLAYERS; i ++)
{
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, BTSTxd);
            TextDrawShowForPlayer(i, RTSTxd);
        }
}
and also the code above is useless in OnGameModeInit.
I've the code to show the textdraw.

Btw i've removed the code on OnGamemodeInit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)