21.11.2012, 08:25
(
Последний раз редактировалось Fernado Samuel; 04.10.2013 в 18:20.
)
Removed
pTimes[MAX_PLAYERS]; // Top of the script
forward SecondTimer(); // Top of the script
SetTimer("SecondTimer", 1000, 1); // Below OnGameModeInit()
public SecondTimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && pInfo[playerid][pLogged] == true) // I'm not sure, is your variable pLogged or not.
{
pTimes[i]++;
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new string[128];
// Example 'users' is your tablename, you can change it
format(string, sizeof(string), "UPDATE users SET times = '%d' WHERE username = '%s'", pTimes[playerid], PlayerName(playerid));
mysql_query(string);
return 1;
}
pTimes[playerid] / 24; // 24 = minutes, example the player has played 86 Minutes, 86 / 24 = 3,5 the server converts it to integer automatically, so it's 3 Game Days
pTimes[playerid] / 1140; // A day has 1140 minutes, 60 * 24 = 1140:
new pJoined[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
new pJoined[playerid] = gettime();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new value = gettime() - pJoined[playerid];
printf("The player has played %d minutes.", value);
return 1;
}