hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.28. 18:01



Jelenlévő felhasználók

Jelenleg 213 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 213 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 
Szerző Üzenet
HozzászólásElküldve: 2019.08.12. 09:06 
Offline
Nagyúr
Avatar

Csatlakozott: 2013.09.14. 08:21
Hozzászólások: 547
Megköszönt másnak: 95 alkalommal
Megköszönték neki: 71 alkalommal
Üdv.

kiszeretném bővíteni annyival a plugint, ha épp van fent játékos a szerveren akkor random ne váltsa át a pályát. te hát csak annyit akarok elérni, ha lejár az idő mikor váltaná a pályát akkor fel jön egy egyszerű menü "igen" "nem" szöveggel. ha igen akkor elvált, ha nem akkor nem vált el.

  1. #pragma semicolon 1
  2. #include <sourcemod>
  3.  
  4. new bool:g_LoggedFileName = false;      /* Whether or not the file name has been logged */
  5. new g_ErrorCount = 0;               /* Current error count */
  6. new g_CurrentLine = 0;              /* Current line we're on */
  7. new String:g_Filename[PLATFORM_MAX_PATH];   /* Used for error messages */
  8. new String:g_map[255];
  9. new Handle:g_map_idle_time;
  10. new Handle:g_players_change;
  11. new Handle:g_log_map_change;
  12. new Handle:g_MapsArray;
  13. new Handle:g_timer;
  14. bool g_changeMap;
  15.  
  16. public Plugin:myinfo =
  17. {
  18.     name = "Idle Random Map",
  19.     author = "Gdk",
  20.     description = "Change to a random map for a defined player count after a defined time",
  21.     version = "1.2.0",
  22.     url = "https://github.com/RavageCS/Idle-Change-Random-Map"
  23. }
  24.  
  25. public OnPluginStart()
  26. {
  27.     g_map_idle_time = CreateConVar("sm_irm_idle_time","30","Time limit to change map");
  28.     g_players_change = CreateConVar("sm_irm_players_change","0","How many players on server to start map change timer");
  29.     g_log_map_change = CreateConVar("sm_irm_log_map_change","0","Log map selection");
  30.     AutoExecConfig(true, "idle_random_map");
  31. }
  32.  
  33. public OnMapStart()
  34. {
  35.     ServerCommand("sv_hibernate_when_empty 0");
  36.     g_timer = INVALID_HANDLE;
  37. }
  38.  
  39. public OnConfigsExecuted()
  40. {
  41.     g_MapsArray = CreateArray(255);
  42.     ReadMaps();
  43.     SetNextmap();
  44.    
  45.     PrintToServer("Idle Random Map: %s.", g_map);
  46.  
  47.     if(GetConVarInt(g_log_map_change))
  48.         LogMessage("Idle Random Map: %s.", g_map);
  49.     if(g_timer == INVALID_HANDLE)
  50.     {
  51.         g_timer = CreateTimer(GetConVarFloat(g_map_idle_time)*60, mapChange); //Start checking
  52.         g_changeMap = true;
  53.     }
  54. }
  55.  
  56. public OnClientPutInServer(client)
  57. {
  58.     if(GetRealClientCount(true) > GetConVarInt(g_players_change))
  59.     {
  60.         if(g_timer != INVALID_HANDLE)
  61.         {
  62.             KillTimer(g_timer);
  63.                 g_timer = INVALID_HANDLE; //Stop checking
  64.             g_changeMap = false;
  65.         }
  66.     }
  67. }
  68.  
  69. public OnClientDisconnect_Post(client)
  70. {
  71.     if(GetRealClientCount(true) <= GetConVarInt(g_players_change))
  72.     {
  73.         if(g_timer == INVALID_HANDLE)
  74.         {
  75.             g_timer = CreateTimer(GetConVarFloat(g_map_idle_time)*60, mapChange); //Start checking
  76.             g_changeMap = true;
  77.         }
  78.     }
  79. }
  80.  
  81. public OnMapEnd()
  82. {
  83.     g_timer = INVALID_HANDLE;
  84. }
  85.  
  86. public Action:mapChange(Handle:Timer)
  87. {
  88.     if(IsMapValid(g_map) && g_changeMap)
  89.     {
  90.         ServerCommand("changelevel %s", g_map);
  91.     }
  92.     if(!IsMapValid(g_map))
  93.     {
  94.         ParseError("Invalid map: %s", g_map);
  95.     }
  96.        
  97.     return Plugin_Handled;
  98. }
  99.  
  100. // Load maps from ini file
  101. public ReadMaps()
  102. {
  103.     BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/idle_random_map.ini");
  104.    
  105.     File file = OpenFile(g_Filename, "rt");
  106.     if (!file)
  107.     {
  108.         ParseError("Could not open file!");
  109.         return;
  110.     }
  111.    
  112.     while (!file.EndOfFile())
  113.     {
  114.         char line[255];
  115.         if (!file.ReadLine(line, sizeof(line)))
  116.             break;
  117.        
  118.         /* Trim comments */
  119.         int len = strlen(line);
  120.         bool ignoring = false;
  121.         for (int i=0; i<len; i++)
  122.         {
  123.             if (ignoring)
  124.             {
  125.                 if (line[i] == '"')
  126.                     ignoring = false;
  127.             }
  128.             else
  129.             {
  130.                 if (line[i] == '"')
  131.                 {
  132.                     ignoring = true;
  133.                 }
  134.                 else if (line[i] == ';')
  135.                 {
  136.                     line[i] = '\0';
  137.                     break;
  138.                 }
  139.                 else if (line[i] == '/' && i != len - 1 && line[i+1] == '/')
  140.                 {
  141.                     line[i] = '\0';
  142.                     break;
  143.                 }
  144.             }
  145.         }
  146.        
  147.         TrimString(line);
  148.        
  149.         if ((line[0] == '/' && line[1] == '/') || (line[0] == ';' || line[0] == '\0'))
  150.         {
  151.             continue;
  152.         }
  153.  
  154.         PushArrayString(g_MapsArray, line); //Add maps to the array
  155.     }
  156.    
  157.     file.Close();
  158. }
  159.  
  160. // Pick the next map
  161. public SetNextmap()
  162. {
  163.     int numberOfMaps = GetArraySize(g_MapsArray);
  164.     int rand = GetRandomInt(0,numberOfMaps-1);
  165.  
  166.         for(int i=0; i < numberOfMaps; i++)
  167.         {
  168.         if(i == rand)
  169.         {
  170.                 GetArrayString(g_MapsArray, i, g_map, 255); //Set the map
  171.         }
  172.     }
  173.  
  174. }
  175.    
  176. stock GetRealClientCount( bool:inGameOnly = true )
  177. {
  178.     new clients = 0;
  179.     for( new i = 1; i <= GetMaxClients(); i++ )
  180.     {
  181.         if( ( ( inGameOnly ) ? IsClientInGame( i ) : IsClientConnected( i ) ) && !IsFakeClient( i ) )
  182.         {
  183.             clients++;
  184.         }
  185.     }
  186.     return clients;
  187. }
  188.  
  189. ParseError(const String:format[], any:...)
  190. {
  191.     decl String:buffer[512];
  192.    
  193.     if (!g_LoggedFileName)
  194.     {
  195.         LogError("Error(s) detected parsing %s", g_Filename);
  196.         g_LoggedFileName = true;
  197.     }
  198.    
  199.     VFormat(buffer, sizeof(buffer), format, 2);
  200.    
  201.     LogError(" (line %d) %s", g_CurrentLine, buffer);
  202.    
  203.     g_ErrorCount++;
  204. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 2 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole