Score textdraw not working properly. -
rangerxxll - 24.03.2013
So I've created a textdraw under ongamodeinit, and set a timer to refresh it every 5 seconds. For some reason, when a player gets a kill(score) for his team, it updates both the TE and CE team to 1, instead of just the team that got the score. Here's my current code.
pawn Код:
forward TextDrawRefresh(playerid);
public TextDrawRefresh(playerid)
{
foreach(Player, i)
{
//CT
new string[128];
format(string,sizeof(string), "CT Score: %d",tscore[gTeam[i]]);
TextDrawSetString(TeamScoreCT, string);
TextDrawShowForPlayer(playerid, TeamScoreCT);
//TE
new tstring[128];
format(tstring,sizeof(tstring), "TE Score: %d",tscore[gTeam[i]]);
TextDrawSetString(TeamScoreTE, tstring);
TextDrawShowForPlayer(playerid, TeamScoreTE);
}
}
And under OnPlayerDeath.
pawn Код:
tscore[gTeam[killerid]]++;
new astring[128];
format(astring,sizeof(astring), "You have killed %s, and earned one score for your team. (Total Score: %d)",GetName(playerid),tscore[gTeam[killerid]]);
SendClientMessage(killerid,COLOR_CYAN, astring);
if(tscore[gTeam[killerid]] == 10)
{
winner = gTeam[killerid];
new pstring[128];
format(pstring,sizeof(pstring), "%s%s has won the round for %ss. Their team has earned 20k cash, and 20 score.",TeamColor(killerid), GetName(killerid), TeamName(killerid));
SendClientMessageToAll(COLOR_RED, pstring);
ChangeMode();
}
Thank you for your help.
EDIT: And its only updating when the enemy team gets a score.
Re: Score textdraw not working properly. - Patrick - 24.03.2013
nvm. can you show us how you define tscore?
Re: Score textdraw not working properly. -
rangerxxll - 24.03.2013
new tscore[MAX_PLAYERS];
Re: Score textdraw not working properly. - Patrick - 24.03.2013
if you are me i wont use
MAX_PLAYERS because its not needed
So here's my version just change the
/*Your CT Team Here*/ and
/*Your CT Team Here*/ to your team define
Here you go
pawn Код:
new Team1Kills=0;
new Team2Kills=0;
forward TextDrawRefresh(playerid);
public TextDrawRefresh(playerid)
{
foreach(Player, i)
{
//CT
new string[128];
format(string,sizeof(string), "CT Score: %i",Team1Kills);
TextDrawSetString(TeamScoreCT, string);
TextDrawShowForPlayer(playerid, TeamScoreCT);
//TE
new tstring[128];
format(tstring,sizeof(tstring), "TE Score: %i",Team2Kills);
TextDrawSetString(TeamScoreTE, tstring);
TextDrawShowForPlayer(playerid, TeamScoreTE);
}
}
public OnPlayerDeath(playerid, killerid, reason)
{
new astring[128];
if(gTeam[playerid] == /*Your CT Team Here*/)
{
Team1Kills++;
format(astring,sizeof(astring), "You have killed %s, and earned one score for your team. (Total Score: %d)",GetName(playerid),Team1Kills);
SendClientMessage(killerid,COLOR_CYAN, astring);
}
if(gTeam[playerid] == /*Your CT Team Here*/)
{
Team2Kills++;
format(astring,sizeof(astring), "You have killed %s, and earned one score for your team. (Total Score: %d)",GetName(playerid),Team2Kills);
SendClientMessage(killerid,COLOR_CYAN, astring);
}
if(Team2Kills == 10 || Team1Kills == 10)
{
winner = gTeam[killerid];
new pstring[128];
format(pstring,sizeof(pstring), "%s%s has won the round for %ss. Their team has earned 20k cash, and 20 score.",TeamColor(killerid), GetName(killerid), TeamName(killerid));
SendClientMessageToAll(COLOR_RED, pstring);
ChangeMode();
}
return 1;
}
Re: Score textdraw not working properly. -
rangerxxll - 24.03.2013
I'll make sure to test it out. So it's not possible to split one variable for two teams?
Re: Score textdraw not working properly. - Patrick - 24.03.2013
Im not sure if its possible. but i can't think of any idea. so i did that version using 2 normal variables