UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[Tutorial] Spawn a Weapon by GSC (Like in Radiant)

broken avatar :(
Created 9 years ago
by DidUknowiPwn
0 Members and 1 Guest are viewing this topic.
3,483 views
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 6 months ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
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:

Code Snippet
Plaintext
// ==========================================================
// 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

 
Loading ...