playerd hours system problem
#1

it shows me 0 seconds 0 minutes played when im checking with the /time cmd,here's all i have on the system

CMD:time(playerid, params[])
{
new string[80];
format(string, sizeof(string),"*You've been connected for {ff0000}%0.0f {ffffff}seconds ({00ffff}%0.0f {ffffff}minutes)", PlayerInfo[playerid][pTimeConnected], PlayerInfo[playerid][pTimeConnected]/60);
SendClientMessage(playerid, -1, string);
return 1;
}


CMDayday(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have acces");
foreach(Player, i)
{

new string[128];

format(string, sizeof(string), " You recived %0.2f played hours", PlayerInfo[playerid][pTimeConnected]/3600);
SendClientMessage(i, COLOR_GREEN2, string);




PlayerInfo[playerid][pHours] += PlayerInfo[playerid][pTimeConnected]/3600;
PlayerInfo[playerid][pTimeConnected] = 0;


UpdateVariable(i, pHoursx);
UpdateVariable(i, pTimeConnectedx);
}
return 1;

}

here's where the played time is calculated(this is part of a function,that is used on a timer that repeats every second,and no. the problem is not here because the timer works,im using it for many other things that work,and the afk time works,if im not moving the afk time goes up as it should,but if it's under 5 the time connected does't go up for some reason)

GetPlayerPos(i, PositionAFK[i][0], PositionAFK[i][1], PositionAFK[i][2]);

if(PositionAFK[i][0] == PositionAFK[i][4] && PositionAFK[i][1] == PositionAFK[i][5] && PositionAFK[i][2] == PositionAFK[i][6])
{
PlayerAFK[i]++;
}
else PlayerAFK[i] = 0;

PositionAFK[i][4] = PositionAFK[i][0];
PositionAFK[i][5] = PositionAFK[i][1];
PositionAFK[i][6] = PositionAFK[i][2];

if(PlayerAFK[i] < 5) PlayerInfo[i][pTimeConnected]++;
Reply
#2

As you said above (but if it's under 5 the time connected does't go up for some reason), is probably because of this part of your code, this conditional command will only work if your AFK time is less than 5, so when it reaches 5, it will return FALSE, since 5 is not less than 5.

Код:
if(PlayerAFK[i] < 5) PlayerInfo[i][pTimeConnected]++;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)