How to make it where you can drop weapon

broken avatar :(
Created 1170 days ago
by Fire Level One
0 Members and 1 Guest are viewing this topic.
4,151 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 October 2015
Last active: 156 days ago
Posts
46
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Groups
More
My Contact & Social Links
More
×
Fire Level One's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Fire Level One's Contact & Social LinksFireLevelOneFireLevelOnefirelevelone.com
Hey folks, how do you make it where when you hold down a certain button (on your keyboard not trigger_use) you'll drop your gun and it can be picked up by anyone?

Double Post Merge: July 07, 2016, 01:52:58 am
I did some research and I know the dvar for dropping your weapon is "dropweapon" now how do I bind that to a button?
Last Edit: July 07, 2016, 09:49:43 pm by Fire Level One
broken avatar :(
×
broken avatar :(
The OG Polish Modder
Location: pl
Date Registered: 19 June 2013
Last active: 250 days ago
Posts
1,666
Respect
Forum Rank
Zombie Destroyer
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
#RyukoRocks
Signature
[FS] Social Networking, Lead Animator and Scripter
[You are not allowed to view external links. Register or Login to see them]
[You are not allowed to view external links. Register or Login to see them]
×
Ray1235's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
dropweapon is not a dvar, it's a command, so nate's solution won't work.
Last Edit: July 07, 2016, 12:34:17 pm by Ray1235
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 296 days ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
you could do something like this that will use the actionslot 1 which is supposed to be the map button but zombiemode doesnt have a map so its free to use.

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == "+actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self dropPlayerWeapon(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
dropPlayerWeapon( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_" + weapon_name, self.origin + (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon ) + 1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}

put this in your mapname.gsc and this before zombiemode::main();

level thread onPlayerConnect();

although somewhere you might want to do a check that the player's weapon isnt a perk bottle or a grenade or something like that

Fixed my code. Should hopefully work now. I still cant test it though lol

isn't dropWeapon() an ai only function?


Edit: I added the entire funtion that im using for the weapon drop in my project, its an edited version of DUIPs tut
Last Edit: July 07, 2016, 02:20:30 pm by buttkicker845
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 296 days ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
Yeah you are right. Solid code there man. Do you have a list of engine notifies? I never heard of menuresponse, but I am still new to scripting. Also you sure spawn("weapon_"+weapon ............) will work? I have never seen that either.

thanks :)
its a response from menus that is used for key press, i originally got it from a tut that blunt made. also duip made a tut on the spawn weapon part.

 i'm also currently using both the menuresponse and the weapon spawn on a non-zombie project ive been working on so i know they both work.

the only thing im not positive is the "+actionslot 1" as the response name. thats what its listed as under in the options_pc_mis menu file so it should work

edit: actually looking at the tutorial again it opens a scriptmenu during the key bind so its possible this wont work with the map key. but he can fallow the original tut and make his own keybinding for it if he wants to do it this way.
Last Edit: July 07, 2016, 02:08:54 pm by buttkicker845
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 October 2015
Last active: 156 days ago
Posts
46
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Groups
More
My Contact & Social Links
More
×
Fire Level One's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Fire Level One's Contact & Social LinksFireLevelOneFireLevelOnefirelevelone.com
Completely untested because I am at work but paste this in the bottom of your mapname.gsc

drop_weapon_func()
{
players = getplayers();
for( i=0;i<players.size;i   )
{
players[i] setactionslot( 2, "weapon", "colt" ); // iirc this colt is different than the colt you spawn with
players[i] thread drop_weapon_notify();
players[i] thread drop_weapon_watch();
}
}

drop_weapon_notify()
{
self endon("disconnect");
while(1)
{
self.weapon_to_drop = getcurrentweapon();
wait(0.05);
self.check_if_colt = getcurrentweapon();
if( self.check_if_colt == "colt" && self.weapon_to_drop != self.check_if_colt )
self notify( "drop_the_weap" );
wait(0.05);
}
}

drop_weapon_watch()
{
self endon("disconnect");
while(1)
{
self waittill("drop_the_weap");
iprintlnbold("weapon should drop at this point unless I used dropweapon wrong");
self takeweapon("colt");
self switchtoweapon(self.weapon_to_drop);
self dropweapon( self.weapon_to_drop, "left", 0.9 );
}
}

and then under maps\_zombiemode::main(); add this:
thread drop_weapon_func();

This binds the drop weapon to action slot 2 if it works properly

I got an error (the pictures kinda hard to read, sorry.)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 296 days ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
its it should look like this in the drop_weapon_notify()

                self.weapon_to_drop = self getcurrentweapon(); 
wait(0.05);
self.check_if_colt = self getcurrentweapon();

but youre probably still going to run into the problem that dropweapon is for AI and not players
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 October 2015
Last active: 156 days ago
Posts
46
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Groups
More
My Contact & Social Links
More
×
Fire Level One's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Fire Level One's Contact & Social LinksFireLevelOneFireLevelOnefirelevelone.com
you could do something like this that will use the actionslot 1 which is supposed to be the map button but zombiemode doesnt have a map so its free to use.

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == " actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self dropPlayerWeapon(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
dropPlayerWeapon( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_"   weapon_name, self.origin   (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon )   1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}

put this in your mapname.gsc and this before zombiemode::main();

level thread onPlayerConnect();

although somewhere you might want to do a check that the player's weapon isnt a perk bottle or a grenade or something like that

isn't dropWeapon() an ai only function?


Edit: I added the entire funtion that im using for the weapon drop in my project, its an edited version of DUIPs tut
I got this error
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 296 days ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
huh, the odds of me naming a two different functions the same from two different scripts and like 6 months apart?  :troll:

anyways heres the fix

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == " actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self placeTheWeaponOnTheGround(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
placeTheWeaponOnTheGround( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_"   weapon_name, self.origin   (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon )   1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 10 days 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
huh, the odds of me naming a two different functions the same from two different scripts and like 6 months apart?  :troll:

anyways heres the fix

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == " actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self placeTheWeaponOnTheGround(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
placeTheWeaponOnTheGround( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_"   weapon_name, self.origin   (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon )   1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}

For some reason you're missing the "+" in important places.
i.e. "weapon_"   weapon_name , self.origin   (0,0,12) , WeaponMaxAmmo( weapon )   1 )
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 296 days ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
you could do something like this that will use the actionslot 1 which is supposed to be the map button but zombiemode doesnt have a map so its free to use.

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == "+actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self dropPlayerWeapon(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
dropPlayerWeapon( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_" + weapon_name, self.origin + (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon ) + 1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}

put this in your mapname.gsc and this before zombiemode::main();

level thread onPlayerConnect();
thats weird? its in the original post
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 October 2015
Last active: 156 days ago
Posts
46
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Groups
More
My Contact & Social Links
More
×
Fire Level One's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Fire Level One's Contact & Social LinksFireLevelOneFireLevelOnefirelevelone.com
huh, the odds of me naming a two different functions the same from two different scripts and like 6 months apart?  :troll:

anyways heres the fix

onPlayerConnect()
{
       level waittill("connecting",player);
       player thread onPlayerSpawn();
}

onPlayerSpawn()
{
       self endon("disconnect");
       while(1)
       {
                 self waittill("spawned");
                 self thread waitForWeaponDrop();
        }
}

waitForWeaponDrop()
{
         if(!isPlayer(self))
                 return;
           
         self endon("death");
         self endon("disconnect");

           while(1)
           {
                       self waittill("menuresponse", menu, response);
                       if(maps\_zombiemode_utility::is_valid_player(self) && response == " actionslot 1")
                       {
                                 primaries = self  getWeaponsListPrimaries();
                                 if(primaries.size > 1) //checks to make sure the player has more than one weapon
                                           self thread dropPlayerWeapon( self getCurrentWeapon());
                       }
            }
}
dropPlayerWeapon(weapon)
{
       if(!isPlayer(self))
                return;
       self endon("death");
       self endon("disconnect");
       
       self takeWeapon(weapon);
       self placeTheWeaponOnTheGround(weapon, self GetWeaponAmmoClip( weapon ) , self GetWeaponAmmoStock( weapon ));
}
placeTheWeaponOnTheGround( weapon_name , clipAmmo , stockAmmo)
{
weapon = weapon_name;
item = Spawn( "weapon_"   weapon_name, self.origin   (0,0,12) );
item SetModel( GetWeaponModel(weapon) );
if(!isDefined(clipAmmo))
clipAmmo = RandomInt( WeaponClipSize(weapon) );
if(!isDefined(stockAmmo))
stockAmmo = RandomIntRange( WeaponClipSize(weapon), WeaponMaxAmmo( weapon )   1 );
stockMax = WeaponMaxAmmo( weapon );
if ( stockAmmo > stockMax )
stockAmmo = stockMax;

item ItemWeaponSetAmmo( clipAmmo, stockAmmo );
}
bad syntax
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 10 days 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?
×
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
bad syntax
( [You are not allowed to view external links. Register or Login to see them] .)
as I said it's missing all the necessary  's

 

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 Twitch
Loading ...