Time saving
#1

Just wondering how you would make it so it saves the time. Ive managed to get it to load just not save. My time is like the proper game 1 minute = 1 hour and 1 second = 1 minute. This is for Pen1. So far Ive got
pawn Код:
new wtime = 18;
new timetimer;
Then under ongamemodeintit
pawn Код:
public OnGameModeInit()
{
    LoadConfig();
    LoadTmp();
    LoadProperty();
    LoadBizz();
    LoadSBizz();
    //PlayerHaul[78][pLoad] = 10000;
    PlayerHaul[78][pCapasity] = 10;
    //PlayerHaul[79][pLoad] = 10000;
    PlayerHaul[79][pCapasity] = 10;
    //PlayerHaul[80][pLoad] = 10000;
    PlayerHaul[80][pCapasity] = 10;
    //PlayerHaul[81][pLoad] = 10000;
    PlayerHaul[81][pCapasity] = 10;
    SetGameModeText("Public Enemy: LS");
    format(objstore, sizeof(objstore), "MOLE: I Got Nothin, Check Back With Me Later.");
    format(cbjstore, sizeof(cbjstore), "HQ: There is Nothing in Your Vicinity, Out.");
    gettime(ghour, gminute, gsecond);
    FixHour(ghour);
    ghour = shifthour;
    SetTimer("CheckTime", 1000, 1);
    new string2[64];
    format(string2, sizeof(string2), "Time.cer");
    new File: file = fopen(string2, io_read);
    new valtmp[128];
    fread(file, valtmp);TimeInfo[_h] = strval(valtmp);DelPrint(valtmp);
    fread(file, valtmp);TimeInfo[minuty] = strval(valtmp);DelPrint(valtmp);
     fclose(file);
     SetWorldTimeEx(TimeInfo[_h],TimeInfo[minuty]);
    AllowInteriorWeapons(1);
    EnableTirePopping(1);
    EnableZoneNames(1);
    if(!realtime)
    {
        SetWorldTime(wtime);
    }
    ShowPlayerMarkers(0);
    ShowNameTags(0);
Under Gamemodeintit again
pawn Код:
synctimer = SetTimer("SyncUp", 1000, 1);
    newmistimer = SetTimer("PrePlayerNewMission", jobdelay, 1);
    unjailtimer = SetTimer("SetPlayerUnjail", 1000, 1);
    if (nocasino)
    {
      playertimer = SetTimer("PlayerInArea", 1000, 1);
    }
    timetimer = SetTimer("CheckTime", 1000, 1);
    cartimer = SetTimer("CarCheck", 30000, 1);
    celltimer = SetTimer("CellPhoneTimer", 1000, 1);
    SetTimer("RingToner", 500, 0);
    SetTimer("SetPlayerFlash", 1000, 0);
    SetTimer("CustomPickups", 1000, 1);
    SetTimer("InHouse", 1000, 1);
    SetTimer("GameTicks", 500, 1);
    SetTimer("VoteKickTimer", 1000, 1);
    SetTimer("DMDetect", 1000, 1);
    SetTimer("Spectator", 2000, 1);
    SetTimer("PenInArea", 2000, 1);
    SetTimer("IdleKick", idletime, 1);
    SetTimer("AntiTeleport", 1000, 1);
    SetTimer("AntiCamp", 1000, 1);
    SetTimer("SkyDive", 1000, 1);
    SetTimer("Production", 300000, 1); //5 mins
     productiontimer = SetTimer("Production", 300000, 1); // 5 mins (300000)
Then Onplayerconnect
pawn Код:
SetPlayerTime(playerid,TimeInfo[_h],TimeInfo[minuty]);
TogglePlayerClock(playerid,2);
pawn Код:
public LoadTime(loaderid,const string[])
{
  new string2[64];
  new valtmp[128];
  format(string2, sizeof(string2), "Time.cer", string);
  new File: file = fopen(string2, io_read);
  if (file)
  {
      fread(file, valtmp);TlimeInfo[_hl] = strval(valtmp);DelPrint(valtmp);
      fread(file, valtmp);TlimeInfo[mlinuty] = strval(valtmp);DelPrint(valtmp);
  }
  return 1;
}

public SaveTime(loaderid,const string[])
{
  new string3[32];
  format(string3, sizeof(string3), "Time.cer", string);
  {
    new var[32];
    new File: hFile = fopen(string3, io_append);
    format(var, 32, "%d _h\n",TlimeInfo[_hl]);fwrite(hFile, var);
    format(var, 32, "%d minuty\n",TlimeInfo[mlinuty]);fwrite(hFile, var);
    fclose(hFile);
  }
  return 1;
}
pawn Код:
public GameModeInitExitFunc()
{
  if (gdebug >= 1){printf("DEBUG GameModeInitExitFunc()");}
  new string[128];
  format(string, sizeof(string), "Traveling...");
  for(new i = 0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i) == 1)
    {
      DisablePlayerCheckpoint(i);
      gPlayerCheckpointStatus[i] = CHECKPOINT_NONE;
      if (gdebug){print("DEBUG CHECKPOINT_NONE3");}
      GameTextForPlayer(i, string, 4000, 5);
      if (gdebug){printf("DEBUG %s", string);}
      SetPlayerCameraPos(i,1460.0, -1324.0, 287.2);
      SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0);
      OnPlayerUpdate(i);
      OnTimeUpdate(i);
      gPlayerLogged[i] = 0;
    }
  }
  SetTimer("GameModeExitFunc", 4000, 0);
  return 1;
}
pawn Код:
public GameModeExitFunc()
{
  KillTimer(synctimer);
  KillTimer(newmistimer);
  KillTimer(unjailtimer);
  KillTimer(playertimer);
  KillTimer(timetimer);
  KillTimer(cartimer);
  KillTimer(celltimer);
  KillTimer(productiontimer);
  GameModeExit();
  return 1;
 }
pawn Код:
public OnTimeUpdate(playerid)
{
  new string3[32];
  format(string3, sizeof(string3), "Time.cer");
  new var[32];
  new File: hFile = fopen(string3, io_write);
  GetPlayerTime(playerid,TimeInfo[_h],TimeInfo[minuty]);
  format(var, 32, "%d _h\n",TimeInfo[_h]);fwrite(hFile, var);
  format(var, 32, "%d minuty\n",TimeInfo[minuty]);fwrite(hFile, var);
  fclose(hFile);
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)