SHARE
TWEET

Untitled

a guest Jun 12th, 2017 131 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Online Players Record v2 by teko96
  3. */
  4. #include <a_samp>
  5. new oplayers, Precord, Drecord, Mrecord, Yrecord, THrecord, TMrecord;
  6. new mname[][] = {"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"};
  7. public OnFilterScriptInit()
  8. {
  9.     LoadRecord();
  10.     oplayers=ConnectedPlayers();
  11.     print("\n--------------------------------------");
  12.     print("FS =Online Players Record= by Airkite, Loaded...");
  13.     print("--------------------------------------\n");
  14.     return 1;
  15. }
  16. public OnFilterScriptExit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print("FS =Online Players Record= by Airkite, Unloaded...");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23. public OnPlayerConnect(playerid)
  24. {
  25.     if(IsPlayerNPC(playerid)) { return 1; }
  26.     SetTimerEx("Record", 5000, false, "d", playerid);
  27.     return 1;
  28. }
  29. public OnPlayerDisconnect(playerid, reason)
  30. {
  31.     oplayers--;
  32.     return 1;
  33. }
  34. ///////////////////////////////////////////////////////////////////////////
  35. forward LoadRecord();
  36. public LoadRecord()
  37. {
  38.     new strFromFile[24], arrCoords[6][5], File: file = fopen("porecords", io_read);
  39.     if (file)
  40.     {
  41.         fread(file, strFromFile);
  42.         split(strFromFile, arrCoords, ',');
  43.         Precord = strval(arrCoords[0]);
  44.         Drecord = strval(arrCoords[1]);
  45.         Mrecord = strval(arrCoords[2]);
  46.         Yrecord = strval(arrCoords[3]);
  47.         THrecord = strval(arrCoords[4]);
  48.         TMrecord = strval(arrCoords[5]);
  49.         fclose(file);
  50.     }
  51.     return 1;
  52. }
  53. forward SaveRecord();
  54. public SaveRecord()
  55. {
  56.     new coordsstring[24];
  57.     format(coordsstring, sizeof(coordsstring), "%d,%d,%d,%d,%d,%d", Precord, Drecord, Mrecord, Yrecord, THrecord, TMrecord);
  58.     new File: file = fopen("porecords", io_write);
  59.     fwrite(file, coordsstring);
  60.     fclose(file);
  61.     return 1;
  62. }
  63. forward Record(playerid);
  64. public Record(playerid)
  65. {
  66.     if(Precord)
  67.     {
  68.         new string[92];
  69.         format(string, sizeof(string), "**Nosso record é de : %d, no dias %d %s %d, at %d:%d", Precord, Drecord, mname[Mrecord-1], Yrecord, THrecord, TMrecord);
  70.         SendClientMessage(playerid, 0xA5D24DFF, string);
  71.     }
  72.     oplayers++;
  73.     if(Precord < oplayers)
  74.     {
  75.         Precord=oplayers;
  76.         gettime(THrecord, TMrecord); getdate(Yrecord, Mrecord, Drecord);
  77.         new string[92];
  78.         format(string, sizeof(string), "Novo record de Onlines%d %s %d, at %d:%d", Precord, Drecord, mname[Mrecord-1], Yrecord, THrecord, TMrecord);
  79.         SendClientMessageToAll(0xFCB833FF, string);
  80.         SaveRecord();
  81.     }
  82.     return 1;
  83. }
  84. stock split(const strsrc[], strdest[][], delimiter)
  85. {
  86.     new i, li;
  87.     new aNum;
  88.     new len;
  89.     while(i <= strlen(strsrc))
  90.     {
  91.         if(strsrc[i] == delimiter || i == strlen(strsrc))
  92.         {
  93.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  94.             strdest[aNum][len] = 0;
  95.             li = i+1;
  96.             aNum++;
  97.         }
  98.         i++;
  99.     }
  100.     return 1;
  101. }
  102. forward ConnectedPlayers();
  103. public ConnectedPlayers()
  104. {
  105.     new Connected;
  106.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i)) Connected++;
  107.     return Connected;
  108. }
  109. ///////////////////////////////////////////////////////////////////////////
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top