08.08.2010, 23:05
Can somone show me an EXAMPLE, Not the whole thing, just an EXAMPLE Of how i would go about making a function to Save, Then Get, There total time online?
new TimerOwner[MAX_PLAYERS];
forward TimeOnlineCount(playerid);
KillTimer(TimerOwner[playerid]);
//your code.
TimerOwner[playerid] = SetTimerEx("TimeOnlineCount", 60000, 1, "i", playerid); //I use minutes in this.
public TimeOnlineCount(playerid)
{
File[playerid][TimeOnline]++; //Just replace this to whatever variable you use. Also, if you use an Admin System, add the variable "TimeOnline" or rename it, if you wish.
return 1;
}
//OnPlayerConnect
SetPVarInt(playerid, "CTime", GetTickCount());
//OnPlayerDisconnect - save to file using dini
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
dini_SetInt("Time.txt", name, (
dini_GetInt("Time.txt", name) +
floatround( ( ( GetTickCount() - GetPVarInt(playerid, "CTime") ) / 1000.0 ), floatround_floor)
)
);