Played Time won`t save.
#1

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Seconds",PlayerInfo[playerid][pSeconds]);
    INI_WriteInt(File,"Minutes",PlayerInfo[playerid][pMinutes]);
    INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]);
    INI_WriteInt(File,"Days",PlayerInfo[playerid][pDays]);
    INI_WriteString(File, "Ip",GetPlayerIPEx(playerid));
    INI_Close(File);
    return 1;
}
After logging off seconds,minutes,hours,days are all 0
Reply
#2

pawn Код:
forward timetimer();
public timetimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        PlayerInfo[i][pSeconds] ++;
        if(PlayerInfo[i][pSeconds] == 60)
        {
            PlayerInfo[i][pMinutes] ++;
            PlayerInfo[i][pSeconds] = 0;
        }
        if(PlayerInfo[i][pMinutes] == 60)
        {
            PlayerInfo[i][pHours] ++;
            PlayerInfo[i][pMinutes] = 0;
        }
        if(PlayerInfo[i][pHours] == 24)
        {
            PlayerInfo[i][pDays] ++;
            PlayerInfo[i][pHours] = 0;
        }
    }
    return 1;
}
pawn Код:
enum pInfo
{
    pPass,
    pScore,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pBanned,
    pCookies,
    pVip,
    pSpawnVehicle,
    pIp,
    pSeconds,
    pMinutes,
    pHours,
    pDays
}
Reply
#3

Anyone?
Reply
#4

Instead of increasing variables, I would use gettime() and take the difference from the previous variable and make an addition. This would save you from using a timer.
Reply
#5

How do i do it with Gettime()?
Reply
#6

Quote:
Originally Posted by Audi_Quattrix
Посмотреть сообщение
How do i do it with Gettime()?
I am on phoe so don't expect much.

Onplayerconnect



new Hour, Minute, Second;
gettime(Hour, Minute, Second)
#pragma unused Hour
#pragma unused Second
Time[playerid] = Minute;

Then, when they leave take the minute again and the difference between Time[pid] and the time they left. Add it as var totheir data you can make it work under a fixed timer or so. If they joined on minute 59 and leave on 03 you'll have a negative number. So you would need to calculate that aswell

Thats anexample. All would work. Gettime will get the servers time in a format like hour:minuteecond
Reply
#7

pawn Код:
stock TotalGameTime(playerid, &h=0, &m=0, &s=0)
{
    PlayerInfo[playerid][pTotalTime] =
    (
        (gettime() - PlayerInfo[playerid][pConnectTime]) + (PlayerInfo[playerid][pHours]*60*60) + (PlayerInfo[playerid][pMinutes]*60) + (PlayerInfo[playerid][pSeconds])
    );

    h = floatround(PlayerInfo[playerid][pTotalTime] / 3600, floatround_floor);
    m = floatround(PlayerInfo[playerid][pTotalTime] / 60,   floatround_floor) % 60;
    s = floatround(PlayerInfo[playerid][pTotalTime] % 60,   floatround_floor);
    return PlayerInfo[playerid][pTotalTime];
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new h, m, s;
    TotalGameTime(playerid, h, m, s);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Seconds",s);
    INI_WriteInt(File,"Minutes",m);
    INI_WriteInt(File,"Hours",h);
    INI_WriteString(File, "Ip",GetPlayerIPEx(playerid));
    INI_Close(File);
    aDuty[playerid] = 0;
    God[playerid] = 0;
    Warns[playerid] = 0;
    Jailed[playerid] = 0;
    Muted[playerid] = 0;
    KillTimer(JailTime[playerid]);
    return 1;
}
Still the same problem
Reply
#8

Bump
Reply
#9

Show us where you start the timer and load the files of the player once he connects.
Reply
#10

I dont use Timer anymore.
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    INI_Int("Cookies",PlayerInfo[playerid][pCookies]);
    INI_Int("Vip",PlayerInfo[playerid][pVip]);
    INI_Int("Seconds",PlayerInfo[playerid][pSeconds]);
    INI_Int("Minutes",PlayerInfo[playerid][pMinutes]);
    INI_Int("Hours",PlayerInfo[playerid][pHours]);
    return 1;
}
pawn Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
Reply
#11

Still not fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)