Post: C++ MW3 How to give weapons proper way
11-12-2017, 06:39 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Hi guys,

Another release on how to give weapons the proper way C++.
Credits to Chris - Swagg - DevOps. You can add this to your sprx and then you can give weapon with camo and attachments, reticle of choice. Also modded combinations like Augbar with working heartbeat sensor and thermalscope...

    
namespace Weapons {

struct gclient_s {
char unk0[0x3980];
};


struct gentity_s {
char unk0[0x280];
};

gentity_s *getEntity(int ent) {
return (gentity_s*)(0xFCA280 + (0x280 * ent));
}
gclient_s *getClient(int clientIndex) {
return (gclient_s*)(0x0110A280 + (0x3980 * clientIndex));
}

void G_SelectWeapon(int clientIndex, int WeaponIndex) {
char buff[50];
Com_sprintf(buff, sizeof(buff), "%c %i", 97, WeaponIndex);
SV_GameSendServerCommand(clientIndex, 1, buff);
}
opd_s GGPW = { 0x001C3034, TOC };
int(*G_GivePlayerWeapon)(gclient_s* clientIndex, int iWeaponIndex, char altModelIndex) = (int(*)(gclient_s*, int, char))&GGPW;

opd_s AA = { 0x0018A29C, TOC };
void(*Add_Ammo)(gentity_s* Entity, unsigned int weaponIndex, char weaponModel, int count, int fillClip) = (void(*)(gentity_s*, unsigned int, char, int, int))&AA;


int BG_GetViewmodelWeaponIndex(int clientIndex) // added
{
return *(int*)(getClient(clientIndex) + 0x370);
}

int G_TakePlayerWeapon(gclient_s *clientIndex, unsigned int weaponIndex) {
opd_s G_TakePlayerWeapon_t = { 0x001C409C , TOC };
int(*G_TakePlayerWeapon)(gclient_s *clientIndex, unsigned int weaponIndex) = (int(*)(gclient_s*, unsigned int))&G_TakePlayerWeapon_t;
return G_TakePlayerWeapon(clientIndex, weaponIndex);
}

opd_s GGPW1 = { 0x00110a4fc, TOC };
int(*G_GivePlayerprimWeapon)(gclient_s* clientIndex, int iWeaponIndex) = (int(*)(gclient_s*, int))&GGPW1;

int G_GetWeaponForName(const char* WeaponName) {
opd_s G_GetWeaponForName_t = { 0x001c34b8, TOC };
int(*G_GetWeaponForName)(int Buffer, const char* WeaponName) = (int(*)(int, const char*))&G_GetWeaponForName_t;
G_GetWeaponForName(0x1004f000, WeaponName);
return *(int*)(0x1004f000);
}


int GivePlayerWeapon(int clientIndex, const char* Weapon, bool RemoveOld = true, bool Akimbo = false) {

int WeaponIndex;
if(RemoveOld)
G_TakePlayerWeapon(getClient(clientIndex), *(int*)(0x0110a5f0 + (clientIndex * 0x3980)));
if (strcmp(Weapon, ""))
WeaponIndex = G_GetWeaponForName(Weapon);
G_GivePlayerWeapon(getClient(clientIndex), WeaponIndex, Akimbo ? 1 : 0);
Add_Ammo(getEntity(clientIndex), WeaponIndex, 0, 9999, 9999);
G_SelectWeapon(clientIndex, WeaponIndex);
return WeaponIndex;
}

void GiveWeaponbyIndex(int clientIndex, int Index)
{
G_GivePlayerWeapon(getClient(clientIndex), Index, 1);
Add_Ammo(getEntity(clientIndex), Index, 0, 9999, 1);
}

namespace WeaponsInfo {

const char* Weapon[66];
const char* Attachment[40];
const char* Camo[14];
const char* Reticle[7];
enum Weapons_e {

NoneWeapon = 0,
Riotshield = 1,
Magnum44 = 2,
usp45 = 3,
desertEagle = 4,
mp412 = 5,
p99 = 6,
five7 = 7,
fmg9 = 8,
skorpion = 9,
mp9 = 10,
g18 = 11,
mp5 = 12,
m9 = 13,
p90 = 14,
pp90m1 = 15,
ump45 = 16,
mp7 = 17,
ak47 = 18,
m16 = 19,
m4a1 = 20,
fad = 21,
acr = 22,
type95 = 23,
mk14 = 24,
scar = 25,
g36c = 26,
cm901 = 27,
m320 = 28,
rpg = 29,
smaw = 30,
stinger = 31,
javelin = 32,
xm25 = 33,
dragunov = 34,
msr = 35,
barret = 36,
rssas = 37,
as50 = 38,
l96a1 = 39,
ksg = 40,
M1887 = 41,
striker = 42,
aa12 = 43,
usas12 = 44,
spas12 = 45,
m60 = 46,
m60jugg = 47, // augbar
mk46 = 48,
pecheneg = 49,
sa80 = 50,
mg36 = 51,
usp45jugg = 52,
mp412jugg = 53,
FN2000 = 54,
Supernoobtube = 55,
ac130_25mm = 56,
ac130_40mm = 57,
ac130_105mm = 58,
airdrop_marker = 59,
briefcase_bomb = 60,
ims_projectile = 61,
killstreak_helicopter_minigun_mp = 62,//briefcase
mortar_remote_zoom = 63, //Reaper interface
mortar_remote_mp = 64, //Reaper interface ++
killstreak_remote_mortar_mp = 65,// reaper laptop

};


enum Attachments_e {

NoneAttachment = 0,
reflex = 1,
reflexsmg = 2,
reflexlmg = 3,
HolographicSight = 4,
HolographicSightsmg = 5,
HolographicSightlmg = 6,
acog = 7,
acogsmg = 8,
hybrid = 9,
hamrhybrid = 10,
thermal = 11,
thermalsmg = 12,
barretscope = 13,
barretscopevz = 14,
dragunovscope = 15,
dragunovscopevz = 16,
l96a1scope = 17,
l96a1scopevz = 18,
as50scope = 19,
as50scopevz = 20,
rssasscope = 21,
rssasscopevz = 22,
msrscope = 23,
msrscopevz = 24,
SilencerSmg = 25,
SilencerPistols = 26,
SilencerSnipers = 27,
ExtendedMags = 28,
rapidfire = 29,
grip = 30,
grip2 = 31,
m3202 = 32,
gp25 = 33,
shotgun = 34,
heartbeat = 35,
heartbeat2 = 36,
akimbo = 37,
tactical = 38,
rapidFire = 39,

};


enum Camos_e {

NoneCamo = 0,
Classic = 1, //(Woodland)
Snow = 2, //(Desert)
Multicam = 3, //(Winter)
Digital = 4, //(Digital)
Hex = 5, //(Urban)
Choco = 6,
Snake = 7, //(Blue Tiger)
Blue = 8, //(Autumn)
Red = 9,
Autumn = 10,
Gold = 11,
Marine = 12,
Winter = 13,

};


enum Reticles_e {

NoneReticle = 0,
TargetDost = 1,
Delta = 2,
UDot = 3,
MilDot = 4,
Omega = 5,
Lamda = 6,
};
};

void setupWeaponStrings(bool Weapons = true, bool Camos = true, bool Attachments = true, bool Reticles = true) { //Call once before using any function !

if (Weapons) {
WeaponsInfo::Weapon[0] = "defaultweapon_mp";
WeaponsInfo::Weapon[1] = "riotshield_mp";
WeaponsInfo::Weapon[2] = "iw5_44magnum_mp";
WeaponsInfo::Weapon[3] = "iw5_usp45_mp";
WeaponsInfo::Weapon[4] = "iw5_deserteagle_mp";
WeaponsInfo::Weapon[5] = "iw5_mp412_mp";
WeaponsInfo::Weapon[6] = "iw5_p99_mp";
WeaponsInfo::Weapon[7] = "iw5_fnfiveseven_mp";
WeaponsInfo::Weapon[8] = "iw5_fmg9_mp";
WeaponsInfo::Weapon[9] = "iw5_skorpion_mp";
WeaponsInfo::Weapon[10] = "iw5_mp9_mp";
WeaponsInfo::Weapon[11] = "iw5_g18_mp";
WeaponsInfo::Weapon[12] = "iw5_mp5_mp";
WeaponsInfo::Weapon[13] = "iw5_m9_mp";
WeaponsInfo::Weapon[14] = "iw5_p90_mp";
WeaponsInfo::Weapon[15] = "iw5_pp90m1_mp";
WeaponsInfo::Weapon[16] = "iw5_ump45_mp";
WeaponsInfo::Weapon[17] = "iw5_mp7_mp";
WeaponsInfo::Weapon[18] = "iw5_ak47_mp";
WeaponsInfo::Weapon[19] = "iw5_m16_mp";
WeaponsInfo::Weapon[20] = "iw5_m4_mp";
WeaponsInfo::Weapon[21] = "iw5_fad_mp";
WeaponsInfo::Weapon[22] = "iw5_acr_mp";
WeaponsInfo::Weapon[23] = "iw5_type95_mp";
WeaponsInfo::Weapon[24] = "iw5_mk14_mp";
WeaponsInfo::Weapon[25] = "iw5_scar_mp";
WeaponsInfo::Weapon[26] = "iw5_g36c_mp";
WeaponsInfo::Weapon[27] = "iw5_cm901_mp";
WeaponsInfo::Weapon[28] = "m320_mp";
WeaponsInfo::Weapon[29] = "rpg_mp";
WeaponsInfo::Weapon[30] = "iw5_smaw_mp";
WeaponsInfo::Weapon[31] = "stinger_mp";
WeaponsInfo::Weapon[32] = "javelin_mp";
WeaponsInfo::Weapon[33] = "xm25_mp";
WeaponsInfo::Weapon[34] = "iw5_dragunov_mp";
WeaponsInfo::Weapon[35] = "iw5_msr_mp";
WeaponsInfo::Weapon[36] = "iw5_barrett_mp";
WeaponsInfo::Weapon[37] = "iw5_rsass_mp";
WeaponsInfo::Weapon[38] = "iw5_as50_mp";
WeaponsInfo::Weapon[39] = "iw5_l96a1_mp";
WeaponsInfo::Weapon[40] = "iw5_ksg_mp";
WeaponsInfo::Weapon[41] = "iw5_1887_mp";
WeaponsInfo::Weapon[42] = "iw5_striker_mp";
WeaponsInfo::Weapon[43] = "iw5_aa12_mp";
WeaponsInfo::Weapon[44] = "iw5_usas12_mp";
WeaponsInfo::Weapon[45] = "iw5_spas12_mp";
WeaponsInfo::Weapon[46] = "iw5_m60_mp";
WeaponsInfo::Weapon[47] = "iw5_m60jugg_mp"; // augbar
WeaponsInfo::Weapon[48] = "iw5_mk46_mp";
WeaponsInfo::Weapon[49] = "iw5_pecheneg_mp";
WeaponsInfo::Weapon[50] = "iw5_sa80_mp";
WeaponsInfo::Weapon[51] = "iw5_mg36_mp";
WeaponsInfo::Weapon[52] = "iw5_usp45jugg_mp";
WeaponsInfo::Weapon[53] = "nuke_mp"; //iw5_mp412jugg_mp /// test !!!!!
WeaponsInfo::Weapon[54] = "uav_strike_marker_mp"; // P2000 // no bullet
WeaponsInfo::Weapon[55] = "gl_mp"; //supernoobtube
WeaponsInfo::Weapon[56] = "ac130_25mm_mp";
WeaponsInfo::Weapon[57] = "ac130_40mm_mp";
WeaponsInfo::Weapon[58] = "ac130_105mm_mp";
WeaponsInfo::Weapon[59] = "airdrop_tank_marker_mp";
WeaponsInfo::Weapon[60] = "briefcase_bomb_mp";
WeaponsInfo::Weapon[61] = "ims_projectile_mp";
WeaponsInfo::Weapon[62] = "killstreak_helicopter_minigun_mp"; //briefcase
WeaponsInfo::Weapon[63] = "mortar_remote_zoom_mp"; //Reaper interface
WeaponsInfo::Weapon[64] = "mortar_remote_mp"; //Reaper interface ++
WeaponsInfo::Weapon[65] = "killstreak_remote_mortar_mp";// reaper laptop
//WeaponsInfo::Weapon[66] = "remote_mortar_missile_mp"; // javelin won't lock on
}
if (Attachments) {

WeaponsInfo::Attachment[0] = "";
WeaponsInfo::Attachment[1] = "_reflex";
WeaponsInfo::Attachment[2] = "_reflexsmg";
WeaponsInfo::Attachment[3] = "_reflexlmg";
WeaponsInfo::Attachment[4] = "_eotech"; //HolographicSight
WeaponsInfo::Attachment[5] = "_eotechsmg";
WeaponsInfo::Attachment[6] = "_eotechlmg";
WeaponsInfo::Attachment[7] = "_acog";
WeaponsInfo::Attachment[8] = "_acogsmg";
WeaponsInfo::Attachment[9] = "_hybrid";
WeaponsInfo::Attachment[10] = "_hamrhybrid";
WeaponsInfo::Attachment[11] = "_thermal";
WeaponsInfo::Attachment[12] = "_thermalsmg";
WeaponsInfo::Attachment[13] = "_barrettscope";
WeaponsInfo::Attachment[14] = "_barrettscopevz"; //Variable zoom
WeaponsInfo::Attachment[15] = "_dragunovscope";
WeaponsInfo::Attachment[16] = "_dragunovscopevz";
WeaponsInfo::Attachment[17] = "_l96a1scope";
WeaponsInfo::Attachment[18] = "_l96a1scopevz";
WeaponsInfo::Attachment[19] = "_as50scope";
WeaponsInfo::Attachment[20] = "as50scopevz";
WeaponsInfo::Attachment[21] = "_rsassscope";
WeaponsInfo::Attachment[22] = "_rsassscopevz";
WeaponsInfo::Attachment[23] = "_msrscope";
WeaponsInfo::Attachment[24] = "_msrscopevz";
WeaponsInfo::Attachment[25] = "_silencer";
WeaponsInfo::Attachment[26] = "_silencer02"; //Pistols
WeaponsInfo::Attachment[27] = "_silencer03"; //Snipers
WeaponsInfo::Attachment[28] = "_xmags";
WeaponsInfo::Attachment[29] = "_rapidfire";
WeaponsInfo::Attachment[30] = "_grip";
WeaponsInfo::Attachment[31] = "_grip2";
WeaponsInfo::Attachment[32] = "_m320";
WeaponsInfo::Attachment[33] = "_gp25";
WeaponsInfo::Attachment[34] = "_shotgun";
WeaponsInfo::Attachment[35] = "_heartbeat";
WeaponsInfo::Attachment[36] = "_heartbeat2";
WeaponsInfo::Attachment[37] = "_akimbo";
WeaponsInfo::Attachment[38] = "_tactical";
WeaponsInfo::Attachment[39] = "_rof"; //rapid fire
}
if (Camos) {

WeaponsInfo::Camo[0] = "";
WeaponsInfo::Camo[1] = "_camo01";
WeaponsInfo::Camo[2] = "_camo02";
WeaponsInfo::Camo[3] = "_camo03";
WeaponsInfo::Camo[4] = "_camo04";
WeaponsInfo::Camo[5] = "_camo05";
WeaponsInfo::Camo[6] = "_camo06";
WeaponsInfo::Camo[7] = "_camo07";
WeaponsInfo::Camo[8] = "_camo08";
WeaponsInfo::Camo[9] = "_camo09";
WeaponsInfo::Camo[10] = "_camo010";
WeaponsInfo::Camo[11] = "_camo011";
WeaponsInfo::Camo[12] = "_camo012";
WeaponsInfo::Camo[13] = "_camo013";
}
if (Reticles) {

WeaponsInfo::Reticle[0] = "";
WeaponsInfo::Reticle[1] = "_scope1";
WeaponsInfo::Reticle[2] = "_scope2";
WeaponsInfo::Reticle[3] = "_scope3";
WeaponsInfo::Reticle[4] = "_scope4";
WeaponsInfo::Reticle[5] = "_scope5";
WeaponsInfo::Reticle[6] = "_scope6";

}
}

};
int GivePlayerCustomWeapon(int clientIndex, Weapons::WeaponsInfo::Weapons_e WeaponName, Weapons::WeaponsInfo::Attachments_e A, Weapons::WeaponsInfo::Attachments_e A2, Weapons::WeaponsInfo::Attachments_e A3, Weapons::WeaponsInfo::Camos_e Camo, Weapons::WeaponsInfo::Reticles_e Reticle, bool RemoveOld = true, bool Akimbo = false) {

char buffer[100];
Com_sprintf(buffer, sizeof(buffer), "%s%s%s%s%s%s", Weapons::WeaponsInfo::Weapon[WeaponName], Weapons::WeaponsInfo::Attachment[A], Weapons::WeaponsInfo::Attachment[A2], Weapons::WeaponsInfo::Attachment[A3], Weapons::WeaponsInfo::Camo[Camo], Weapons::WeaponsInfo::Reticle[Reticle]);
iPrintln(clientIndex, buffer);
return Weapons::GivePlayerWeapon(clientIndex, buffer, RemoveOld, Akimbo);
}


Have fun!!
Last edited by mrdarkblue ; 11-16-2017 at 11:57 PM.

The following 2 users say thank you to mrdarkblue for this useful post:

kiwi_modz, lucasaf01

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo