Advertisement
Deaderik

Info server

Feb 9th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.65 KB | Gaming | 0 0
  1. #include <a_samp> // Zahrnuje SA-MP nativní funkce
  2. //Infoooooooooo by Vankin,exploit, SuperGrand
  3. #define MAX_SERVERS 50 // Maximální počet serverů
  4. #define MAX_PLAYER_NAME 24 // Maximální délka jména hráče
  5. #define MAX_GAME_MODE_LENGTH 32 // Maximální délka názvu herního módu
  6. #define MAX_MAP_NAME_LENGTH 32 // Maximální délka názvu mapy
  7.  
  8. new g_ServerData[MAX_SERVERS][6]; // Pole pro uložení dat o serverech: IP, port, název, počet hráčů, herní mód, mapa
  9.  
  10. // Načtení dat o serverech při startu
  11. public OnGameModeInit()
  12. {
  13.     GetServerData();
  14.     return 1;
  15. }
  16.  
  17. // Funkce pro získání dat o serverech
  18. public GetServerData()
  19. {
  20.     new File:fileHandle = fopen("server_data.txt", io_read);
  21.     if (!fileHandle)
  22.     {
  23.         printf("Chyba: Nepodařilo se otevřít soubor 'server_data.txt'!");
  24.         return 0;
  25.     }
  26.  
  27.     new line[128], idx = 0;
  28.     while (!feof(fileHandle) && idx < MAX_SERVERS)
  29.     {
  30.         fgets(fileHandle, line, sizeof(line));
  31.         sscanf(line, "%s %d %s %d %s %s", g_ServerData[idx][0], g_ServerData[idx][1], g_ServerData[idx][2], g_ServerData[idx][3], g_ServerData[idx][4], g_ServerData[idx][5]);
  32.         idx++;
  33.     }
  34.  
  35.     fclose(fileHandle);
  36.     printf("Data o serverech načtena úspěšně.");
  37.     return 1;
  38. }
  39.  
  40. // Příkaz pro zobrazení informací o konkrétním serveru
  41. CMD:info(playerid)
  42. {
  43.     new serverIndex = GetPlayerServerIndex(playerid); // Získání indexu serveru, na který je hráč připojen
  44.  
  45.     if (serverIndex != INVALID_SERVER_INDEX)
  46.     {
  47.         new serverIP[24], serverName[64], playerCount;
  48.         format(serverIP, sizeof(serverIP), "%s:%d", g_ServerData[serverIndex][0], g_ServerData[serverIndex][1]);
  49.         format(serverName, sizeof(serverName), "%s", g_ServerData[serverIndex][2]);
  50.         playerCount = g_ServerData[serverIndex][3];
  51.  
  52.         new gameMode[MAX_GAME_MODE_LENGTH], mapName[MAX_MAP_NAME_LENGTH];
  53.         format(gameMode, sizeof(gameMode), "%s", g_ServerData[serverIndex][4]);
  54.         format(mapName, sizeof(mapName), "%s", g_ServerData[serverIndex][5]);
  55.  
  56.         SendClientMessage(playerid, COLOR_WHITE, "Informace o serveru:");
  57.         SendClientMessage(playerid, COLOR_WHITE, "IP: %s", serverIP);
  58.         SendClientMessage(playerid, COLOR_WHITE, "Název: %s", serverName);
  59.         SendClientMessage(playerid, COLOR_WHITE, "Hráči online: %d", playerCount);
  60.         SendClientMessage(playerid, COLOR_WHITE, "Herní mód: %s", gameMode);
  61.         SendClientMessage(playerid, COLOR_WHITE, "Mapa: %s", mapName);
  62.     }
  63.     else
  64.     {
  65.         SendClientMessage(playerid, COLOR_RED, "Nejste připojeni na žádný server.");
  66.     }
  67.  
  68.     return 1;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement