Post: [MW2/1.14/C#] Gold Desert eagle and Default weapon for all clients
11-19-2013, 05:13 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); The is the code to give the gold desert eagle or default weapon to a client in mw2:
    
public static void giveDeagle(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Deagle */
setSecondaryWeapon(client, 45, true); // Gold Deagle 0x002D (45) - + 0x01 on some maps

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x23);
modifyAmmo(0x14e250a + offset, 0x23);
modifyAmmo(0x14e2502 + offset, 0x24); // Index is shifted on some maps
//modifyAmmo(0x14e2512 + offset, 0x24);
}

public static void giveDefault(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Default */
setSecondaryWeapon(client, 1, false);

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x01);
modifyAmmo(0x14e250a + offset, 0x01);
modifyAmmo(0x14e2502 + offset, 0x01);
modifyAmmo(0x14e2512 + offset, 0x01);
}

static void modifyAmmo(ulong address, byte index)
{
SetMemory(address, new byte[] { 0x00, index, 0x0F, 0xFF, 0xFF, 0xFF }); // Set ammo index to deagle's + infinite ammo
}

public static void setSecondaryWeapon(int client, UInt16 weapIndex, bool shiftIndex)
{
if ( shiftIndex )
IncrementWeaponIndex(ref weapIndex);

byte[] bytes = BitConverter.GetBytes(weapIndex);
Array.Reverse(bytes);
SetMemory(0x014e2422 + (uint)(client * 0x3700), bytes);
}

public static void IncrementWeaponIndex(ref UInt16 weapIndex)
{
if (isSpecialMap())
{
weapIndex++;
}
}

public static bool isSpecialMap()
{
string[] maps = new string[]{
"mp_afghan",
"mp_highrise",
"mp_checkpoint", // Karachi
"mp_quarry",
"mp_rundown",
"mp_nightshift", // Skidrow
"mp_terminal",
"mp_brecourt", // Wasteland
};

return maps.Contains(getCurrentMap());
}

public static string getCurrentMap()
{
byte[] map_buffer = new byte[31];

GetMemory(0xD495F4, ref map_buffer); // Loaded map fastfile - alt: 0xD4A688

string raw_name = ASCIIEncoding.ASCII.GetString(map_buffer);
return clear_string(raw_name);
}

public static string clear_string(string str)
{
string newstring = "";

for (int i = 0; i < str.Length; i++)
{
if (str[i] == (char)0x00)
break;

newstring += str[i];
}

return newstring;
}


Use giveDeagle(client); or giveDefault(client); to give the weapon.

I haven't found this anywhere, so i coded it myself.
If you want, I can explain the code, but atm I don't have enough time.

Have fun Smile

Credit: Me Happy

EDIT: Didn't see SC58 already posted it. At least mine fixes it for every map.
(adsbygoogle = window.adsbygoogle || []).push({});

The following 6 users say thank you to momo5502 for this useful post:

John, Obris, QuantumDev, SnaY, Taylors Bish
11-19-2013, 07:08 PM #2
QuantumDev
Can’t trickshot me!
Originally posted by momo5502 View Post
The is the code to give the gold desert eagle or default weapon to a client in mw2:
    
public static void giveDeagle(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Deagle */
setSecondaryWeapon(client, 45, true); // Gold Deagle 0x002D (45) - + 0x01 on some maps

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x23);
modifyAmmo(0x14e250a + offset, 0x23);
modifyAmmo(0x14e2502 + offset, 0x24); // Index is shifted on some maps
//modifyAmmo(0x14e2512 + offset, 0x24);
}

public static void giveDefault(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Default */
setSecondaryWeapon(client, 1, false);

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x01);
modifyAmmo(0x14e250a + offset, 0x01);
modifyAmmo(0x14e2502 + offset, 0x01);
modifyAmmo(0x14e2512 + offset, 0x01);
}

static void modifyAmmo(ulong address, byte index)
{
SetMemory(address, new byte[] { 0x00, index, 0x0F, 0xFF, 0xFF, 0xFF }); // Set ammo index to deagle's + infinite ammo
}

public static void setSecondaryWeapon(int client, UInt16 weapIndex, bool shiftIndex)
{
if ( shiftIndex )
IncrementWeaponIndex(ref weapIndex);

byte[] bytes = BitConverter.GetBytes(weapIndex);
Array.Reverse(bytes);
SetMemory(0x014e2422 + (uint)(client * 0x3700), bytes);
}

public static void IncrementWeaponIndex(ref UInt16 weapIndex)
{
if (isSpecialMap())
{
weapIndex++;
}
}

public static bool isSpecialMap()
{
string[] maps = new string[]{
"mp_afghan",
"mp_highrise",
"mp_checkpoint", // Karachi
"mp_quarry",
"mp_rundown",
"mp_nightshift", // Skidrow
"mp_terminal",
"mp_brecourt", // Wasteland
};

return maps.Contains(getCurrentMap());
}

public static string getCurrentMap()
{
byte[] map_buffer = new byte[31];

GetMemory(0xD495F4, ref map_buffer); // Loaded map fastfile - alt: 0xD4A688

string raw_name = ASCIIEncoding.ASCII.GetString(map_buffer);
return clear_string(raw_name);
}

public static string clear_string(string str)
{
string newstring = "";

for (int i = 0; i < str.Length; i++)
{
if (str[i] == (char)0x00)
break;

newstring += str[i];
}

return newstring;
}


Use giveDeagle(client); or giveDefault(client); to give the weapon.

I haven't found this anywhere, so i coded it myself.
If you want, I can explain the code, but atm I don't have enough time.

Have fun Smile

Credit: Me Happy


Very nice man! Thanks! Will definitely use this.
11-19-2013, 11:11 PM #3
Gandalf
Gandalf the Orange
Thread moved on request
11-28-2013, 11:41 PM #4
seb5594
Proud Former Admin
Thanks man. Finally someone can build up nice functions :p
12-02-2013, 11:30 AM #5
SnaY
Former Lead of GS
Originally posted by momo5502 View Post
The is the code to give the gold desert eagle or default weapon to a client in mw2:
    
public static void giveDeagle(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Deagle */
setSecondaryWeapon(client, 45, true); // Gold Deagle 0x002D (45) - + 0x01 on some maps

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x23);
modifyAmmo(0x14e250a + offset, 0x23);
modifyAmmo(0x14e2502 + offset, 0x24); // Index is shifted on some maps
//modifyAmmo(0x14e2512 + offset, 0x24);
}

public static void giveDefault(int client)
{
uint offset = (uint)client * 0x3700;

/* Give Default */
setSecondaryWeapon(client, 1, false);

/* Give ammo */
modifyAmmo(0x14E24FA + offset, 0x01);
modifyAmmo(0x14e250a + offset, 0x01);
modifyAmmo(0x14e2502 + offset, 0x01);
modifyAmmo(0x14e2512 + offset, 0x01);
}

static void modifyAmmo(ulong address, byte index)
{
SetMemory(address, new byte[] { 0x00, index, 0x0F, 0xFF, 0xFF, 0xFF }); // Set ammo index to deagle's + infinite ammo
}

public static void setSecondaryWeapon(int client, UInt16 weapIndex, bool shiftIndex)
{
if ( shiftIndex )
IncrementWeaponIndex(ref weapIndex);

byte[] bytes = BitConverter.GetBytes(weapIndex);
Array.Reverse(bytes);
SetMemory(0x014e2422 + (uint)(client * 0x3700), bytes);
}

public static void IncrementWeaponIndex(ref UInt16 weapIndex)
{
if (isSpecialMap())
{
weapIndex++;
}
}

public static bool isSpecialMap()
{
string[] maps = new string[]{
"mp_afghan",
"mp_highrise",
"mp_checkpoint", // Karachi
"mp_quarry",
"mp_rundown",
"mp_nightshift", // Skidrow
"mp_terminal",
"mp_brecourt", // Wasteland
};

return maps.Contains(getCurrentMap());
}

public static string getCurrentMap()
{
byte[] map_buffer = new byte[31];

GetMemory(0xD495F4, ref map_buffer); // Loaded map fastfile - alt: 0xD4A688

string raw_name = ASCIIEncoding.ASCII.GetString(map_buffer);
return clear_string(raw_name);
}

public static string clear_string(string str)
{
string newstring = "";

for (int i = 0; i < str.Length; i++)
{
if (str[i] == (char)0x00)
break;

newstring += str[i];
}

return newstring;
}


Use giveDeagle(client); or giveDefault(client); to give the weapon.

I haven't found this anywhere, so i coded it myself.
If you want, I can explain the code, but atm I don't have enough time.

Have fun Smile

Credit: Me Happy

EDIT: Didn't see SC58 already posted it. At least mine fixes it for every map.


Niceee ^^
07-26-2015, 11:26 PM #6
New to MW2 modding i have a jailbroken PS3 on CEX will it work? also how do i inject or whatever to get it?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo