Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release SpeedPlugin Fix
#1
Hey, finally there's a fix for the speedplugin!
It's fixing the tac preventing or picking up equipment from a far distance.

Here's the code(used @hillbilly 's offsets)
CSHARP Code
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using Addon;
  4. using System.Net;
  5.  
  6. namespace ReadyUP
  7. {
  8. public class Class1 : CPlugin
  9. {
  10. string cur_version = "";
  11. string update_message = "";
  12.  
  13. int g_speed_var = 0;
  14. float jump_height_var = 0;
  15. int fall_damage_var = 0;
  16. int gravity_var = 0;
  17. bool fall_damage_enabled = true;
  18.  
  19. IntPtr g_speed, jump_height, fallmax, fallmin, g_gravity;
  20.  
  21. [DllImport("kernel32.dll")]
  22. private static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);
  23.  
  24. unsafe public bool getOffsets()
  25. {
  26. //version,g_speed,jump_height,fallmax,fallmin,g_gravity,update message
  27. try
  28. {
  29. WebClient wc = new WebClient();
  30. string download = wc.DownloadString("http://www.infected.inx-gaming.com/forums/uploads/offsets.txt");
  31. string[] downloads = download.Split(',');
  32.  
  33. cur_version = downloads[0];
  34. g_speed = (IntPtr)Convert.ToInt32(downloads[1], 16);
  35. jump_height = (IntPtr)Convert.ToInt32(downloads[2], 16);
  36. fallmax = (IntPtr)Convert.ToInt32(downloads[3], 16);
  37. fallmin = (IntPtr)Convert.ToInt32(downloads[4], 16);
  38. g_gravity = (IntPtr)Convert.ToInt32(downloads[5], 16);
  39. update_message = downloads[6];
  40.  
  41. /*if (cur_version != GetDvar("shortversion"))
  42.   {
  43.   ServerPrint("Speed plugin outdated, wait patiently for an update!");
  44.   ServerPrint("Current server version: " + GetDvar("shortversion") + ". Current speed plugin offset version: " + cur_version);
  45.   return false;
  46.   }*/
  47.  
  48. ServerPrint("Speed plugin for version " + cur_version.ToString() + " loaded. Author: Pozzuh.");
  49.  
  50. if (update_message != "-1")
  51. ServerPrint(update_message);
  52.  
  53. return true;
  54. }
  55. catch (Exception e)
  56. {
  57. ServerPrint("Speed plugin couldn't load. Error written to log.");
  58. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  59.  
  60. if (update_message != "-1")
  61. ServerPrint(update_message);
  62.  
  63. return false;
  64. }
  65. }
  66.  
  67. unsafe public override void OnServerLoad()
  68. {
  69. if (!getOffsets())
  70. return;
  71.  
  72. if (GetServerCFG("SPEEDPLUGIN", "Speed", "-1") == "-1")
  73. SetServerCFG("SPEEDPLUGIN", "Speed", "190");
  74. if (GetServerCFG("SPEEDPLUGIN", "JumpHeight", "-1") == "-1")
  75. SetServerCFG("SPEEDPLUGIN", "JumpHeight", "39");
  76. if (GetServerCFG("SPEEDPLUGIN", "FallDamage", "-1") == "-1")
  77. SetServerCFG("SPEEDPLUGIN", "FallDamage", "1");
  78. if (GetServerCFG("SPEEDPLUGIN", "Gravity", "-1") == "-1")
  79. SetServerCFG("SPEEDPLUGIN", "Gravity", "800");
  80.  
  81. try
  82. {
  83. g_speed_var = 190;
  84. jump_height_var = 39;
  85. fall_damage_var = 1;
  86. gravity_var = 800;
  87.  
  88. }
  89. catch (Exception e)
  90. {
  91. ServerPrint("invalid speed, jump height, fall damage or gravity value...");
  92. }
  93.  
  94. makeSpeedHappy();
  95. makeJumpHeightHappy();
  96. makeGravityHappy();
  97.  
  98. set_g_speed(g_speed_var);
  99. set_jump_height(jump_height_var);
  100. set_g_gravity(gravity_var);
  101.  
  102. if (fall_damage_var == 0)
  103. disableFallDamage();
  104. }
  105.  
  106. public override unsafe ChatType OnSay(string Message, ServerClient Client)
  107. {
  108. string lowMsg = Message.ToLower();
  109.  
  110. if (lowMsg.StartsWith("!falldamage"))
  111. {
  112. string[] splitMsg = lowMsg.Split(' ');
  113.  
  114. if (splitMsg.Length == 1)
  115. {
  116. if (fall_damage_enabled)
  117. TellClient(Client.ClientNum, "Fall damage is currently enabled.", true);
  118. else
  119. TellClient(Client.ClientNum, "Fall damage is currently disabled.", true);
  120. }
  121. else
  122. {
  123. if (splitMsg[1] == "0")
  124. {
  125. disableFallDamage();
  126. TellClient(Client.ClientNum, "Fall damage is now disabled.", true);
  127. }
  128. else if (splitMsg[1] == "1")
  129. {
  130. enableFallDamage();
  131. TellClient(Client.ClientNum, "Fall damage is now enabled.", true);
  132. }
  133. }
  134.  
  135. return ChatType.ChatNone;
  136. }
  137.  
  138. if (lowMsg.StartsWith("!speed"))
  139. {
  140. string[] splitMsg = lowMsg.Split(' ');
  141.  
  142. if (splitMsg.Length == 1)
  143. TellClient(Client.ClientNum, "Current speed: " + *(int*)g_speed, true);
  144. else
  145. {
  146. try
  147. {
  148. int NewSpeedValue = Convert.ToInt32(splitMsg[1]);
  149. set_g_speed(NewSpeedValue);
  150.  
  151. TellClient(Client.ClientNum, "Speed changed to: " + NewSpeedValue + " (default=190)", true);
  152. }
  153. catch (Exception e)
  154. {
  155. TellClient(Client.ClientNum, "^1Invalid speed value!", true);
  156. }
  157. }
  158. return ChatType.ChatNone;
  159. }
  160.  
  161. if (lowMsg.StartsWith("!jumpheight"))
  162. {
  163. string[] splitMsg = lowMsg.Split(' ');
  164.  
  165. if (splitMsg.Length == 1)
  166. TellClient(Client.ClientNum, "Current jump height: " + *(float*)jump_height, true);
  167. else
  168. {
  169. try
  170. {
  171. float NewJumpHeightValue = (float)Convert.ToInt32(splitMsg[1]);
  172.  
  173. set_jump_height(NewJumpHeightValue);
  174.  
  175. if (NewJumpHeightValue < 128)
  176. TellClient(Client.ClientNum, "Jump height changed to: " + NewJumpHeightValue, true);
  177. else
  178. {
  179. TellClient(Client.ClientNum, "Jump height changed to: " + NewJumpHeightValue + " (default=39). Fall damage disabled.", true);
  180. disableFallDamage();
  181. }
  182.  
  183. }
  184. catch (Exception e)
  185. {
  186. TellClient(Client.ClientNum, "^1Invalid jump height value!", true);
  187. }
  188. }
  189. return ChatType.ChatNone;
  190. }
  191.  
  192. if (lowMsg.StartsWith("!gravity"))
  193. {
  194. string[] splitMsg = lowMsg.Split(' ');
  195.  
  196. if (splitMsg.Length == 1)
  197. TellClient(Client.ClientNum, "Current gravity: " + *(int*)g_gravity, true);
  198. else
  199. {
  200. try
  201. {
  202. int newGravityValue = Convert.ToInt32(splitMsg[1]);
  203.  
  204. set_g_gravity(newGravityValue);
  205.  
  206. TellClient(Client.ClientNum, "Gravity changed to: " + newGravityValue + " (default=800).", true);
  207. }
  208. catch (Exception e)
  209. {
  210. TellClient(Client.ClientNum, "^1Invalid gravity value!", true);
  211. }
  212. }
  213. return ChatType.ChatNone;
  214. }
  215.  
  216. return ChatType.ChatContinue;
  217. }
  218.  
  219. /////////////////////////////////////////////////////////////////////////////////////////////////////////
  220. //Stuff needed for speed change
  221. public void makeSpeedHappy()
  222. {
  223. try
  224. {
  225. uint size = 4;
  226. uint newProtect = 0x40;
  227. uint oldProtect = 0;
  228.  
  229. VirtualProtect(g_speed, size, newProtect, out oldProtect);
  230. }
  231. catch (Exception e)
  232. {
  233. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  234. }
  235. }
  236.  
  237. unsafe public void set_g_speed(int value)
  238. {
  239. try
  240. {
  241. *(int*)g_speed = value;
  242. }
  243. catch (Exception e)
  244. {
  245. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  246. }
  247. }
  248.  
  249. public unsafe void makeJumpHeightHappy()
  250. {
  251. try
  252. {
  253. uint size = 4;
  254. uint newProtect = 0x40;
  255. uint oldProtect = 0;
  256.  
  257. VirtualProtect(jump_height, size, newProtect, out oldProtect);
  258. VirtualProtect(fallmin, size, newProtect, out oldProtect);
  259. VirtualProtect(fallmax, size, newProtect, out oldProtect);
  260.  
  261.  
  262. }
  263. catch (Exception e)
  264. {
  265. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  266. }
  267. }
  268.  
  269. public unsafe void disableFallDamage()
  270. {
  271. fall_damage_enabled = false;
  272. *(float*)fallmin = 999999.0f;
  273. *(float*)fallmax = 1000000.0f;
  274. }
  275.  
  276.  
  277. public unsafe void enableFallDamage()
  278. {
  279. fall_damage_enabled = true;
  280. *(float*)fallmin = 128.0f;
  281. *(float*)fallmax = 300.0f;
  282. }
  283.  
  284. unsafe public void set_jump_height(float value)
  285. {
  286. try
  287. {
  288. *(float*)jump_height = value;
  289. }
  290. catch (Exception e)
  291. {
  292. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  293. }
  294. }
  295.  
  296. public void makeGravityHappy()
  297. {
  298. try
  299. {
  300. uint size = 4;
  301. uint newProtect = 0x40;
  302. uint oldProtect = 0;
  303.  
  304. VirtualProtect(g_gravity, size, newProtect, out oldProtect);
  305. }
  306. catch (Exception e)
  307. {
  308. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  309. }
  310. }
  311.  
  312. unsafe public void set_g_gravity(int value)
  313. {
  314. try
  315. {
  316. *(int*)g_gravity = value;
  317. }
  318. catch (Exception e)
  319. {
  320. ServerLog(LogType.LogConsole, "SPEED PLUGIN ERROR: " + e.ToString());
  321. }
  322. }
  323. public override void OnMapChange()
  324. {
  325. string speed = GetServerCFG("SPEEDPLUGIN", "Speed", "");
  326. string jh = GetServerCFG("SPEEDPLUGIN", "JumpHeight", "");
  327. string falldmg = GetServerCFG("SPEEDPLUGIN", "FallDamage", "");
  328. string gravity = GetServerCFG("SPEEDPLUGIN", "Gravity", "");
  329.  
  330. g_speed_var = Convert.ToInt32(speed);
  331. jump_height_var = Convert.ToInt32(jh);
  332. fall_damage_var = Convert.ToInt32(falldmg);
  333. gravity_var = Convert.ToInt32(gravity);
  334.  
  335. set_g_speed(g_speed_var);
  336. set_jump_height(jump_height_var);
  337. set_g_gravity(gravity_var);
  338.  
  339. if (fall_damage_var == 0)
  340. disableFallDamage();
  341. else
  342. enableFallDamage();
  343. }
  344. }
  345. }


using the default speed/jh/gravity/falldmg in OnServerLoad and change it in OnMapChange fixed it.
you can use the default sv_config for this.

Credits
@Pozzuh - creator of the SpeedPlugin
@MADD_DOGG - found the fix with different speed/jumpheight for each map
@8q4s8 - fixed the plugin
@hillbilly - updating the plugin


Attached Files
.zip   SpeedPluginFix.zip (Size: 4 KB / Downloads: 156)
Reply

#2
oldy post i know, but having a little issue including different speed/jump height for each map, i added it like my other one but didn't work, as i'm already using OnMapChange for the maps/speed etc
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.