Andrew_Manu

Sistema de clanes (ES)

Feb 10th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.24 KB | None | 0 0
  1. #define CLANES "clanes/%s.txt"
  2. #define CLANES_REGISTRADOS      4
  3. #define PARAMETROS              22*CLANES_REGISTRADOS
  4.  
  5. new Float:Clan_top[4][5];
  6. new Clan_id[][] =
  7. {
  8.     {0,1,2,3,4},
  9.     {0,1,2,3,4},
  10.     {0,1,2,3,4},
  11.     {0,1,2,3,4}
  12. };
  13. new Clan_kills[CLANES_REGISTRADOS];
  14. new Clan_muertes[CLANES_REGISTRADOS];
  15. new Float:Clan_ratio[CLANES_REGISTRADOS];
  16. new Clan_Cganadas[CLANES_REGISTRADOS];
  17. new Clan_Cperdidas[CLANES_REGISTRADOS];
  18. new Clan_n[MAX_PLAYERS];
  19. new Clanes[4][CLANES_REGISTRADOS] =
  20. {
  21.     {"WTx"},
  22.     {"KDs"},
  23.     {"DcP"},
  24.     {"R$x"}
  25. };
  26. enum Datos{ Nombre_clan[32], Creacion_clan, Dueno_clan[32] }
  27. new Clanes_descripcion[][Datos] =
  28. {
  29.     {"Toxic Warriors",          2011,   "[WTx]Andrew_Manu"},
  30.     {"Death's King's Squad",    0,      "Null"},
  31.     {"Dicaprios Family",        0,      "Null"},
  32.     {"Rebelion Street Xtreme",  0,      "Null"}
  33. };
  34.  
  35. /* OnGameModeInit */
  36.     new Local[100], Clan[50];
  37.     new File:c;
  38.     for(new x=0;x<CLANES_REGISTRADOS;x++){
  39.         format(Clan, 50, "%s.txt", Clanes[x]);
  40.         format(Local, 50, CLANES, Clan);
  41.         if(!fexist(Local)){
  42.             fcreate(Local);
  43.             c = fopen(Local,io_write);
  44.             format(datos, 128,"0\r\n0\r\n0.000\r\n0\r\n0\r\n");
  45.             fwrite(c, datos);
  46.         }else{
  47.             c = fopen(Local,io_read);
  48.             fread(c,Local); Clan_kills[x]   = strval(Local);
  49.             fread(c,Local); Clan_muertes[x] = strval(Local);
  50.             fread(c,Local); Clan_ratio[x]   = floatstr(Local);
  51.             fread(c,Local); Clan_Cganadas[x]    = strval(Local);
  52.             fread(c,Local); Clan_Cperdidas[x] = strval(Local);
  53.         }
  54.     }
  55.     fclose(c);
  56.    
  57. /* OnPlayerConnect */
  58.     Clan_n[playerid] = -1;
  59.     new p = 0;
  60.     do{
  61.         if(strfind(nombre(playerid), Clanes[p], true) != -1){
  62.             Clan_n[playerid] = p;
  63.             p = 4;
  64.         }else p++;
  65.     }while(p != 4);
  66.  
  67. /* OnPlayerDis */
  68.     if(Clan_n[playerid] != -1){
  69.         new Local[100], Clan[50], datos[128];
  70.         new File:c;
  71.         for(new x=0;x<CLANES_REGISTRADOS;x++){
  72.             format(Clan, 50, "%s.txt", Clanes[x]);
  73.             format(Local, 50, CLANES, Clan);
  74.             if(fexist(Local)){
  75.                 c = fopen(Local, io_write);
  76.                 format(datos, 128,"%d\r\n%d\r\n%.3f\r\n%d\r\n%d\r\n", Clan_kills[x], Clan_muertes[x], Clan_ratio[x], Clan_Cganadas[x], Clan_Cperdidas[x]);
  77.                 fwrite(c, datos);
  78.                 fclose(c);
  79.             }
  80.         }
  81.     }
  82.    
  83. /* OnPlayerDeath (CWTG) */
  84.     if(EstaEnX1[playerid] != 0){ /* var x1 */
  85.         if((GetPVarInt(playerid,"Logged") == 1) && (GetPVarInt(killerid,"Logged") == 1)){ /* var log */
  86.             if(Clan_n[playerid] != 1 && Clan_n[killerid] != 1){
  87.                 Clan_kills[Clan_n[killerid]]++;
  88.                 Clan_muertes[Clan_n[playerid]]--;
  89.             }
  90.         }
  91.     }
  92.    
  93. /* Score update (CWTG) */
  94.             if(Equipo_puntaje[team] == Puntaje_maximo){
  95.                 Equipo_rondas[team]++;
  96.                 SCMTA(BLANCO,"");
  97.                 if(naranja > 1 && verde > 1){
  98.                     new cc_n = 0, cc_v = 0;
  99.                     ForPlayers(i){
  100.                         if(Equipo[i] == EQUIPO_NARANJA){
  101.                             if(strcmp(Clanes[Clan_n[i]], Nombre_equipo[EQUIPO_NARANJA], true) == 0){
  102.                                 cc_n++;
  103.                             }
  104.                         }else if(Equipo[i] == EQUIPO_VERDE){
  105.                             if(strcmp(Clanes[Clan_n[i]], Nombre_equipo[EQUIPO_VERDE], true) == 0){
  106.                                 cc_v++;
  107.                             }
  108.                         }
  109.                     }
  110.                     if(team == EQUIPO_NARANJA){
  111.                         SCMTAF(0x670000F6A,"{FFFFFF}- {B8B8B8}¡Equipo {F69521}%s{B8B8B8} ha ganado!",Nombre_equipo[team]);
  112.                         if(cc_n == naranja && cc_v == verde){
  113.                             new n_clan = -1, v_clan = -1, pos = 0, c[2] = {-1,-1};
  114.                             do{
  115.                                 if(strcmp(Clanes[pos], Nombre_equipo[EQUIPO_NARANJA], true) == 0){
  116.                                     n_clan = pos;
  117.                                     c[0] = 1;
  118.                                 }else if(strcmp(Clanes[pos], Nombre_equipo[EQUIPO_NARANJA], true) == 0){
  119.                                     v_clan = pos;
  120.                                     c[1] = 1;
  121.                                 }
  122.                                 if(pos == 4) pos = 0;
  123.                             }while(c[0] != 1 && c[1] != 1);
  124.                             Clan_Cganadas[n_clan]++;
  125.                             Clan_Cperdidas[v_clan]--;
  126.                         }
  127.                     }else{
  128.                         SCMTAF(0x670000F6A,"{FFFFFF}- {B8B8B8}¡Equipo {007C0E}%s{B8B8B8} ha ganado!",Nombre_equipo[team]);
  129.                         if(cc_n == naranja && cc_v == verde){
  130.                             new n_clan = -1, v_clan = -1, pos = 0, c[2] = {-1,-1};
  131.                             do{
  132.                                 if(strcmp(Clanes[pos], Nombre_equipo[EQUIPO_NARANJA], true) == 0){
  133.                                     n_clan = pos;
  134.                                     c[0] = 1;
  135.                                 }else if(strcmp(Clanes[pos], Nombre_equipo[EQUIPO_NARANJA], true) == 0){
  136.                                     v_clan = pos;
  137.                                     c[1] = 1;
  138.                                 }
  139.                                 if(pos == 4) pos = 0;
  140.                             }while(c[0] != 1 && c[1] != 1);
  141.                             Clan_Cganadas[v_clan]++;
  142.                             Clan_Cperdidas[n_clan]--;
  143.                         }
  144.                     }
  145.                 }
  146.                
  147. /* OnDialogResponse.. in switch */
  148.     Ordenar_c(0);
  149.     new str[600];
  150.     format(str, sizeof(str), "{7C7C7C}p.\t{7C7C7C}Clan\t{7C7C7C}Kills\n{7C7C7C}1.{FFFFFF}> \t{B8B8B8}%s\t{F69521}%d\n{7C7C7C}2.{FFFFFF}> \t{B8B8B8}%s\t{F69521}%d\n{7C7C7C}3.{FFFFFF}> \t{B8B8B8}%s\t{F69521}%d\n{7C7C7C}4.{FFFFFF}> \t{B8B8B8}%s\t{F69521}%d",
  151.     Clanes[Clan_id[0][0]], Clan_kills[Clan_id[0][0]], Clanes[Clan_id[0][1]], Clan_kills[Clan_id[0][1]], Clanes[Clan_id[0][2]], Clan_kills[Clan_id[0][2]], Clanes[Clan_id[0][3]], Clan_kills[Clan_id[0][3]]);
  152.     ShowPlayerDialog(playerid, CLAN_TOP_KILLS, DIALOG_STYLE_TABLIST_HEADERS, "{F69521}Top clan kills:", str , "Ok", "");
  153.  
  154.  
  155. /* Stock.. */
  156. stock Ordenar_c(s){
  157.     new Local[100], Clan[100], File:c, aux;
  158.     for(new a=0;a<CLANES_REGISTRADOS;a++){
  159.         format(Clan, 50, "%s.txt", Clanes[a]);
  160.         format(Local, 50, CLANES, Clan);
  161.         if(fexist(Local)){
  162.             c = fopen(Local,io_read);
  163.             fread(c,Local); Clan_top[a][0] = strval(Local);
  164.             fread(c,Local); Clan_top[a][1] = strval(Local);
  165.             fread(c,Local); Clan_top[a][2] = floatstr(Local);
  166.             fread(c,Local); Clan_top[a][3] = strval(Local);
  167.             fread(c,Local); Clan_top[a][4] = strval(Local);
  168.         }
  169.     }
  170.     fclose(c);
  171.     switch(s){
  172.         case 0:
  173.         {
  174.         for(new x=0;x<CLANES_REGISTRADOS;x++){
  175.                 for(new y=x+1;y<CLANES_REGISTRADOS;y++){
  176.                     if(Clan_top[x][0] < Clan_top[y][0]){
  177.                         aux = Clan_id[0][x];
  178.                         Clan_id[0][x] = Clan_id[0][y];
  179.                         Clan_id[0][y] = aux;
  180.                     }
  181.                 }
  182.             }
  183.         }
  184.         case 1:
  185.         {
  186.         for(new x=0;x<CLANES_REGISTRADOS;x++){
  187.                 for(new y=x+1;y<CLANES_REGISTRADOS;y++){
  188.                     if(Clan_top[x][1] < Clan_top[y][1]){
  189.                         aux = Clan_id[1][x];
  190.                         Clan_id[1][x] = Clan_id[1][y];
  191.                         Clan_id[1][y] = aux;
  192.                     }
  193.                 }
  194.             }
  195.         }
  196.     }
  197. }
Advertisement
Add Comment
Please, Sign In to add comment