[HELP]Save problem
#1

Hallo!
Problem is this:
If i go to server and /q an join back then the time save
If i stop server and trun on then time not save :S
What is the problem?
pawn Код:
#include <a_samp>
#include <dini>
#include <zcmd>
#include <foreach>
#define COLOR_WHITE 0xFFFFFFFF
forward Hours();
forward Minutes();
forward IfCrashOrRestart(playerid);
enum pInfo
{
    pConnectTime,
    pConnectTime1,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new HoursTimer;
new MinutesTimer;

public OnGameModeInit()
{
    return 1;
}
public OnPlayerConnect(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new string[256], pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "Time/%s.ini", pname);
        dini_Set(string, "Hours", PlayerInfo[i][pConnectTime]);
        dini_Set(string, "Minutes", PlayerInfo[i][pConnectTime1]);
        dini_Create(string);
        HoursTimer = SetTimer("Hours",3600000, true);
        MinutesTimer = SetTimer("Minutes", 60000, true);
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new file[128], pname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(file, sizeof(file), "Time/%s.ini", pname);
        if(!dini_Exists(file))
        dini_Create(file);
        dini_IntSet(file, "Hours", PlayerInfo[i][pConnectTime]);
        dini_IntSet(file, "Minutes", PlayerInfo[i][pConnectTime1]);
        KillTimer(HoursTimer);
        KillTimer(MinutesTimer);

        switch(reason)
        {
            case 0: IfCrashOrRestart(playerid);

        }
        return 1;

    }
    return 1;
}
command(time,playerid,params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new string[256];
        format(string, sizeof(string), "~r~%d ~w~hours and ~r~%d ~w~minutes.", PlayerInfo[i][pConnectTime],PlayerInfo[i][pConnectTime1]);
        GameTextForPlayer(playerid, string, 5000, 1);
        return 1;
    }
    return 1;
}
command(annajuurde,playerid,params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerInfo[i][pConnectTime1] += 1;
    return 1;
}
public Hours()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerInfo[i][pConnectTime] += 1;
    return 1;
}
public Minutes()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    PlayerInfo[i][pConnectTime1] += 1;
    return 1;
}

IfCrashOrRestart(playerid)
{
    new file[128], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "Time/%s.ini", pname);
    if(!dini_Exists(file))
    dini_Create(file);
    dini_IntSet(file, "Hours", PlayerInfo[playerid][pConnectTime]);
    dini_IntSet(file, "Minutes", PlayerInfo[playerid][pConnectTime1]);
    KillTimer(HoursTimer);
    KillTimer(MinutesTimer);

}
Reply
#2

no help?
Reply
#3

mm,
pawn Код:
enum PlayerData
{
hours,
mins,
};
Reply
#4

Kui sa eestlane kuhu ma panene selle?
Were i but this?
Reply
#5

Ok WORK:P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)