Skip to content
M2O Scripting APIScripting reference
GuideMaintainer authored

Weapons

Weapons in the scripting API are identified by their numeric weapons.tbl row ID. Use the table below when granting a weapon, changing ammunition, equipping a weapon, or checking which weapon a player currently holds.

Weapon inventory changes are authoritative server operations. The server sends the requested change to the owning client, while normal M2O player synchronization makes the equipped weapon visible to other players.

Call Player.giveWeapon(weaponId, ammo, equip) from a server resource:

Events.on("playerConnect", (player) => {
const weaponId = 10; // MP40
const reserveAmmo = 120;
player.giveWeapon(weaponId, reserveAmmo, true);
});

The first argument is an ID from this page, the second is the initial reserve ammunition, and the final boolean controls whether the granted weapon is equipped immediately. An ammunition value of zero or less uses the default load of 100 rounds. Unknown weapon IDs are ignored.

Use player.giveAmmo(weaponId, amount) to adjust reserve ammunition later, or player.removeWeapon(weaponId) to remove the weapon from the player’s inventory.

Some IDs represent incomplete or unsafe game content. Pay attention to the notes beside grenades, the MG42, and the missing sniper model before exposing them in a game mode.

#02Sidearm
Model 12 Revolver

Model 12 Revolver

#03Sidearm
Mauser C96

Mauser C96

#04Sidearm
Colt M1911A1

Colt M1911A1

#05Sidearm
Colt M1911 Special

Colt M1911 Special

#06Sidearm
Model 19 Revolver

Model 19 Revolver

#07Inactive
Grenade Sicily

Grenade Sicily

Does not explode.

#08Shotgun
Remington Model 870 Field Gun

Remington 870 Field Gun

#09SMG
M3 Grease Gun

M3 Grease Gun

#10SMG
MP40

MP40

#11SMG
Thompson 1928

Thompson 1928

#12SMG
M1A1 Thompson

M1A1 Thompson

#13SMG
Beretta Model 38A

Beretta Model 38A

#14Unsafe
MG42

MG42

Animation is buggy; do not use.

#15Rifle
M1 Garand

M1 Garand

#16Inactive
Stielhandgranate 24

Stielhandgranate 24

Does not explode.

#17Rifle
Kar98k

Kar98k

#18Missing
No model preview

Mauser 98k Sniper

The game model is missing.

#20Throwable
Mk II Grenade

Mk II Grenade

#21Throwable
Molotov Cocktail

Molotov Cocktail