So, was in chat earlier today when @Ray1235 was asking about dropped a weapon by script. I had realized that moment we've been spawning weapons through script incorrectly this entire time (I'm pretty sure we all knew this). Anyway after about 30 minutes I got this solution:
// ========================================================== // Coding Projects // // Component: WaW // Purpose: Code for dropping a weapon through script // PROPERLY!!! // // Initial author: DidUknowiPwn // Started: 2014-12-13 // © 2014 DidUknowiPwn™ // ========================================================== #include common_scriptsutility; #include maps\_utility; #include maps\_zombiemode_utility; #include maps\_loadout; init() { level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connecting", player); player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon("disconnct"); for(;;) { self waittill("spawned_player"); wait 2; self thread DropLeWeapon("zombie_kar98k"); } } DropLeWeapon( weapon_name ) { weapon = weapon_name; item = Spawn( "weapon_" + weapon_name, self.origin + (0,0,12) ); item SetModel( GetWeaponModel(weapon) ); clipAmmo = RandomInt( WeaponClipSize(weapon) ); stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon ) + 1 ); stockMax = WeaponMaxAmmo( weapon ); if ( stockAmmo > stockMax ) stockAmmo = stockMax; item ItemWeaponSetAmmo( clipAmmo, stockAmmo ); item itemRemoveAmmoFromAltModes(); } itemRemoveAmmoFromAltModes() { origweapname = self getItemWeaponName(); curweapname = weaponAltWeaponName( origweapname ); altindex = 1; while ( curweapname != "none" && curweapname != origweapname ) { self itemWeaponSetAmmo( 0, 0, altindex ); curweapname = weaponAltWeaponName( curweapname ); altindex++; } } getItemWeaponName() { classname = self.classname; assert( getsubstr( classname, 0, 7 ) == "weapon_" ); weapname = getsubstr( classname, 7 ); return weapname; }
Video:
http://www.youtube.com/watch?v=L6zE6LG42C0#ws