public UpdateStats(playerid)
{
for(new i; i < MAX_PLAYERS; i++)// this is to find the playerid
{
if(IsPlayerConnected(i))
{
i = playerid;
}
}
new
str[128],
Float:ratio,
k,d;
if((PlayerInfo[playerid][Kills] != 0) && PlayerInfo[playerid][Deaths] == 0)//just a script to work out a kill death ratio
{
ratio = 100.00;
}
else
{
ratio = floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]);
}
k = PlayerInfo[playerid][Kills];
d = PlayerInfo[playerid][Deaths];
format(str,sizeof(str),"~r~K: ~w~%d | ~r~D: ~w~%d | ~r~K/D: ~w~%.2f ",k,d,ratio);
TextDrawSetString(TotalStats[playerid],str);
SendClientMessage(playerid,WHITE,str);
return 1;
}
public UpdateStats(playerid)
{
for(new i; i < MAX_PLAYERS; i++)// this is to find the playerid
{
if(IsPlayerConnected(i))
{
i = playerid;
}
}
new
str[128],
Float:ratio,
k,d;
if((PlayerInfo[playerid][Kills] != 0) && PlayerInfo[playerid][Deaths] == 0)//just a script to work out a kill death ratio
{
ratio = 100.00;
}
else
{
ratio = floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]);
}
k = PlayerInfo[playerid][Kills];
d = PlayerInfo[playerid][Deaths];
format(str,sizeof(str),"~r~K: ~w~%d | ~r~D: ~w~%d | ~r~K/D: ~w~%.2f ",k,d,ratio);
TextDrawSetString(TotalStats[playerid],str);
SendClientMessage(playerid,WHITE,str);
TextDrawShowForPlayer(playerid, str); //Add this
return 1;
}
..But I like to hear the "I'll keep trying" spirit!
public OnPlayerConnect(playerid)
{
TotalStats[playerid] = TextDrawCreate(10.000000,432.000000," Loading stats.... ");
TextDrawColor(TotalStats[playerid],0xFFFFFFFF); //color of the words
TextDrawUseBox(TotalStats[playerid],true);
TextDrawBoxColor(TotalStats[playerid],0x000000AA);
TextDrawFont(TotalStats[playerid],1);
TextDrawSetOutline(TotalStats[playerid],true);
TextDrawBackgroundColor(TotalStats[playerid],255); //color of the shadow
TextDrawTextSize(TotalStats[playerid],640.0,480.0);
TextDrawLetterSize(TotalStats[playerid],0.4,1.2);
|
My goal is to have 1 global timer that updates every persons stats at the same time.
|
forward UpdateStats();
public UpdateStats()
{
for(new i; i < MAX_PLAYERS; i++)
{
new
str[128],
Float:ratio,
k,d;
if((PlayerInfo[i][Kills] != 0) && PlayerInfo[i][Deaths] == 0) //just a script to work out a kill death ratio
{
ratio = 100.00;
}
else
{
ratio = floatdiv(PlayerInfo[i][Kills], PlayerInfo[i][Deaths]);
}
k = PlayerInfo[i][Kills];
d = PlayerInfo[i][Deaths];
format(str,sizeof(str),"~r~K: ~w~%d | ~r~D: ~w~%d | ~r~K/D: ~w~%.2f ",k,d,ratio);
TextDrawSetString(TotalStats[i],str);
SendClientMessage(i,WHITE,str);
}
return 1;
}
public OnGameModeInit()
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
TotalStats[i] = TextDrawCreate(10.000000,432.000000," Loading stats.... ");
TextDrawColor(TotalStats[i],0xFFFFFFFF); //color of the words
TextDrawUseBox(TotalStats[i],true);
TextDrawBoxColor(TotalStats[i],0x000000AA);
TextDrawFont(TotalStats[i],1);
TextDrawSetOutline(TotalStats[i],true);
TextDrawBackgroundColor(TotalStats[i],255); //color of the shadow
TextDrawTextSize(TotalStats[i],640.0,480.0);
TextDrawLetterSize(TotalStats[i],0.4,1.2);
}
SetTimer("UpdateStats", 600, true);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, TotalStats[playerid]);
return 1;
}