Weapons & Perks - 505e06b2/MW2-GSC-Documentation GitHub Wiki

Useful links:


buildWeaponName( <weapon_base_name>, <attachment_1>, <attachment_2> )

Return the weapon with attachments as a string ending in _mp

invalid_attachments = buildWeaponName("scar", "reflex", "eotech"); //will be invalid since they use the same slot - no attachments will be added when given
one_attachments = buildWeaponName("m4", "reflex", "none"); //will only have red-dot
two_attachments = buildWeaponName("famas", "reflex", "gl"); //red-dot and grenade launcher
no_attachments = "fn2000_mp"; //just put _mp after the base name to get the full name
player giveWeapon(two_attachments); //given the famas + red-dot + grenade launcher

Include: maps\mp\gametypes\_class


player givePerk( <perk_or_equipment_name> )

Give the player the specified perk or equipment - giving certain equipment after spawning may not always work

//self givePerk("specialty_fastreload"); //including the related file may cause namespace conflicts - in the original source, the methods below seem preferred
self maps\mp\perks\_perks::givePerk("throwingknife_mp"); //throwing knife
self maps\mp\perks\_perks::givePerk("specialty_fastreload"); //sleight of hand

Include: maps\mp\perks\_perks


player giveWeapon( <weapon_name>, [camo_index], [akimbo] )

Add the specified weapon to the player's inventory

player giveWeapon("deserteaglegold_mp");
player giveWeapon("scar_reflex_mp", 3); //scar-h with red-dot and arctic camo
player giveWeapon("m4_mp", int(tableLookup("mp/camoTable.csv", 1, "red_tiger", 0)) ); //m4a1 with red tiger
player giveWeapon("m79_mp", 0, true); //thumper akimbo

player takeWeapon( <weapon_name> )

Take the specified weapon from the player's inventory

player takeWeapon("deserteaglegold_mp");

player takeAllWeapons( )

Take all weapons from the player (leaving them with nothing in their hands)

player takeAllWeapons();

player switchToWeapon( <weapon_name> )

Force a weapon from the player's inventory into their hands

player switchToWeapon("deserteaglegold_mp");

player getCurrentWeapon( );

Return the currently held weapon as a string

weapon_name = player getCurrentWeapon();

player getWeaponsListPrimaries( );

Return the current, non-temporary (killstreak), weapons as an array

weapons_in_inventory = player getWeaponsListPrimaries();

player giveMaxAmmo( <weapon_name> )

Give the player the max ammo stock for the specified weapon

player giveMaxAmmo("deserteaglegold_mp");

player giveStartAmmo( <weapon_name> )

Give the player the default ammo stock for the specified weapon

player giveStartAmmo("deserteaglegold_mp");

player getWeaponAmmoClip( <weapon_name> )

Return the remaining clip in the specified weapon as an integer

shots_before_reload = player getWeaponAmmoClip("deserteaglegold_mp");

player setWeaponAmmoClip( <weapon_name>, <clip_size> )

Set the current clip size for the weapon

player setWeaponAmmoClip("deserteaglegold_mp", 1);

player setWeaponAmmoStock( <weapon_name>, <stock_ammount> )

Set the current ammo stock size for the weapon

player setWeaponAmmoStock("deserteaglegold_mp", 9999);

player getWeaponAmmoStock( <weapon_name> )

Return the remaining ammo for the specified weapon as an integer

ammo_left = player getWeaponAmmoStock("deserteaglegold_mp");

player getWeaponAmmoStock( <weapon_name> )

Return the remaining ammo for the specified weapon as an integer

ammo_left = player getWeaponAmmoStock("deserteaglegold_mp");
⚠️ **GitHub.com Fallback** ⚠️