Badyx

[FS] Record de jugadores.

Apr 18th, 2014
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.28 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define             funcion%0(%1)                           forward %0(%1); public %0(%1)
  5.  
  6. enum sRecords
  7. {
  8.     CantidadJugadores,
  9. };
  10. new SistemaDeRecords[sRecords];
  11.  
  12. new TotalJugadores = 0;
  13.  
  14. #if defined FILTERSCRIPT
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     CargarRecord();
  19.     return 1;
  20. }
  21. #else
  22. main(){}
  23. #endif
  24.  
  25. public OnPlayerConnect(playerid)
  26. {
  27.     TotalJugadores ++;
  28.     ComprobarRecord();
  29.     return 1;
  30. }
  31.  
  32. public OnPlayerDisconnect(playerid, reason)
  33. {
  34.     TotalJugadores --;
  35.     return 1;
  36. }
  37.  
  38. funcion CargarRecord()
  39. {
  40.     new arrCoords[1][64];
  41.     new strFromFile2[256];
  42.     new File: file = fopen("Records/Records.ini", io_read);
  43.     if (file)
  44.     {
  45.         fread(file, strFromFile2);
  46.         split(strFromFile2, arrCoords, ',');
  47.         SistemaDeRecords[CantidadJugadores] = strval(arrCoords[0]);
  48.         fclose(file);
  49.     }
  50.     return 1;
  51. }
  52.  
  53. funcion GuardarRecord()
  54. {
  55.     new coordsstring[256];
  56.     format(coordsstring, sizeof(coordsstring), "%d", SistemaDeRecords[CantidadJugadores]);
  57.     new File: file2 = fopen("Records/Records.ini", io_write);
  58.     fwrite(file2, coordsstring);
  59.     fclose(file2);
  60.     return 1;
  61. }
  62.  
  63.  
  64. funcion ComprobarRecord()
  65. {
  66.     new Anterior = SistemaDeRecords[CantidadJugadores] -1;
  67.     new string[75];
  68.     if(TotalJugadores > SistemaDeRecords[CantidadJugadores])
  69.     {
  70.         SendClientMessageToAll(-1, "|_________ Atención _________|");
  71.         SendClientMessageToAll(-1, "");
  72.         SendClientMessageToAll(-1, "El record de usuarios a sido superado!.");
  73.         format(string,128,"[!] Record anterior %d ",Anterior);
  74.         SendClientMessageToAll(-1,string);
  75.         format(string,128,"[!] Nuevo record %d ",SistemaDeRecords[CantidadJugadores]);
  76.         SendClientMessageToAll(-1,string);
  77.         SistemaDeRecords[CantidadJugadores] ++;
  78.         GuardarRecord();
  79.         return 1;
  80.     }
  81.     return 1;
  82. }
  83.  
  84. funcion split(const strsrc[], strdest[][], delimiter)
  85. {
  86.     new i, li;
  87.     new aNum;
  88.     new len;
  89.     while(i <= strlen(strsrc)){
  90.         if(strsrc[i]==delimiter || i==strlen(strsrc)){
  91.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  92.             strdest[aNum][len] = 0;
  93.             li = i+1;
  94.             aNum++;
  95.         }
  96.         i++;
  97.     }
  98.     return 1;
  99. }
  100. /*  Comandos    */
  101. CMD:verrecord(playerid, params[])
  102. {
  103.     new string[25];
  104.     format(string, sizeof(string), "[Info] Record actual %d", SistemaDeRecords[CantidadJugadores]);
  105.     SendClientMessage(playerid, -1, string);
  106.     return 1;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment