A new weapon (variant and skin)
A Marksman M4: an M4 that hits harder and spreads less, with a smaller clip, its own colour and an animated skin.
Admins give it with /marksman.
- Create
plugins/MarksmanM4.cswith a class of the same name. - In
OnLoaded, start from the game’s M4 (ItemDatabase.Find) and change its numbers inStats. - Give it a
Tint, so players tell it from a plain M4 at a glance. - Add the skin:
Texturefor the first person view,WorldTexturefor the model the others see. The example below uses the guide’s liquid metal frames; for your own picture, paint over the M4’s two textures from the skins folder and put their addresses instead. - Register an admin command that gives it.
using RustLegacy;
public class MarksmanM4 : RustPlugin{ public override string Description => "The Marksman M4: harder hits, tighter spread, an animated skin. Admins: /marksman";
public override void OnLoaded() { var m4 = ItemDatabase.Find( "M4" ); var dir = "https://raw.githubusercontent.com/rustlegacyio/rustlegacy-plugins/main/skins/examples/liquid_metal/"; var frames = ""; foreach ( var n in new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2 } ) frames += dir + "0" + n + ".jpg ";
var marksman = new PluginItem { Id = "marksmanm4_rifle", Base = "M4", Title = "Marksman M4", Description = "Hits harder, spreads less, holds 20.", Tint = "#c8ccd4", Texture = frames, WorldTexture = frames, TextureFps = 6, }; marksman.Stats["Damage"] = m4.Damage * 1.2f; marksman.Stats["DamageMin"] = m4.DamageMin * 1.2f; marksman.Stats["Spread"] = m4.Spread * 0.6f; marksman.Stats["ClipSize"] = 20; DefineItem( marksman );
AddCommand( "marksman", OnMarksman, "Give yourself or a player a Marksman M4", true, "[player]" ); }
void OnMarksman( ChatCommand cmd ) { var target = cmd.Args.Length > 0 ? FindPlayer( cmd.Args[0] ) : cmd.Player; if ( target == null ) { Reply( cmd.Player, "No such player." ); return; } Give( target, "Marksman M4" ); Reply( cmd.Player, $"Marksman M4 given to {target.DisplayName}." ); }}The item keeps everything else of the M4: its ammo, its sounds, its crafting. If the plugin is removed, the rifles in the world turn back into plain M4s, and come back when it returns.