//A very .NET approach on doing this :D public static string[] Read(RemoteMemory Mem) { Mem.Position = Addresses.GameData; StringBuilder builder = new StringBuilder(); List<string> final = new List<string>(); while (true) { string buffer = Mem.ReadString(256); if (buffer.Count(c => c == '\0') != 256) { builder.Append(buffer); } else break; } foreach (string data in builder.ToString().Split('\0')) { if (data != string.Empty) final.Add(data); } return final.ToArray(); }
void zFrame(object x) { LoopMem = new RemoteMemory((Process)x); int GameDataInterval = 0; while (run) { #region GameData gathering / Map events if (GameDataInterval++ == 10) { GameDataInterval = 0; string[] NewGameData = GameDataReader.Read(LoopMem); //use the gamedata as indicator of a new map being loaded/destroyed because i'm a f*****g noob and i don't know how to handle events (YET) if (GameData.Length == 0 && NewGameData.Length > 0) { w_eapons = GameDataReader.GetWeapons(NewGameData); PluginEvent(OnMapLoad); } else if (GameData.Length > 0 && NewGameData.Length == 0) { w_eapons = GameDataReader.GetWeapons(NewGameData); PluginEvent(OnMapDestroy); } GameData = NewGameData; } #endregion #region Portal Manager if(Portals.Count > 0) foreach (Player player in GetPlayers()) { foreach (Portal portal in Portals) { float[] orig = player.World.Origin; if ( orig[0] < portal.X + portal.Radius && orig[0] > portal.X - portal.Radius && orig[1] < portal.Y + portal.Radius && orig[1] > portal.Y - portal.Radius ) { WriteLine(string.Format("Portal @ {0}, {1} ({2}) triggered by {3}", portal.X, portal.Y, portal.Radius, player.Name), true); if(portal.Teleport) player.World.Origin = portal.Destination; portal.trigger(portal, player); } } } #endregion HookManager.Frame(); if (OnFrame != null) { PluginEvent(OnFrame, new object[] { }); } Thread.Sleep(200); } ded = true; }
/// <summary> /// Initializes jZm onto a certain game process. Make sure the game is the correct process, This function doesn't check if the process is correct. /// </summary> /// <remarks> /// DO NOT CALL FROM A PLUGIN. This function is called from the jZm frontend and you should not call it from a plugin. /// </remarks> /// <param name="Game">The game process jZm reads/writes to (must be a valid CODBOII zombies process)</param> public void Bootstrap(Process Game) { ZombieAPI._instance = this; WriteLine("Initializing jZm..."); long start = DateTime.Now.Ticks; WriteLine("Connecting to game...", true); this.BaseProcess = Game; Memory = new RemoteMemory(Game); // this is to redirect the hooks to jZm (and optionally a buffer together) //CurrentIPC = new IPC(); //CurrentIPC.InitJZMEventHookingManager(Memory.ProcessHandle); WriteLine("Recognizing patterns...", true); PatternRecognition.Run(Memory.ProcessHandle); WriteLine("Reading entities...", true); _level = new GameObjects.Level(Game, Addresses.Level, this); int x = 0; while (x != 1024) { _entities.Add(new GEntity(Memory.Process, Addresses.GEntity + (Addresses.GEntity_Size * x), this)); x++; } WriteLine("Reading DVars...", true); x = 0; Memory.Position = Addresses.DvarPointers; while (x != 1024) { DVar dvar = new DVar(Game, Memory.ReadInt32(), this); _dvars.Add(dvar); x++; } WriteLine("Injecting hooks...", true); HookManager.Init(Memory.ProcessHandle, this); initPlugins(); DateTime initTime = new DateTime(DateTime.Now.Ticks - start); new TestingPlugin().Init(this); WriteLine("Initialized in " + initTime.Second + "." + initTime.Millisecond + " second(s)"); // add infinite event waiter ThreadPool.QueueUserWorkItem(new WaitCallback(zFrame), Game); }