ZiGGi

same ip

Aug 16th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.05 KB | None | 0 0
  1. #define MAX_SAME_IP_PLAYERS 10
  2.  
  3. new
  4.     ip_address_idx,
  5.     ip_same_idx,
  6.     id_same_idx[MAX_SAME_IP_PLAYERS];
  7.  
  8. static
  9.     bool:is_found,
  10.     ip_temp[16],
  11.     ip_address[MAX_PLAYERS][16],
  12.     ip_same[MAX_SAME_IP_PLAYERS][16]
  13.     id_same[MAX_SAME_IP_PLAYERS][MAX_PLAYERS];
  14.  
  15. foreach (new playerid : Player) {
  16.     GetPlayerIp(playerid, ip_temp, sizeof(ip_temp));
  17.  
  18.     is_found = false;
  19.  
  20.     for (new i = 0; i < sizeof(ip_address); i++) {
  21.         if (strcmp(ip_temp, ip_address[i]) == 0) {
  22.             is_found = true;
  23.  
  24.             ip_same[ip_same_idx][0] = '\0';
  25.             strcat(ip_same[ip_same_idx], ip_temp, sizeof(ip_same[]));
  26.            
  27.             id_same[id_same_idx[ip_same_idx]] = playerid;
  28.  
  29.             id_same_idx[ip_same_idx]++
  30.             ip_same_idx++;
  31.  
  32.             break;
  33.         }
  34.     }
  35.  
  36.     if (!is_found) {
  37.         ip_address[ip_address_idx][0] = '\0';
  38.         strcat(ip_address[ip_address_idx], ip_temp, sizeof(ip_address[]));
  39.  
  40.         ip_address_idx++;
  41.     }
  42. }
  43.  
  44. for (new i = 0; i < ip_same_idx; i++) {
  45.     printf("ip: %s", ip_same[i]);
  46.  
  47.     for (new playerid = 0; playerid < id_same_idx[i]; playerid++) {
  48.         printf("    id: %d", id_same[i][playerid]);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment