Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4.  
  5. #define PLUGIN_AUTHOR "BloodTiger"
  6. #define PLUGIN_VERSION "1.00"
  7.  
  8. #include <sourcemod>
  9. #include <sdktools>
  10.  
  11. #pragma newdecls required
  12.  
  13. // Convars
  14. ConVar g_cvJumpMax = null;
  15. ConVar g_cvAllorTeam = null;
  16. ConVar g_cvJumpBoost = null;
  17. ConVar g_cvJumpEnable = null;
  18. ConVar g_cvBlueorRed = null;
  19.  
  20. // Floats
  21. float g_flBoost = 250.0;
  22.  
  23. // Bools
  24. bool g_bDoubleJump;
  25. bool g_bAllorTeam;
  26. bool g_bBlueorRed;
  27.  
  28.  
  29. // Ints
  30. int g_iJumpMax;
  31. int g_iLastButtons[MAXPLAYERS+1];
  32. int g_iLastFlags[MAXPLAYERS+1];
  33. int g_iJumps[MAXPLAYERS+1];
  34.  
  35. public Plugin myinfo =
  36. {
  37. name = "[TF2] Blue double-jump",
  38. author = PLUGIN_AUTHOR,
  39. description = "Adds double jumping for blues",
  40. version = PLUGIN_VERSION,
  41. url = ""
  42. };
  43.  
  44. public void OnPluginStart()
  45. {
  46. CreateConVar("sm_doublejump_version", PLUGIN_VERSION, "Double jump version");
  47. g_cvJumpEnable = CreateConVar("sm_doublejump_enabled", "1", "Enables double jumping");
  48. g_cvJumpBoost = CreateConVar("sm_doublejump_boost", "250.0", "Vertical boost count");
  49. g_cvJumpMax = CreateConVar("sm_doublejump_max", "1", "Maximum numbers of double jumps");
  50. g_cvAllorTeam = CreateConVar("sm_doublejump_allorteam", "1", "Specifies whether you want doublejump only enabled on one team or on all teams");
  51. g_cvBlueorRed = CreateConVar("sm_doublejump_redorblue", "0", "Specifies which team to pick.");
  52.  
  53. g_cvJumpEnable.AddChangeHook(convar_ChangeEnable);
  54. g_cvJumpBoost.AddChangeHook(convar_ChangeBoost);
  55. g_cvJumpMax.AddChangeHook(convar_ChangeMax);
  56. g_cvAllorTeam.AddChangeHook(convar_AllorTeam);
  57. g_cvBlueorRed.AddChangeHook(convar_BlueorRed);
  58.  
  59. g_bBlueorRed = g_cvBlueorRed.BoolValue;
  60. g_bAllorTeam = g_cvAllorTeam.BoolValue;
  61. g_bDoubleJump = g_cvJumpEnable.BoolValue;
  62. g_flBoost = g_cvJumpBoost.FloatValue;
  63. g_iJumpMax = g_cvJumpMax.IntValue;
  64. }
  65.  
  66. public int convar_ChangeBoost(Handle convar, const char[] oldVal, const char[] newVal)
  67. {
  68. g_flBoost = StringToFloat(newVal);
  69. }
  70.  
  71. public int convar_ChangeEnable(Handle convar, const char[] oldVal, const char[] newVal)
  72. {
  73. if(StringToInt(newVal) >=1)
  74. {
  75. g_bDoubleJump = true;
  76. }
  77. else
  78. {
  79. g_bDoubleJump = false;
  80. }
  81. }
  82.  
  83. public void convar_ChangeMax(Handle convar, const char[] oldVal, const char[] newVal)
  84. {
  85. g_iJumpMax = StringToInt(newVal);
  86. }
  87.  
  88. public void convar_AllorTeam(Handle convar, const char[] oldVal, const char[] newVal)
  89. {
  90. g_bAllorTeam = StringToBool(newVal);
  91. }
  92.  
  93. public void convar_BlueorRed(Handle convar, const char[] oldVal, const char[] newVal)
  94. {
  95. g_bBlueorRed = StringToBool(newVal);
  96. }
  97.  
  98. public void OnGrameFrame()
  99. {
  100. if(g_bDoubleJump)
  101. {
  102. for (int i = 1; i <= MaxClients; i++)
  103. {
  104. if(!g_bAllorTeam)
  105. {
  106. if(IsClientInGame(i) && IsPlayerAlive(i))
  107. {
  108. DoubleJump(i);
  109. }
  110. }
  111. else if(g_bAllorTeam)
  112. {
  113. if(!g_bBlueorRed)
  114. {
  115. if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
  116. {
  117. DoubleJump(i);
  118. }
  119. }
  120. else if(g_bBlueorRed)
  121. {
  122. if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
  123. {
  124. DoubleJump(i);
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131.  
  132. stock void DoubleJump(int client)
  133. {
  134. int fCurFlags = GetEntityFlags(client);
  135. int fCurButtons = GetEntityFlags(client);
  136.  
  137. if(g_iLastFlags[client] & FL_ONGROUND)
  138. {
  139. if(!(fCurFlags & FL_ONGROUND) && !(g_iLastButtons[client] & IN_JUMP) && (fCurButtons & IN_JUMP))
  140. {
  141. OriginalJump(client);
  142. }
  143. }
  144. else if(fCurFlags & FL_ONGROUND)
  145. {
  146. LandedClient(client);
  147. }
  148. else if(!(g_iLastButtons[client] & IN_JUMP) && (fCurButtons & IN_JUMP))
  149. {
  150. ReJump(client);
  151. }
  152.  
  153. g_iLastFlags[client] = fCurFlags;
  154. g_iLastButtons[client] = fCurButtons;
  155. }
  156.  
  157. stock void OriginalJump(int client)
  158. {
  159. g_iJumps[client]++;
  160. }
  161.  
  162. stock void LandedClient(int client)
  163. {
  164. g_iJumps[client] = 0;
  165. }
  166.  
  167. stock void ReJump(int client)
  168. {
  169. if ( 1 <= g_iJumps[client] <= g_iJumpMax)
  170. {
  171. g_iJumps[client]++;
  172. float vVel[3];
  173. GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
  174.  
  175. vVel[2] = g_flBoost;
  176. TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel);
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement