Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SOURCE: http://www.nextgenupdate.com/forums/modern-warfare-3-mods-patches-tutorials/749369-c-mystery-box.html
- //Mw3 Mystery Box:
- public static class MysteryBox
- {
- #region Variables
- private static uint Weapon = 0;
- private static uint[] MBIndexes = new uint[3];
- private static string WeaponName = null;
- private static Thread MBThread;
- #endregion
- #region Read + Write
- private static string ReadString(uint Offset)
- {
- uint num = 0;
- List<byte> List = new List<byte>();
- while (true)
- {
- byte[] buffer = new byte[1];
- PS3.GetMemory(Offset + num, buffer);
- if (buffer[0] == 0)
- {
- return Encoding.UTF8.GetString(List.ToArray());
- }
- List.Add(buffer[0]);
- num++;
- }
- }
- private static float ReadFloat(uint Offset)
- {
- byte[] buffer = new byte[4];
- PS3.GetMemory(Offset, buffer);
- Array.Reverse(buffer, 0, 4);
- return BitConverter.ToSingle(buffer, 0);
- }
- private static int ReadInt(uint Offset)
- {
- byte[] buffer = new byte[4];
- PS3.GetMemory(Offset, buffer);
- Array.Reverse(buffer);
- int Value = BitConverter.ToInt32(buffer, 0);
- return Value;
- }
- private static float[] ReadFloatLength(uint Offset, int Length)
- {
- byte[] buffer = new byte[Length * 4];
- PS3.GetMemory(Offset, buffer);
- Array.Reverse(buffer);
- float[] FArray = new float[Length];
- for (int i = 0; i < Length; i++)
- {
- FArray[i] = BitConverter.ToSingle(buffer, (Length - 1 - i) * 4);
- }
- return FArray;
- }
- private static void WriteString(uint Offset, string Text)
- {
- byte[] buffer = Encoding.UTF8.GetBytes(Text);
- Array.Resize(ref buffer, buffer.Length + 1);
- PS3.SetMemory(Offset, buffer);
- }
- private static void WriteByte(uint Offset, byte Byte)
- {
- byte[] buffer = new byte[1];
- buffer[0] = Byte;
- PS3.SetMemory(Offset, buffer);
- }
- private static void WriteFloat(uint Offset, float Float)
- {
- byte[] buffer = new byte[4];
- BitConverter.GetBytes(Float).CopyTo(buffer, 0);
- Array.Reverse(buffer, 0, 4);
- PS3.SetMemory(Offset, buffer);
- }
- private static void WriteFloatArray(uint Offset, float[] Array)
- {
- byte[] buffer = new byte[Array.Length * 4];
- for (int Lenght = 0; Lenght < Array.Length; Lenght++)
- {
- ReverseBytes(BitConverter.GetBytes(Array[Lenght])).CopyTo(buffer, Lenght * 4);
- }
- PS3.SetMemory(Offset, buffer);
- }
- private static void WriteInt(uint Offset, int Value)
- {
- byte[] buffer = BitConverter.GetBytes(Value);
- Array.Reverse(buffer);
- PS3.SetMemory(Offset, buffer);
- }
- private static void WriteUInt(uint Offset, uint Value)
- {
- byte[] buffer = new byte[4];
- BitConverter.GetBytes(Value).CopyTo(buffer, 0);
- Array.Reverse(buffer, 0, 4);
- PS3.SetMemory(Offset, buffer);
- }
- private static byte[] ReverseBytes(byte[] inArray)
- {
- Array.Reverse(inArray);
- return inArray;
- }
- #endregion
- #region RPC
- private static uint func_address = 0x0277208;
- private static void Enable()
- {
- byte[] Check = new byte[1];
- PS3.GetMemory(func_address + 4, Check);
- if (Check[0] == 0x3F)
- {
- }
- else
- {
- byte[] PPC = new byte[]
- {0x3F,0x80,0x10,0x05,0x81,0x9C,0,0x48,0x2C,0x0C,0, 0,0x41,0x82,0,0x78,
- 0x80,0x7C,0,0,0x80,0x9C,0,0x04,0x80,0xBC,0,0x08,0x80,0xDC,0,0x0C,0x80,
- 0xFC,0,0x10,0x81,0x1C,0,0x14,0x81,0x3C,0,0x18,0x81 ,0x5C,0,0x1C,0x81,
- 0x7C,0,0x20,0xC0,0x3C,0,0x24,0xC0,0x5C,0,0x28,0xC0 ,0x7C,0,0x2C,0xC0,
- 0x9C,0,0x30,0xC0,0xBC,0,0x34,0xC0,0xDC,0,0x38,0xC0 ,0xFC,0,0x3C,0xC1,
- 0x1C,0,0x40,0xC1,0x3C,0,0x44,0x7D,0x89,0x03,0xA6,0x4E,0x80,0x04,0x21,
- 0x38,0x80,0,0,0x90,0x9C,0,0x48,0x90,0x7C,0,0x4C,0xD0,0x3C,0,0x50,0x48,0,0,0x14};
- PS3.SetMemory(func_address, new byte[] { 0x41 });
- PS3.SetMemory(func_address + 4, PPC);
- PS3.SetMemory(func_address, new byte[] { 0x40 });
- }
- }
- private static int Call(uint address, params object[] parameters)
- {
- int length = parameters.Length;
- int index = 0;
- uint count = 0;
- uint Strings = 0;
- uint Single = 0;
- uint Array = 0;
- while (index < length)
- {
- if (parameters[index] is int)
- {
- WriteInt(0x10050000 + (count * 4), (int)parameters[index]);
- count++;
- }
- else if (parameters[index] is uint)
- {
- WriteUInt(0x10050000 + (count * 4), (uint)parameters[index]);
- count++;
- }
- else if (parameters[index] is byte)
- {
- WriteByte(0x10050000 + (count * 4), (byte)parameters[index]);
- count++;
- }
- else
- {
- uint pointer;
- if (parameters[index] is string)
- {
- pointer = 0x10052000 + (Strings * 0x400);
- WriteString(pointer, Convert.ToString(parameters[index]));
- WriteUInt(0x10050000 + (count * 4), (uint)pointer);
- count++;
- Strings++;
- }
- else if (parameters[index] is float)
- {
- WriteFloat(0x10050024 + (Single * 4), (float)parameters[index]);
- Single++;
- }
- else if (parameters[index] is float[])
- {
- float[] Args = (float[])parameters[index];
- pointer = 0x10051000 + Array * 4;
- WriteFloatArray(pointer, Args);
- WriteUInt(0x10050000 + count * 4, (uint)pointer);
- count++;
- Array += (uint)Args.Length;
- }
- }
- index++;
- }
- WriteUInt(0x10050048, (uint)address);
- Thread.Sleep(20);
- return ReadInt(0x1005004c);
- }
- private static bool Dvar_GetBool(string DVAR)
- {//0x00291060 - Dvar_GetBool(const char *dvarName)
- bool State;
- uint Value = (uint)Call(0x00291060, DVAR);
- if (Value == 1)
- State = true;
- else
- State = false;
- return State;
- }
- #endregion
- #region HUDS
- private static uint Element(uint Index)
- {
- return 0xF0E10C + ((Index) * 0xB4);
- }
- private static uint StoreText(uint Index, decimal Client, string Text, int Font, float FontScale, int X, int Y, decimal R = 255, decimal G = 255, decimal B = 255, decimal A = 255, decimal R1 = 0, decimal G1 = 0, decimal B1 = 0, decimal A1 = 0)
- {
- uint elem = Element(Index);
- WriteInt(elem + 0x84, Call(0x1BE6CC, Text));
- WriteInt(elem + 0x24, Font);
- WriteFloat(elem + 0x14, FontScale);
- WriteFloat(elem + 0x4, X);
- WriteFloat(elem + 0x8, Y);
- PS3.SetMemory(elem + 0xa7, new byte[] { 7 });
- PS3.SetMemory(elem + 0x30, new byte[] { (byte)R, (byte)G, (byte)B, (byte)A });
- PS3.SetMemory(elem + 0x8C, new byte[] { (byte)R1, (byte)G1, (byte)B1, (byte)A1 });
- WriteInt(elem + 0xA8, (int)Client);
- System.Threading.Thread.Sleep(20);
- WriteInt(elem, 1);
- return elem;
- }
- #endregion
- #region Functions
- private enum Brush : uint
- {
- NULL = 0,
- CarePackage = 2,
- Bomb = 3,
- }
- private static uint SolidModel(float[] Origin, float[] Angles, string Model = "com_plasticcase_friendly", Brush Index = Brush.CarePackage)
- {
- uint Entity = (uint)Call(0x01C058C);//G_Spawn
- WriteFloatArray(Entity + 0x138, Origin);//Position
- WriteFloatArray(Entity + 0x144, Angles);//Orientation
- Call(0x01BEF5C, Entity, Model);//G_SetModel
- Call(0x01B6F68, Entity); //SP_script_model
- Call(0x002377B8, Entity);//SV_UnlinkEntity
- WriteByte(Entity + 0x101, 4);
- WriteByte(Entity + 0x8C + 3, (byte)Index);
- Call(0x0022925C, Entity);//SV_SetBrushModel
- Call(0x00237848, Entity);//SV_LinkEntity
- return Entity;
- }
- public static float[] GetOrigin(uint Client)
- {
- return ReadFloatLength(0x110a29c + (Client * 0x3980), 3);
- }
- private static string ChangeWeaponModel()
- {
- int Value = 0;
- byte[] buffer = new byte[100];
- PS3.GetMemory(0x8360d5, buffer);
- System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding();
- string Map = Encoding.GetString(buffer).Split(Convert.ToChar(0x5c))[6];
- if (Map == "mp_seatown" | Map == "mp_paris" |Map == "mp_plaza2" | Map == "mp_exchange" | Map == "mp_bootleg" | Map == "mp_alpha" | Map == "mp_village" | Map == "mp_bravo" | Map == "mp_courtyard_ss" | Map == "mp_aground_ss")
- Value = -1;
- else
- Value = 0;
- Random Random = new Random();
- switch (Random.Next(1, 50))
- {
- case 1:
- Weapon = (uint)Value + 4;
- WeaponName = "Riotshield";
- return "weapon_riot_shield_mp";
- case 2:
- Weapon = (uint)Value + 6;
- WeaponName = ".44 Magnum";
- return "weapon_44_magnum_iw5";
- case 3:
- Weapon = (uint)Value + 7;
- WeaponName = "USP .45";
- return "weapon_usp45_iw5";
- case 4:
- Weapon = (uint)Value + 9;
- WeaponName = "Desert Eagle";
- return "weapon_desert_eagle_iw5";
- case 5:
- Weapon = (uint)Value + 10;
- WeaponName = "MP412";
- return "weapon_mp412";
- case 6:
- Weapon = (uint)Value + 12;
- WeaponName = "P99";
- return "weapon_walther_p99_iw5";
- case 7:
- Weapon = (uint)Value + 13;
- WeaponName = "Five-Seven";
- return "weapon_fn_fiveseven_iw5";
- case 8:
- Weapon = (uint)Value + 14;
- WeaponName = "FMG9";
- return "weapon_fmg_iw5";
- case 9:
- Weapon = (uint)Value + 15;
- WeaponName = "Skorpion";
- return "weapon_skorpion_iw5";
- case 10:
- Weapon = (uint)Value + 16;
- WeaponName = "MP9";
- return "weapon_mp9_iw5";
- case 11:
- Weapon = (uint)Value + 17;
- WeaponName = "G18";
- return "weapon_g18_iw5";
- case 12:
- Weapon = (uint)Value + 18;
- WeaponName = "MP5";
- return "weapon_mp5_iw5";
- case 13:
- Weapon = (uint)Value + 19;
- WeaponName = "PM-9";
- return "weapon_uzi_m9_iw5";
- case 14:
- Weapon = (uint)Value + 20;
- WeaponName = "P90";
- return "weapon_p90_iw5";
- case 15:
- Weapon = (uint)Value + 21;
- WeaponName = "PP90M1";
- return "weapon_pp90m1_iw5";
- case 16:
- Weapon = (uint)Value + 22;
- WeaponName = "UMP45";
- return "weapon_ump45_iw5";
- case 17:
- Weapon = (uint)Value + 23;
- WeaponName = "MP7";
- return "weapon_mp7_iw5";
- case 18:
- Weapon = (uint)Value + 24;
- WeaponName = "AK-47";
- return "weapon_ak47_iw5";
- case 19:
- Weapon = (uint)Value + 25;
- WeaponName = "M16A4";
- return "weapon_m16_iw5";
- case 20:
- Weapon = (uint)Value + 26;
- WeaponName = "M4A1";
- return "weapon_m4_iw5";
- case 21:
- Weapon = (uint)Value + 27;
- WeaponName = "FAD";
- return "weapon_fad_iw5";
- case 22:
- Weapon = (uint)Value + 28;
- WeaponName = "ACR 6.8";
- return "weapon_remington_acr_iw5";
- case 23:
- Weapon = (uint)Value + 29;
- WeaponName = "Typ 95";
- return "weapon_type95_iw5";
- case 24:
- Weapon = (uint)Value + 30;
- WeaponName = "MK14";
- return "weapon_m14_iw5";
- case 25:
- Weapon = (uint)Value + 31;
- WeaponName = "SCAR-L";
- return "weapon_scar_iw5";
- case 26:
- Weapon = (uint)Value + 32;
- WeaponName = "G36C";
- return "weapon_g36_iw5";
- case 27:
- Weapon = (uint)Value + 33;
- WeaponName = "CM901";
- return "weapon_cm901";
- case 28:
- Weapon = (uint)Value + 35;
- WeaponName = "M320 GLM";
- return "weapon_m320_gl";
- case 29:
- Weapon = (uint)Value + 36;
- WeaponName = "RPG-7";
- return "weapon_rpg7";
- case 30:
- Weapon = (uint)Value + 37;
- WeaponName = "SMAW";
- return "weapon_smaw";
- case 31:
- Weapon = (uint)Value + 39;
- WeaponName = "Javelin";
- return "weapon_javelin";
- case 32:
- Weapon = (uint)Value + 40;
- WeaponName = "XM25";
- return "weapon_xm25";
- case 33:
- Weapon = (uint)Value + 12329;
- WeaponName = "Dragunow";
- return "weapon_dragunov_iw5";
- case 34:
- Weapon = (uint)Value + 12330;
- WeaponName = "MSR";
- return "weapon_remington_msr_iw5";
- case 35:
- Weapon = (uint)Value + 12331;
- WeaponName = "BARRET KAL. .50";
- return "weapon_m82_iw5";
- case 36:
- Weapon = (uint)Value + 12332;
- WeaponName = "RSASS";
- return "weapon_rsass_iw5";
- case 37:
- Weapon = (uint)Value + 12333;
- WeaponName = "AS50";
- return "weapon_as50_iw5";
- case 38:
- Weapon = (uint)Value + 12334;
- WeaponName = "L118A";
- return "weapon_l96a1_iw5";
- case 39:
- Weapon = (uint)Value + 47;
- WeaponName = "KSG 12";
- return "weapon_ksg_iw5";
- case 40:
- Weapon = (uint)Value + 48;
- WeaponName = "MODELL 1887";
- return "weapon_model1887";
- case 41:
- Weapon = (uint)Value + 49;
- WeaponName = "STRIKER";
- return "weapon_striker_iw5";
- case 42:
- Weapon = (uint)Value + 50;
- WeaponName = "AA-12";
- return "weapon_aa12_iw5";
- case 43:
- Weapon = (uint)Value + 51;
- WeaponName = "USAS12";
- return "weapon_usas12_iw5";
- case 44:
- Weapon = (uint)Value + 52;
- WeaponName = "SPAS-12";
- return "weapon_spas12_iw5";
- case 45:
- Weapon = (uint)Value + 54;
- WeaponName = "M60E4";
- return "weapon_m60_iw5";
- case 46:
- Weapon = (uint)Value + 17461;
- WeaponName = "AUG";
- return "weapon_steyr_digital";
- case 47:
- Weapon = (uint)Value + 55;
- WeaponName = "MK46";
- return "weapon_mk46_iw5";
- case 48:
- Weapon = (uint)Value + 56;
- WeaponName = "PKP PECHENEG";
- return "weapon_pecheneg_iw5";
- case 49:
- Weapon = (uint)Value + 57;
- WeaponName = "L86 LSW";
- return "weapon_sa80_iw5";
- case 50:
- Weapon = (uint)Value + 58;
- WeaponName = "MG36";
- return "weapon_mg36";
- }
- return null;
- }
- private static void MBFunction(float[] Origin, float[] Angles)
- {
- float[] BoxOrigin = Origin;
- float WeaponZ1 = 0;
- bool Running = false;
- uint ClientUsing = 0, WeaponID = 0;
- PS3.Connect();
- Origin[2] += 16;
- MBIndexes[0] = SolidModel(Origin, Angles, "com_plasticcase_trap_friendly");
- MBIndexes[1] = SolidModel(new float[] { Origin[0], Origin[1], Origin[2] += 28 }, Angles, "");
- MBIndexes[2] = SolidModel(new float[] { Origin[0] += -8, Origin[1], Origin[2] += -18 }, Angles, "weapon_ak47_iw5", Brush.NULL);
- WeaponID = MBIndexes[2];
- while (MBThread.IsAlive)
- {
- if (Dvar_GetBool("cl_ingame") == false)
- {
- MBThread.Abort();
- for (uint i = 0; i < 3; i++)
- PS3.SetMemory(MBIndexes[i], new byte[0x280]);
- PS3.SetMemory(0xF0E10C + (500 * 0xB4), new byte[18 * 0xB4]);
- }
- else
- {
- if (Running == false)
- {
- for (uint Client = 0; Client < 18; Client++)
- {
- if (ReadInt(0xFCA41D + (Client * 0x280)) > 0)
- {
- float[] PlayerOrigin = ReadFloatLength(0x110a29c + (Client * 0x3980), 3);
- float X = PlayerOrigin[0] - BoxOrigin[0];
- float Y = PlayerOrigin[1] - BoxOrigin[1];
- float Z = PlayerOrigin[2] - (BoxOrigin[2] - 23);
- float Distance = (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z));
- if (Distance < 50)
- {
- StoreText(500 + Client, Client, "Press for a Random Weapon", 7, 0.8f, 195, 300);
- byte[] Key = new byte[1];
- PS3.GetMemory(0x110D5E3 + (0x3980 * Client), Key);
- if (Key[0] == 0x20)
- {
- PS3.SetMemory(0xF0E10C + (500 * 0xB4), new byte[18 * 0xB4]);
- float WeaponZ = Origin[2];
- for (int i = 0; i < 37; i++)
- {
- WriteFloat(WeaponID + 0x20, WeaponZ += 0.7f);
- if ((i / 2) * 2 == i)
- {
- WriteUInt(WeaponID + 0x58, (uint)Call(0x1BE7A8, ChangeWeaponModel()));
- }
- if (i == 36)
- {
- break;
- }
- WeaponZ1 = WeaponZ;
- Thread.Sleep(100);
- }
- Running = true;
- ClientUsing = Client;
- break;
- }
- }
- else
- {
- PS3.SetMemory(Element(500 + Client), new byte[0xB4]);
- }
- }
- }
- }
- else
- {
- for (int i = 0; i < 37; i++)
- {
- float[] PlayerOrigin = ReadFloatLength(0x110a29c + (ClientUsing * 0x3980), 3);
- float X = PlayerOrigin[0] - BoxOrigin[0];
- float Y = PlayerOrigin[1] - BoxOrigin[1];
- float Z = PlayerOrigin[2] - (BoxOrigin[2] - 23);
- float Distance = (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z));
- if (Distance < 50)
- {
- StoreText(500 + ClientUsing, ClientUsing, "Press for " + WeaponName, 7, 0.8f, 195, 300);
- byte[] Key = new byte[1];
- PS3.GetMemory(0x110D5E3 + (0x3980 * ClientUsing), Key);
- if (Key[0] == 0x20)
- {
- if (ReadInt(0x0110a5f0 + (ClientUsing * 0x3980)) == ReadInt(0x0110a4fc + (ClientUsing * 0x3980)))
- {
- WriteUInt(0x0110a4fc + (ClientUsing * 0x3980), Weapon);
- WriteUInt(0x0110a624 + (ClientUsing * 0x3980), Weapon);
- WriteUInt(0x0110a6a4 + (ClientUsing * 0x3980), Weapon);
- }
- else
- {
- WriteUInt(0x0110a4f4 + (ClientUsing * 0x3980), Weapon);
- WriteUInt(0x0110a68c + (ClientUsing * 0x3980), Weapon);
- WriteUInt(0x0110a614 + (ClientUsing * 0x3980), Weapon);
- }
- WriteUInt(0x0110a5f0 + (ClientUsing * 0x3980), Weapon);
- Call(0x18A29C, 0xFCA280 + (ClientUsing * 0x280), Weapon, "", 9999, 9999);
- WriteFloat(WeaponID + 0x20, Origin[2]);
- WriteUInt(WeaponID + 0x58, (uint)Call(0x1BE7A8, "weapon_ak47_iw5"));
- PS3.SetMemory(Element(500 + ClientUsing), new byte[0xB4]);
- Running = false;
- break;
- }
- else
- {
- WriteFloat(WeaponID + 0x20, WeaponZ1 += -0.7f);
- if (i == 36)
- {
- WriteUInt(WeaponID + 0x58, (uint)Call(0x1BE7A8, "weapon_ak47_iw5"));
- PS3.SetMemory(Element(500 + ClientUsing), new byte[0xB4]);
- Running = false;
- break;
- }
- Thread.Sleep(200);
- }
- }
- else
- {
- PS3.SetMemory(Element(500 + ClientUsing), new byte[0xB4]);
- WriteFloat(WeaponID + 0x20, WeaponZ1 += -0.7f);
- if (i == 36)
- {
- WriteUInt(WeaponID + 0x58, (uint)Call(0x1BE7A8, "weapon_ak47_iw5"));
- PS3.SetMemory(Element(500 + ClientUsing), new byte[0xB4]);
- Running = false;
- break;
- }
- Thread.Sleep(200);
- }
- }
- Thread.Sleep(2000);
- }
- }
- }
- }
- #endregion
- public static void Spawn(float[] Origin, float Yaw)
- {
- Enable();
- float[] Angles = new float[] { 0, Yaw, 0 };
- ThreadStart Start = null;
- Thread.Sleep(100);
- if (Start == null)
- {
- Start = () => MBFunction(Origin, Angles);
- }
- MBThread = new Thread(Start);
- MBThread.IsBackground = true;
- MBThread.Start();
- }
- public static void DeleteMB()
- {
- MBThread.Abort();
- for (uint i = 0; i < 3; i++)
- PS3.SetMemory(MBIndexes[i], new byte[0x280]);
- PS3.SetMemory(0xF0E10C + (500 * 0xB4), new byte[18 * 0xB4]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement