HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk
  3. */
  4.  
  5. #include <sourcemod>
  6. #include <sdktools>
  7.  
  8. #define VERSION "1.5"
  9. #pragma semicolon 1
  10.  
  11. new TeamSpec;
  12. new TeamUna;
  13. new bool:NoTeams = false;
  14.  
  15. new Handle:SpawnProtectionEnabled;
  16. new Handle:SpawnProtectionTime;
  17. new Handle:SpawnProtectionNotify;
  18. new Handle:SpawnProtectionColor;
  19.  
  20. new RenderOffs;
  21.  
  22. enum FX
  23. {
  24. FxNone = 0,
  25. FxPulseFast,
  26. FxPulseSlowWide,
  27. FxPulseFastWide,
  28. FxFadeSlow,
  29. FxFadeFast,
  30. FxSolidSlow,
  31. FxSolidFast,
  32. FxStrobeSlow,
  33. FxStrobeFast,
  34. FxStrobeFaster,
  35. FxFlickerSlow,
  36. FxFlickerFast,
  37. FxNoDissipation,
  38. FxDistort, // Distort/scale/translate flicker
  39. FxHologram, // kRenderFxDistort + distance fade
  40. FxExplode, // Scale up really big!
  41. FxGlowShell, // Glowing Shell
  42. FxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
  43. FxEnvRain, // for environmental rendermode, make rain
  44. FxEnvSnow, // " " " , make snow
  45. FxSpotlight,
  46. FxRagdoll,
  47. FxPulseFastWider,
  48. };
  49.  
  50. enum Render
  51. {
  52. Normal = 0, // src
  53. TransColor, // c*a+dest*(1-a)
  54. TransTexture, // src*a+dest*(1-a)
  55. Glow, // src*a+dest -- No Z buffer checks -- Fixed size in screen space
  56. TransAlpha, // src*srca+dest*(1-srca)
  57. TransAdd, // src*a+dest
  58. Environmental, // not drawn, used for environmental effects
  59. TransAddFrameBlend, // use a fractional frame value to blend between animation frames
  60. TransAlphaAdd, // src + dest*(1-a)
  61. WorldGlow, // Same as kRenderGlow but not fixed size in screen space
  62. None, // Don't render.
  63. };
  64.  
  65. public Plugin:myinfo =
  66. {
  67. name = "Spawn Protection",
  68. author = "Fredd",
  69. description = "Kezdovedelem",
  70. version = VERSION,
  71. url = "www.sourcemod.net"
  72. }
  73.  
  74. public OnPluginStart()
  75. {
  76. CreateConVar("spawnprotection_version", VERSION, "Spawn Protection Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  77.  
  78. SpawnProtectionEnabled = CreateConVar("sp_on", "1");
  79. SpawnProtectionTime = CreateConVar("sp_time", "5");
  80. SpawnProtectionNotify = CreateConVar("sp_notify", "1");
  81. SpawnProtectionColor = CreateConVar("sp_color", "0 255 0 120");
  82.  
  83. AutoExecConfig(true, "spawn_protection");
  84.  
  85. RenderOffs = FindSendPropOffs("CBasePlayer", "m_clrRender");
  86.  
  87. decl String:ModName[21];
  88. GetGameFolderName(ModName, sizeof(ModName));
  89.  
  90. if(StrEqual(ModName, "cstrike", false) || StrEqual(ModName, "dod", false) || StrEqual(ModName, "tf", false))
  91. {
  92. TeamSpec = 1;
  93. TeamUna = 0;
  94. NoTeams = false;
  95.  
  96. } else if(StrEqual(ModName, "Felkeles", false))
  97. {
  98. TeamSpec = 3;
  99. TeamUna = 0;
  100. NoTeams = false;
  101. }
  102. else if(StrEqual(ModName, "hl2mp", false))
  103. {
  104. NoTeams = true;
  105. } else
  106. {
  107. SetFailState("%s egy nem tamogatott mod", ModName);
  108. }
  109. HookEvent("player_spawn", OnPlayerSpawn);
  110. }
  111. public Action:OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  112. {
  113. if(GetConVarInt(SpawnProtectionEnabled) == 1)
  114. {
  115. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  116. new Team = GetClientTeam(client);
  117.  
  118. if(NoTeams == false)
  119. {
  120. if(Team == TeamSpec || Team == TeamUna)
  121. return Plugin_Continue;
  122. }
  123. if(!IsPlayerAlive(client))
  124. return Plugin_Continue;
  125.  
  126. decl String:SzColor[32];
  127. decl String:Colors[4][4];
  128. new Float:Time = float(GetConVarInt(SpawnProtectionTime));
  129.  
  130. GetConVarString(SpawnProtectionColor, SzColor, sizeof(SzColor));
  131. ExplodeString(SzColor, " ", Colors, 4, 4);
  132.  
  133. SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
  134. set_rendering(client, FX:FxDistort, StringToInt(Colors[0]),StringToInt(Colors[1]),StringToInt(Colors[2]), Render:RENDER_TRANSADD, StringToInt(Colors[3]));
  135. CreateTimer(Time, RemoveProtection, client);
  136. if(GetConVarInt(SpawnProtectionNotify) > 0)
  137. PrintToChat(client, "\x04[Kezdovedelem] \x01Kezdovedelemben reszesulsz meg \x04%i \x01masodpercig", RoundToNearest(Time));
  138. }
  139. return Plugin_Continue;
  140. }
  141. public Action:RemoveProtection(Handle:timer, any:client)
  142. {
  143. if(IsClientInGame(client))
  144. {
  145. SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
  146. set_rendering(client);
  147. if(GetConVarInt(SpawnProtectionNotify) > 0)
  148. PrintToChat(client, "\x04[Kezdovedelem] \x01A kezdovedelem jelenleg inaktiv..");
  149. }
  150. }
  151. stock set_rendering(index, FX:fx=FxNone, r=255, g=255, b=255, Render:render=Normal, amount=255)
  152. {
  153. SetEntProp(index, Prop_Send, "m_nRenderFX", _:fx, 1);
  154. SetEntProp(index, Prop_Send, "m_nRenderMode", _:render, 1);
  155. SetEntData(index, RenderOffs, r, 1, true);
  156. SetEntData(index, RenderOffs + 1, g, 1, true);
  157. SetEntData(index, RenderOffs + 2, b, 1, true);
  158. SetEntData(index, RenderOffs + 3, amount, 1, true);
  159. }