02.08.2014, 11:47
I have this code in my GM but the stats is not getting updated instead it gets NULL as string in game.
Note: The textdraw (tStats[]) shows before StatsUpdater() is called. Once StatsUpdater is called, the string becomes empty.
I apologies for my bad English.
Note: The textdraw (tStats[]) shows before StatsUpdater() is called. Once StatsUpdater is called, the string becomes empty.
pawn Код:
#define FUNC:%1(%2) forward %1(%2); public %1(%2)
new
Text:WebsiteURL,
Text:BlackBox,
Text:WhiteLine,
Text:TxtDate,
PlayerText:tStats[MAX_PLAYERS]
;
public OnGameModeInit()
{
BlackBox = TextDrawCreate(656.399536, 433.073364, "usebox");
TextDrawLetterSize(BlackBox, 0.000000, 1.277409);
TextDrawTextSize(BlackBox, -4.399999, 0.000000);
TextDrawAlignment(BlackBox, 1);
TextDrawColor(BlackBox, 0);
TextDrawUseBox(BlackBox, true);
TextDrawBoxColor(BlackBox, 255);
TextDrawSetShadow(BlackBox, 0);
TextDrawSetOutline(BlackBox, 0);
TextDrawBackgroundColor(BlackBox, 170);
TextDrawFont(BlackBox, 0);
TxtDate = TextDrawCreate(637.599426, 433.813323, "6/10/2014");
TextDrawLetterSize(TxtDate, 0.323600, 0.898132);
TextDrawAlignment(TxtDate, 3);
TextDrawColor(TxtDate, -1);
TextDrawSetShadow(TxtDate, 0);
TextDrawSetOutline(TxtDate, 1);
TextDrawBackgroundColor(TxtDate, 51);
TextDrawFont(TxtDate, 1);
TextDrawSetProportional(TxtDate, 1);
WhiteLine = TextDrawCreate(668.399536, 432.326568, "usebox");
TextDrawLetterSize(WhiteLine, 0.000000, -0.565554);
TextDrawTextSize(WhiteLine, -13.200004, 0.000000);
TextDrawAlignment(WhiteLine, 1);
TextDrawColor(WhiteLine, 0);
TextDrawUseBox(WhiteLine, true);
TextDrawBoxColor(WhiteLine, -1061109505);
TextDrawSetShadow(WhiteLine, 0);
TextDrawSetOutline(WhiteLine, 0);
TextDrawFont(WhiteLine, 0);
SetTimer("StatsUpdater", 1000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
tStats[playerid] = CreatePlayerTextDraw(playerid, 4.799985, 433.813354, "Stats");
PlayerTextDrawLetterSize(playerid, tStats[playerid], 0.276399, 0.957865);
PlayerTextDrawAlignment(playerid, tStats[playerid], 1);
PlayerTextDrawColor(playerid, tStats[playerid], -1);
PlayerTextDrawSetShadow(playerid, tStats[playerid], 0);
PlayerTextDrawSetOutline(playerid, tStats[playerid], -1);
PlayerTextDrawBackgroundColor(playerid, tStats[playerid], 51);
PlayerTextDrawFont(playerid, tStats[playerid], 1);
PlayerTextDrawSetProportional(playerid, tStats[playerid], 1);
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
TextDrawShowForPlayer(playerid, WebsiteURL);
PlayerTextDrawShow(playerid, tStats[playerid]);
TextDrawShowForPlayer(playerid, BlackBox);
TextDrawShowForPlayer(playerid, WhiteLine);
TextDrawShowForPlayer(playerid, TxtDate);
TextDrawShowForPlayer(playerid, ZoneName[playerid]);
return 1;
}
FUNC:StatsUpdater()
{
for(new i=0; i < GetMaxPlayers(); i++) {
if(IsPlayerConnected(i)) {
new string[128], Float:health,Float:armour; GetPlayerHealth(i, health); GetPlayerArmour(i, armour);
format(string,128,"Name: %s | H: %f | A: %f | Score: %d | Kills: %d | Deaths: %d | Rank: (%d) %s",PlayerName(i),health,armour,GetPlayerScore(i),pInfo[i][Kills],pInfo[i][Deaths],pInfo[i][RankID],pInfo[i][RankName]);
PlayerTextDrawSetString(i, tStats[i], string);
PlayerTextDrawShow(i,tStats[i]);
}
}
return 1;
}