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

Give weapon

broken avatar :(
Created 9 years ago
by GerardS0406
0 Members and 1 Guest are viewing this topic.
4,792 views
broken avatar :(
×
broken avatar :(
Location: usMissouri
Date Registered: 6 August 2013
Last active: 6 months ago
Posts
513
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
My Contact & Social Links
More
Signature
Projects:
Unnamed Project: 5%
Mutliple Downloadable Items for Mappers: (Released after map releases)
×
GerardS0406's Groups
GerardS0406's Contact & Social LinksGerardS0406Gerard0406GerardS0406MrGerard0406
Hey I was wondering how to make it so when you used a trigger, it would give you a certain weapon. Any help is appreciated.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: usNUKETOWN
Date Registered: 19 February 2014
Last active: 7 years ago
Posts
177
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Specialist
Signature
×
thezombieproject's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Oil Rig Beta Access
Oil Rig Beta Access
self waittill("trigger", player);      
self.current_weapon = player GetCurrentWeapon();
player takeweapon(self.current_weapon);
player giveweapon("zombie_thompson");
player SwitchToWeapon("zombie_thompson");
Last Edit: August 10, 2015, 05:47:31 am by thezombieproject
broken avatar :(
×
broken avatar :(
Location: usMissouri
Date Registered: 6 August 2013
Last active: 6 months ago
Posts
513
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
My Contact & Social Links
More
×
GerardS0406's Groups
GerardS0406's Contact & Social LinksGerardS0406Gerard0406GerardS0406MrGerard0406
self waittill("trigger", player);      
      self.current_weapon = player GetCurrentWeapon();
      player giveweapon("zombie_thompson");  // change to your weapon name
      player SwitchToWeapon("zombie_thompson");  // change to your weapon name
wouldn't you have to remove your current weapon before giving this weapon

Double Post Merge: August 10, 2015, 05:29:26 am
So this:
Code Snippet
Plaintext
old_gun = player getcurrentweapon();
trigger waittill("trigger", player);
player takeweapon( old_gun );
player giveweapon( "WEAPONNAME" );
player switchtoweapon( "WEAPONNAME" );
Last Edit: August 10, 2015, 05:30:00 am by GerardS0406
broken avatar :(
×
broken avatar :(
Location: usNUKETOWN
Date Registered: 19 February 2014
Last active: 7 years ago
Posts
177
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Specialist
×
thezombieproject's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Oil Rig Beta Access
Oil Rig Beta Access

So this:
Code Snippet
Plaintext
old_gun = player getcurrentweapon();
trigger waittill("trigger", player);
player takeweapon( old_gun );
player giveweapon( "WEAPONNAME" );
player switchtoweapon( "WEAPONNAME" );
[/quote]



yes that should work
Last Edit: August 10, 2015, 05:47:54 am by thezombieproject
Marked as best answer by GerardS0406 9 years ago
broken avatar :(
×
broken avatar :(
RadihaX
Location: caCanada
Date Registered: 2 September 2012
Last active: 3 years ago
Posts
978
Respect
Forum Rank
The Decider
Primary Group
Community Mapper Elite
My Groups
More
My Contact & Social Links
More
Signature
Overrun
Lockdown
Overrun (Black Ops Mod)
Snowglobe
Leviathan
Abandoned School
Ski Resort
Leviathan Redux
×
JBird632's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Community Mapper Elite Has shown excellence and experience in the area of custom mapping in the UGX-Mods community.
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
JBird632's Contact & Social LinksJBird632JBird632JBird632JBird632JBird632Mapper
Might want to add a check if they player only has one weapon (hence it wouldn't give them it as a second weapon). Also you shouldn't try getting the player's weapon before the trigger is triggered, since well... the player isn't defined yet.

Code Snippet
Plaintext
trigger waittill("trigger", player);

// Begin getting all the player's info after the trigger, since that is what defines the player
oldWeapon = player GetCurrentWeapon();
weapons = player GetWeaponsListPrimaries();

// Use a check to see if the game should take away the player's current weapon
// since the player shouldn't have their weapon removed if they only have one
if( weapons.size >= 2 )
player TakeWeapon( oldWeapon );

player GiveWeapon( "WEAPONNAME" );
player SwitchToWeapon( "WEAPONNAME" );
broken avatar :(
×
broken avatar :(
Location: usMissouri
Date Registered: 6 August 2013
Last active: 6 months ago
Posts
513
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
My Contact & Social Links
More
×
GerardS0406's Groups
GerardS0406's Contact & Social LinksGerardS0406Gerard0406GerardS0406MrGerard0406
Also you shouldn't try getting the player's weapon before the trigger is triggered, since well... the player isn't defined yet.
Yup learned that the hard way, anyways thanks
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
if your using my perks, giveweapon() will break mule kick

need to use the "harrybo21_give_gun( gunname )" from my utility script

it will "remove" the old gun automatically, and will do the "switchto" or you too
Last Edit: August 11, 2015, 11:44:07 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: usMissouri
Date Registered: 6 August 2013
Last active: 6 months ago
Posts
513
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
My Contact & Social Links
More
×
GerardS0406's Groups
GerardS0406's Contact & Social LinksGerardS0406Gerard0406GerardS0406MrGerard0406
k thanks, I was using on a test map and didn't try it on the one with perks. I'll use this on my main map.
broken avatar :(
×
broken avatar :(
Location: usNUKETOWN
Date Registered: 19 February 2014
Last active: 7 years ago
Posts
177
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Zombie Specialist
×
thezombieproject's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Oil Rig Beta Access
Oil Rig Beta Access
if your using my perks, giveweapon() will break mule kick

need to use the "harrybo21_give_gun( gunname )" from my utility script

it will "remove" the old gun automatically, and will do the "switchto" or you too

i know this is a old post but are you saying if some1 comes along and decides to use a tutorial  that has example: giveweapon(); in script.  then its going to break mule kick?
If i think alot of tuts have giveweapon() in there scripts.
im just wondering ?



 
Last Edit: August 26, 2015, 01:45:14 am by thezombieproject
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
i know this is a old post but are you saying if some1 comes along and decides to use a tutorial  that has example: giveweapon(); in script.  then its not going to break mule kick?
If i think alot of tuts have giveweapon() in there scripts.
im just wondering ?

Harry = iphone

Lol, I hope he wouldn't have done something like that.


I use this function instead of give weapon. If you want to give ammo instead when they have the gun that is.
Code Snippet
Plaintext
GiveWeaponOrAmmo(gun){//gave = player GiveWeaponOrAmmo(nameofguntogive);
currentGun = self GetCurrentWeapon();
if(!isDefined(gun) || !isDefined(currentGun) || gun == "none" || WeaponClass(gun) == "grenade" || currentGun == "none" || WeaponClass(currentGun) == "grenade" ) return "none";
if(self HasWeapon(gun)){
if(WeaponClass(gun) == "gas" || weaponStartAmmo(gun) <= self getWeaponAmmoStock(gun)) return "none";
self GiveStartAmmo(gun);
return "ammo";
}
weapons = self GetWeaponsListPrimaries();
maxguns = 2;
if(self HasPerk("specialty_extraammo")) maxguns = 3;
if(weapons.size >= maxguns) self TakeWeapon(currentGun);
self GiveWeapon(gun);
self SwitchToWeapon(gun);
self GiveStartAmmo(gun);
return "gun";
}

Edit: improved function, again, fixed typo

I added score checks to the function but can't test right now, but here it is:
Code Snippet
Plaintext
GiveWeaponOrAmmo(gun){//gave = player GiveWeaponOrAmmo(nameofguntogive);
currentGun = self GetCurrentWeapon();
if(!is_player_valid(self) || !isDefined(level.zombie_include_weapons[gun]) || !isDefined(gun) || !isDefined(currentGun) || gun == "none" || WeaponClass(gun) == "grenade" || currentGun == "none" || WeaponClass(currentGun) == "grenade" ) return "none";
if(self HasWeapon(gun) && self.score+5 >= level.zombie_include_weapons[gun].ammo_cost){
if(WeaponClass(gun) == "gas" || weaponStartAmmo(gun) <= self getWeaponAmmoStock(gun)) return "none";
self GiveStartAmmo(gun);
if(gun != currentGun) self SwitchToWeapon(gun);
self maps\_zombiemode_score::minus_to_player_score( level.zombie_include_weapons[gun].ammo_cost );
self playLocalSound("cha_ching");
return "ammo";
}else if(self.score+5 >= level.zombie_include_weapons[gun].cost){
weapons = self GetWeaponsListPrimaries();
maxguns = 2;
if(self HasPerk("specialty_extraammo")) maxguns = 3;
if(weapons.size >= maxguns) self TakeWeapon(currentGun);
self GiveWeapon(gun);
self SwitchToWeapon(gun);
self GiveStartAmmo(gun);
self maps\_zombiemode_score::minus_to_player_score( level.zombie_include_weapons[gun].cost );
self playLocalSound("cha_ching");
return "gun";
}
self playLocalSound("no_cha_ching");
return "none";
}

This is a living function in a helper function gsc that I improve upon as I develop new scripts, so if anyone sees something that I am missing or can be done better, please let me know. I did isolate redundancies and made it two functions, but the size of the two increased and neither function served its own purpose so I kept it one function.
Last Edit: August 25, 2015, 05:45:58 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
Yes, I have a custom give weapon function that does both giving the weapon and tracking the inventory

So using normal give weapon will break it

Just replace give weapon parts with my give weapon function

Like we already need to do with jeis mule kick

 
Loading ...