ItsMods

Full Version: [Mini Map] Where Is She
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi guys and girls,

This is an idea that I got from @MADD_DOGG who made a very valid point about campers who won't shoot when they are last in infected servers, so I decided to come up with my own design that solves a couple of issues that memory pointers have if your server has a limited amount of resource assigned to it and problems with the icon resetting on map change and fast restart.

PLEASE NOTE
I do not take responsibility for your server crashing if you use this plugin, memory pointers run in an unsafe context which are known to cause crashes.

So what does this plugin do?
This plugin is pretty much self explanatory, simply download the DLL, setup the sv_config.ini options for the icon and delay until the last human alive appears on the mini map. When you're in-game a timer will be started if there is one human left alive which will then trigger an icon to appear on everyone's mini map, upon this icon appearing on the mini map the built in timer in the addon plugin will keep looping over itself which constantly checks the total number of humans against the total number of infected players, if it finds there is more then one human left alive the icon will be deactivated and you will need to hunt down everyone until one human remains again.

What commands can I use?
Quote:!icon - Allows you to set what icon is visible in game

See the below for the installation instructions.

  1. Copy the configuration defaults below and place them in your sv_config.ini
  2. Enjoy!
sv_config.ini:
Code:
[WhereIsShe]
// The default icon for the mini map
//
// Default: 40 = Skull
// Version: 0.1 BETA
Icon=40

// The delay between when one human is left alive until the icon appears on the mini map.
// This value is based on "seconds" and must be at least 1
//
// Default: 30
// Version: 0.1 BETA
Timer=30

// Set the following option to true if you only want the icon to appear based on player
// movements around the map, setting this will override the above timer value with the
// reset time below
//
// Default: false
// Accepts: true or false
// Version: 0.3 BETA
DetectMovement=false

// The amount of movement required in order for the mini map icon to be hidden once the
// last human begins moving again, the higher the number the longer it will take for the
// icon to disappear from the mini map
//
// Default: 100 = About 2-3 seconds of movement
// Version: 0.3 BETA
Threshold=100

// The amount of time until the icon reappears on the mini map after the last human stops
// moving again, again this overrides the original timer so make sure its a number that's
// fair for everyone in the game.
//
// This value is based on "seconds" and must be at least 1
//
// Default: 5
// Version: 0.3 BETA
ResetTime=5

Changelog:

Source Code:
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Timers;
  5. using Addon;
  6.  
  7. namespace WhereIsShe
  8. {
  9. public class Main : CPlugin
  10. {
  11. private IntPtr _activate, _icon, _originX, _originY;
  12. private float _x, _y;
  13. private Timer _lastManStanding;
  14. private Stopwatch _stopWatch;
  15. private Configuration _configuration;
  16. private readonly GameOptions _gameStats = new GameOptions();
  17.  
  18. /// <summary>
  19. /// Executes when the MW3 server loads
  20. /// </summary>
  21. public override void OnServerLoad()
  22. {
  23. ServerPrint("\n[Where Is She] Created by SgtLegend. Version 0.3 BETA");
  24. ServerPrint("[Where Is She] Code from waypoint plugin created by 8q4s8");
  25.  
  26. // Grab the configuration for the icon
  27. _configuration = new Configuration
  28. {
  29. IconNumber = int.Parse(GetServerCFG("WhereIsShe", "Icon", "40")),
  30. GirlyTime = int.Parse(GetServerCFG("WhereIsShe", "Timer", "30")),
  31. DetectMovement = bool.Parse(GetServerCFG("WhereIsShe", "DetectMovement", "false")),
  32. Threshold = int.Parse(GetServerCFG("WhereIsShe", "Threshold", "30")),
  33. ResetTime = int.Parse(GetServerCFG("WhereIsShe", "ResetTime", "5"))
  34. };
  35.  
  36. // Memory pointers found by 8q4s8
  37. _activate = (IntPtr) Convert.ToInt32(0x01B1EE9C);
  38. _icon = (IntPtr) Convert.ToInt32(0x01B1EEBC);
  39. _originX = (IntPtr) Convert.ToInt32(0x01B1EEA0);
  40. _originY = (IntPtr) Convert.ToInt32(0x01B1EEA4);
  41.  
  42. // Set the initial icon
  43. ChangeIcon();
  44.  
  45. // Create a new stop watch so we can track the amount of time that the girl has been camping
  46. // in a corner for
  47. _stopWatch = new Stopwatch();
  48.  
  49. // Create a new timer which can be re-used as many times as its needed
  50. _lastManStanding = new Timer
  51. {
  52. Enabled = false,
  53. Interval = 500
  54. };
  55.  
  56. _lastManStanding.Elapsed += FindTheGirl;
  57. }
  58.  
  59. /// <summary>
  60. /// Executes when the addon frame base method gets called
  61. /// </summary>
  62. public override void OnAddonFrame()
  63. {
  64. try
  65. {
  66. List<ServerClient> clients = new List<ServerClient>(GetClients());
  67.  
  68. // Update the total number of clients on the server
  69. _gameStats.ClientsTotal = clients.Count;
  70. _gameStats.ClientsInfected = 0;
  71.  
  72. // Go through all the clients on the server and increment the total number of infected
  73. // players so can determine if there is one player left alive
  74. if (clients.Count == 0) return;
  75.  
  76. foreach (ServerClient client in clients)
  77. {
  78. switch (client.Team)
  79. {
  80. case Teams.Axis:
  81. _gameStats.ClientsInfected++;
  82. break;
  83.  
  84. case Teams.Allies:
  85. _gameStats.ClientsHuman++;
  86. break;
  87. }
  88. }
  89.  
  90. // Now check the number of infected players against the number of humans remaining in the
  91. // game, if the total number of clients minus the total number of zombies equals one then
  92. // we can be sure that we need to seek out the girl
  93. if ((_gameStats.ClientsTotal - _gameStats.ClientsInfected) == 1 ||
  94. (_gameStats.ClientsHuman == 1 && _gameStats.ClientsInfected == 1))
  95. {
  96. foreach (ServerClient client in clients)
  97. {
  98. if (client.Team != Teams.Allies || client.SpectateType == SpectateTypes.None) continue;
  99.  
  100. // Set who the girl is and start the timer
  101. if (_gameStats.TheGirl == null)
  102. {
  103. _gameStats.TheGirl = client;
  104. _stopWatch.Start();
  105. _lastManStanding.Start();
  106. }
  107.  
  108. // Set the clients position for the mini map icon
  109. _x = client.OriginX;
  110. _y = client.OriginY;
  111.  
  112. // Check if the clients last known position is different from their current position
  113. if (_gameStats.LastKnownPosition != null)
  114. {
  115. _gameStats.IsNotMovingAround = !IsClientMoving(client);
  116. }
  117.  
  118. // Update the icon details
  119. ChangeIcon();
  120. SetPosition();
  121.  
  122. _gameStats.LastKnownPosition = new Vector(client.OriginX, client.OriginY, client.OriginZ);
  123.  
  124. break;
  125. }
  126. }
  127. else
  128. {
  129. UpdateMiniMapIcon(true);
  130. }
  131. }
  132. catch (Exception)
  133. {
  134. // Doesn't get used, its here to simply catch any errors that occur while the MW3 server
  135. // is booting up or changing maps
  136. }
  137. }
  138.  
  139. /// <summary>
  140. /// Executes when the map changes
  141. /// </summary>
  142. public override void OnMapChange()
  143. {
  144. UpdateMiniMapIcon(true);
  145. }
  146.  
  147. /// <summary>
  148. /// Executes when the current game map restarts
  149. /// </summary>
  150. public override void OnFastRestart()
  151. {
  152. UpdateMiniMapIcon(true);
  153. }
  154.  
  155. /// <summary>
  156. /// Executes when a player types something into the game chat
  157. /// </summary>
  158. /// <param name="message"></param>
  159. /// <param name="client"></param>
  160. /// <param name="teamchat"></param>
  161. /// <returns></returns>
  162. public override ChatType OnSay(string message, ServerClient client, bool teamchat)
  163. {
  164. string[] command = message.Split(' ');
  165.  
  166. if (command[0] != "!icon") return ChatType.ChatContinue;
  167.  
  168. // Parse the given icon number if one was given otherwise let the client know they did
  169. // something when typing the "!icon" command
  170. if (command[1] == null || command[1].Length == 0 || !int.TryParse(command[1], out _configuration.IconNumber))
  171. {
  172. TellClient(client.ClientNum, "^1Invalid icon number, E.g. ^7!icon 1", true);
  173. }
  174. else
  175. {
  176. ChangeIcon();
  177. }
  178.  
  179. return ChatType.ChatNone;
  180. }
  181.  
  182. /// <summary>
  183. /// Updates the position of the mini map icon given that is there only one player on the allies team
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void FindTheGirl(object sender, ElapsedEventArgs e)
  188. {
  189. if (_gameStats.TheGirl == null)
  190. {
  191. return;
  192. }
  193.  
  194. double elasped = Math.Abs(_stopWatch.Elapsed.TotalSeconds);
  195.  
  196. // Check if we need to detect for movement, if there hasn't been any movement for the time period set
  197. // and the stop watch has reached its goal or if we don't need to detect for movement show the icon on
  198. // the mini map
  199. if ((_configuration.DetectMovement && _gameStats.IsNotMovingAround && elasped >= _configuration.ResetTime) ||
  200. elasped >= _configuration.GirlyTime)
  201. {
  202. ChangeIcon();
  203. IconStatus(1);
  204. UpdateMiniMapIcon(false);
  205. }
  206. else if (_configuration.DetectMovement && !_gameStats.IsNotMovingAround)
  207. {
  208. IconStatus(0);
  209. _stopWatch.Reset();
  210. _stopWatch.Start();
  211. }
  212. }
  213.  
  214. /// <summary>
  215. /// Deactivates the current mini map icon and resets the last man standing timer for the next game
  216. /// </summary>
  217. private void UpdateMiniMapIcon(bool deactivate)
  218. {
  219. _gameStats.ClientsHuman = 0;
  220. _gameStats.ClientsInfected = 0;
  221. _gameStats.ClientsTotal = 0;
  222.  
  223. // Deactivate the mini map icon
  224. if (deactivate)
  225. {
  226. IconStatus(0);
  227. }
  228.  
  229. // Stop the timers
  230. if ((!deactivate && !_configuration.DetectMovement) || deactivate)
  231. {
  232. _stopWatch.Reset();
  233. _stopWatch.Stop();
  234. _lastManStanding.Stop();
  235.  
  236. _gameStats.IsNotMovingAround = false;
  237. _gameStats.TheGirl = null;
  238. }
  239. }
  240.  
  241. /// <summary>
  242. /// Determines if the client is moving around
  243. /// </summary>
  244. /// <param name="client"></param>
  245. /// <returns></returns>
  246. private bool IsClientMoving(ServerClient client)
  247. {
  248. return Math.Abs(Math.Abs(client.OriginX - _gameStats.LastKnownPosition.X)) >= _configuration.Threshold ||
  249. Math.Abs(Math.Abs(client.OriginY - _gameStats.LastKnownPosition.Y)) >= _configuration.Threshold ||
  250. Math.Abs(Math.Abs(client.OriginZ - _gameStats.LastKnownPosition.Z)) >= _configuration.Threshold;
  251. }
  252.  
  253. /// <summary>
  254. /// Activates/deactivates the icon on the minimap
  255. /// </summary>
  256. public unsafe void IconStatus(int status)
  257. {
  258. *(int*) _activate = status;
  259. }
  260.  
  261. /// <summary>
  262. /// Changes the icon on the mini map
  263. /// </summary>
  264. public unsafe void ChangeIcon()
  265. {
  266. *(int*)_icon = _configuration.IconNumber;
  267. }
  268.  
  269. /// <summary>
  270. /// Sets the position of the icon on the mini map
  271. /// </summary>
  272. public unsafe void SetPosition()
  273. {
  274. *(float*) _originX = _x;
  275. *(float*) _originY = _y;
  276. }
  277. }
  278.  
  279. internal class GameOptions
  280. {
  281. public int ClientsTotal = 0;
  282. public int ClientsInfected = 0;
  283. public int ClientsHuman = 0;
  284. public bool IsNotMovingAround = false;
  285. public ServerClient TheGirl;
  286. public Vector LastKnownPosition;
  287. }
  288.  
  289. internal class Configuration
  290. {
  291. public int IconNumber = 40;
  292. public int GirlyTime = 30;
  293. public bool DetectMovement = true;
  294. public int Threshold = 30;
  295. public int ResetTime = 5;
  296. }
  297. }


Credits:
@8q4s8 - Waypoint plugin creator
@MADD_DOGG - For such a simple yet cool idea
@Nukem - For such a great code base to work with

Apart from that the plugin will work its magic in the background without any input been required by the client. Enjoy!
[attachment=2736][attachment=2713][attachment=2709]
Nice plugin, I already released a similar one in this thread
http://www.itsmods.com/forum/Thread-Rele...class.html
but without config Wink
Thank 8q4s8, I actually didn't see your plugin when I was checking through what you had released, if I did I guess the name wasn't obvious enough to me in my sleep deprived state of mind.

@Rendflex haha, if web containers existed within MW3 I would totally embed that next to the mini map
Small update released, in the next release I will add functionality that will detect if the last human is actually camping in a corner or moving around.
awesome... very good very good. nice job
hi Sgt Legend you awesome man

but some problem in mw3 is not resolved

like friendly fire and respawn delay and killcam

can you build a plug for this problems?

for example remove minimap and dead icon in soft core mod

if you fix this

really you are legend in mw3

sry for my bad language
Hi nouri.reza,

I'm not familiar with the "soft core mod" so I wouldn't know any way of fixing the issues you have described above, I created this plugin for typical infected servers so for anything additional it would require more work and a lot of testing.
the soft core = minimap + dead icon + amoo icon and everything on my screen

i try to remove this icon without hardcore mod like this old plugins

http://www.itsmods.com/forum/Thread-Rele...f-off.html

or

remove respawn delay and friendly fire and allow killcam to hardcore like this

www.itsmods.com/forum/Thread-Release-HC-respawn-delay-fixer.html

but in new ver in steam this Source code not working on dedicated server

you C# is very better of me

many of random mod player try to play hardcore in steam mw3 like mw3 Fourdeltaone or great mw2

no ff no respawn delay allow kill cam

i ask for help to fix problem with sample code of old plugins

again sorry for my bad language
i think he means removing deathmarks (where your teammates die) without enabling hardcore mode.

im controlling myself not to say "English , mothefucker. do you speak it"
but im not as nice as @SgtLegend.
anyway , i dont think what you're asking can be done.
Pages: 1 2 3