Retrieving total playtime since registration! [MySQL]
#2

Do you have any code related to this or?

Код:
SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);

forward TimeOnServer(playerid);
public TimeOnServer(playerid)
{
PlayerInfo[playerid][Sec] ++;
if(PlayerInfo[playerid][Sec]>=60)
    {
        PlayerInfo[playerid][Min]++;
        PlayerInfo[playerid][Sec]=0;
    }
if(PlayerInfo[playerid][Min]>=60)
    {
        PlayerInfo[playerid][Min]=0;
        PlayerInfo[playerid][Hour]++;
    }
}
//and that's all you need to have a timer with [hours,mins,sec]

//This is to save it
INI_WriteInt(Acc,"Min",PlayerInfo[playerid][Min]);
INI_WriteInt(Acc,"Hour",PlayerInfo[playerid][Hour]);
INI_WriteInt(Acc,"Sec",PlayerInfo[playerid][Sec]);

//To load it
PlayerInfo[playerid][Min] = GetPVarInt(playerid, "Min");
PlayerInfo[playerid][Hour] = GetPVarInt(playerid, "Hour");
PlayerInfo[playerid][Sec] = GetPVarInt(playerid, "Sec");
Just exchange that INI into the SQL or w/e. I never worked with SQL


Just add the save variables under the OnPlayerSpawn, that's why if you have for example "Force registration" system.
Basically if you have dialogs etc. and player must register, he wont be able to spawn unless he is registered
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)