HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk
  3. */
  4.  
  5. /********************************
  6. INCLUDES AND DEFINITIONS
  7. ********************************/
  8. #include <sourcemod>
  9. #include <tf2_stocks>
  10.  
  11. new Handle:g_cvarPluginEnable = INVALID_HANDLE;
  12. new Handle:g_cvarAdminOnly = INVALID_HANDLE;
  13.  
  14. new bool:IsClientAdmin[MAXPLAYERS +1] = false;
  15. new bool:AdminOnly = false;
  16.  
  17. new ammoOffset;
  18.  
  19. /********************************
  20. PLUGIN INFO
  21. ********************************/
  22. public Plugin:myinfo=
  23. {
  24. name = "[TF2] Unlimited Ammo",
  25. author = "John B.",
  26. description = "A plugin mindenki szamara ujratolti a loszert",
  27. version = "2.0.0.",
  28. url = "http://www.the-gcp.com",
  29. }
  30.  
  31. /********************************
  32. PLUGIN START
  33. ********************************/
  34. public OnPluginStart()
  35. {
  36. g_cvarPluginEnable = CreateConVar("sm_unlimitedammo_enable", "1", "1 Engedelyezes || 0 Letiltas");
  37. g_cvarAdminOnly = CreateConVar("sm_unlimitedammo_adminonly", "0", "0 Minden jatekos || 1 Csak Admin");
  38.  
  39. StartPlugin();
  40. CheckAdminOnly();
  41.  
  42. AutoExecConfig(true, "unlimited_ammo");
  43. }
  44.  
  45. /********************************
  46. CLIENT CONNECT
  47. ********************************/
  48. public OnClientPostAdminCheck(client)
  49. {
  50. if(GetUserAdmin(client) != INVALID_ADMIN_ID)
  51. {
  52. IsClientAdmin[client] = true;
  53. }
  54. }
  55.  
  56. /********************************
  57. CLIENT DISCONNECT
  58. ********************************/
  59. public OnClientDisconnect(client)
  60. {
  61. if(IsClientAdmin[client])
  62. {
  63. IsClientAdmin[client] = false;
  64. }
  65. }
  66.  
  67. /********************************
  68. TIMED ACTION
  69. ********************************/
  70. public Action:Timer_RefillAmmo(Handle:timer)
  71. {
  72. if(!AdminOnly)
  73. {
  74. for(new i = 1; i <= MaxClients; i++)
  75. {
  76. if(IsClientInGame(i) && IsPlayerAlive(i))
  77. {
  78. RefillAmmo(i);
  79. }
  80. }
  81. }
  82. else if(AdminOnly)
  83. {
  84. for(new i = 1; i <= MaxClients; i++)
  85. {
  86. if(IsClientInGame(i) && IsClientAdmin[i] && IsPlayerAlive(i))
  87. {
  88. RefillAmmo(i);
  89. }
  90. }
  91. }
  92.  
  93. return Plugin_Continue;
  94. }
  95.  
  96. /********************************
  97. STOCKS
  98. ********************************/
  99. stock StartPlugin()
  100. {
  101. if(GetConVarInt(g_cvarPluginEnable) == 1)
  102. {
  103. CheckGameType();
  104. ammoOffset = FindSendPropInfo("CTFPlayer", "m_iAmmo");
  105. CreateTimer(1.0, Timer_RefillAmmo, _, TIMER_REPEAT);
  106. }
  107. }
  108.  
  109. stock CheckGameType()
  110. {
  111. new String:sGameType[16];
  112. GetGameFolderName(sGameType, sizeof(sGameType));
  113. new bool:IsTeamFortress = StrEqual(sGameType, "tf", true);
  114.  
  115. if(!IsTeamFortress)
  116. {
  117. SetFailState("Ez a plugin csak a Team Fortress 2 jateknal alkalmazhato.");
  118. }
  119. }
  120.  
  121. stock CheckAdminOnly()
  122. {
  123. if(GetConVarInt(g_cvarAdminOnly) == 1)
  124. {
  125. AdminOnly = true;
  126. }
  127. }
  128.  
  129. stock RefillAmmo(i)
  130. {
  131. if(ammoOffset != -1)
  132. {
  133. SetEntData(i, ammoOffset +4, 50);
  134. SetEntData(i, ammoOffset +8, 50);
  135. }
  136. }