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

Weapon Trader

HOT
broken avatar :(
Created 10 years ago
by MakeCents
0 Members and 1 Guest are viewing this topic.
11,746 views
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
Weapon Trader gives you the ability to trade weapons with the weapon on the table that you or another player has put there.

Weapon Trader

Here is a script with a prefab that only has a trigger and tag_origin, with the right kvps for the script, to get you started. You can place this prefab in your map as many times as you like, on a table or bench, or where ever.

Updates:
v1.1 changes getweaponlist() to GetWeaponsListPrimaries()
v1.2 isolated redundant statements to a TradeWeapons() function
     current weapon is grenade statement is not necessary, but left it in
     linked the trigger to its target (gun) for multiple placement
     added suport for two triggers per gun in case it falls upside down
     added player.revivetrigger condition recommended by DidUknowiPwn
v1.3 changed it so you can swap the same weapon now (swaps your ammo count)

Simply
Download MC_weapon_trader_v1.3.rar
Extract the files.
Put the _mc_weapon_trade.gsc in your root/mods/nazi_zombie_mapname/maps/ folder
Copy the _prefabs folder to your root/map_source/ folder
Insert the prefab in your map, on a table or something, as many times as you like.
Open your nazi_zombie_mapname.gsc and find the following:
Code Snippet
Plaintext
    maps\_zombiemode::main();
and put maps\_mc_weapon_trade::init(); under it like this:
Code Snippet
Plaintext
    maps\_zombiemode::main();
    maps\_mc_weapon_trade::init();
Compile your map and build your mod.


You can edit the starting weapon and cost to trade by editing the following in the init() function:

Code Snippet
Plaintext
        startingWeapon = "kar98k"; //change this to be the first weapon on trade table
cost = 0; //change this to cost something to trade, i.e. 250, 750


Ammo and clip size will be tracked as you trade.

Please let me know of any issues that you have, pertaining to this script and prefab that is.
Last Edit: October 13, 2014, 02:48:43 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: caOntario
Date Registered: 8 July 2014
Last active: 2 years ago
Posts
93
Respect
Forum Rank
Rotting Walker
Primary Group
Member
Signature
- Yonkers 1v
×
Yonkers 1v's Groups
Yonkers 1v's Contact & Social Links
looks great can't wait to add it to my map, but does  it work with ported weapons? all of my guns in my current map are ported weapons.  :-\

and does it work with muel kick?
Last Edit: September 28, 2014, 08:12:07 pm by Yonkers 1v
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
×
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
looks great can't wait to add it to my map, but does  it work with ported weapons? all of my guns in my current map are ported weapons.  :-\


I haven't tested it with them, but I don't see why not. Of course, I don't have any ported weapons so I can't test that for you. Be sure to let me know if it does or doesn't and I will try to figure out why.

I switched computers so I don't have anything on this new one yet, and I am now realizing how much work I have cut out for me again, lol. I think it should but there are many mule kick scripts out there. If something does't work right, just let me know and I will look at the scripts and adjust it so it works. It should work with mule kick though.

This script checks how many weapons you have, if you have the weapon that is on the table, how much ammo the weapon has you are trading, gets the model of the weapon you have, and if you have more than 1 gun it does one thing, and if you have only 1 gun it does something else. It is pretty much independent of any other scripts, as far as I can tell, and should work no matter what. It just swaps the weapon. Once thing it doesn't do is check if you have the same gun upgraded. So you could get one upgraded and one not upgraded, but I didn't see that as a game breaker. If someone else says it is then I will change it.



Edit: I just confirmed it does work with ported weapons and mule kick. 10-12-14
Last Edit: October 13, 2014, 02:48:11 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: usbuffalo
Date Registered: 16 August 2013
Last active: 11 months ago
Posts
927
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Giggity.
Signature
maps:
Undead Town
http://ugx-mods.com/forum/index.php?topic=2294.0 (Release)
Origins 1922
http://ugx-mods.com/forum/index.php?topic=2659.0
[WIP] mapping 39%, weapons 85%, scripts 65%
[/url]
×
RamboBadass's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
RamboBadass's Contact & Social LinksAsk merambobadassRamboDaGreat
that's a good damn idea man gg
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
×
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
that's a good damn idea man gg

Thanks man. The idea hit me today while working on another EE. I was wondering if it was done already?
broken avatar :(
×
broken avatar :(
Location: gbsomerset
Date Registered: 2 March 2014
Last active: 11 months ago
Posts
169
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Now you see me, Now you don`t
×
FATKIDSLOV3CAK3's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
FATKIDSLOV3CAK3's Contact & Social LinksHypercaineHypercaineZombies_dieFATKIDSLOV3CAK3
great idea man :) +1
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
×
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
great idea man :) +1

Thanks man. I was thinking it could be like a EE or buildable reward, or just a stock thing by the box.
broken avatar :(
×
broken avatar :(
Location: gbsomerset
Date Registered: 2 March 2014
Last active: 11 months ago
Posts
169
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Now you see me, Now you don`t
×
FATKIDSLOV3CAK3's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
FATKIDSLOV3CAK3's Contact & Social LinksHypercaineHypercaineZombies_dieFATKIDSLOV3CAK3
yh thats a good idea man :D
broken avatar :(
×
broken avatar :(
Location: usbuffalo
Date Registered: 16 August 2013
Last active: 11 months ago
Posts
927
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Giggity.
×
RamboBadass's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
RamboBadass's Contact & Social LinksAsk merambobadassRamboDaGreat
Thanks man. The idea hit me today while working on another EE. I was wondering if it was done already?
as far as I know I don't think so ...atleast not released
broken avatar :(
×
broken avatar :(
Location: usCalifornia
Date Registered: 28 July 2013
Last active: 3 years ago
Posts
702
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
Personal Quote
Pizza that is all.
Signature
There's no better feeling in the world than a warm pizza box on your lap.
×
SoulTaker's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
SoulTaker's Contact & Social Links
Wow nice man thanks for sharing these with the community !
:)
As for if it's been done already I don't know, but I think Phil had something like this done in one of his maps.
o.o
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 4 years ago
Posts
2,148
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Signature
Donate to me if you enjoy my work. https://www.paypal.me/thezombiekilla6
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social LinksMrZ0mbiesFanaticdust103194MrZ0mbiesFanatic
This is awesome! Will put it in my map and if I run into any problems I will be sure to let you know
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 21 March 2014
Last active: 2 years ago
Posts
227
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
My Contact & Social Links
More
Personal Quote
I the Mighty
×
ConvictioNDR's Groups
Thanks man. The idea hit me today while working on another EE. I was wondering if it was done already?
There is something like this by TheMightyDud or something like that. I don't really care to go looking for it though, I just remember helping him test it in coop before he released it. This was awhile back and I don't know that it checked to see if the player already had the gun.
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
Jesus what's with the repeated code?
i.e. takeweapon, giveweapon, ammo, etc.
You could have just made a bool check something like weapontraded = true and then passed weapontraded as a parameter to another function to set everything else or even just remove all duplicate code.

Edit: There's a lot of problems your code, wrong functions used for sound and players can glitch the amount of ammo you could get.
Last Edit: September 29, 2014, 04:39:14 am by DidUknowiPwn
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
×
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
Jesus what's with the repeated code?
i.e. takeweapon, giveweapon, ammo, etc.
You could have just made a bool check something like weapontraded = true and then passed weapontraded as a parameter to another function to set everything else or even just remove all duplicate code.

Edit: There's a lot of problems your code, wrong functions used for sound and players can glitch the amount of ammo you could get.

I appreciate you testing the code. If you could be more specific I could address it. I tested pretty extensively with 1 and 2 players and was not able to glitch the amount of ammo at all, how did you do it? I don't understand the wrong functions used for sound comment. This is what I always use for sound, what would you suggest?


I do see the redundancy in the if else statement and considered the option of taking that out to another function, but didn't at that time. The below two funcions can be used to replace the WeaponTrade() function to isolate the redundancy.
Code Snippet
Plaintext
WeaponTrade(startingWeapon){
self.Script_Noteworthy = startingWeapon;
weapon = undefined;
showGun = getent(self.target, "targetname");
while(1){
if(!(weapon == self.Script_Noteworthy)){
weapon = self.Script_Noteworthy;
showGun setmodel( GetWeaponModel(weapon, 0));
showGun.origin = showGun.origin + (0,0,10);
showGun PhysicsLaunch( showGun.origin, (0,0,0) );
wait(1);
}
self waittill("trigger", player);
if(player.score >= self.zombie_cost){
playerWeapon = player GetCurrentWeapon();
if(!( playerWeapon == "mk2_frag" || playerWeapon == "fraggrenade" || playerWeapon == "stielhandgranate" || playerWeapon == "molotov" || playerWeapon == "zombie_cymbal_monkey" )){
weapons = player GetWeaponsListPrimaries();
if(!(player HasWeapon( self.Script_Noteworthy ))){
if(!(self.zombie_cost == 0)){
player maps\_zombiemode_score::minus_to_player_score( self.zombie_cost );
player playsound( "cha_ching" );
}
if(weapons.size>1){
self TradeWeapons(playerWeapon, player);
}else{
if(!(self.Script_Noteworthy == startingWeapon)){
glitch = 0;
glitchWeaponAmmoClip = 0;
glitchWeaponAmmoStock = 0;
if(player HasWeapon( startingWeapon )){
glitch = 1;
glitchWeaponAmmoClip = player GetWeaponAmmoClip( startingWeapon );
            glitchWeaponAmmoStock = player GetWeaponAmmoStock( startingWeapon ); 
player TakeWeapon(startingWeapon);
}
player GiveWeapon(startingWeapon);
player SwitchToWeapon( startingWeapon);
self TradeWeapons(startingWeapon, player);
if(glitch){
player GiveWeapon(startingWeapon);
player SetWeaponAmmoClip(startingWeapon,glitchWeaponAmmoClip);
player SetWeaponAmmoStock(startingWeapon,glitchWeaponAmmoStock);
}
}else{
player GiveWeapon(startingWeapon);
player SwitchToWeapon( startingWeapon);
}
}
}else{
player iprintlnbold("You already have that weapon");
}
}
}else{
player playsound( "no_cha_ching" );
}
}
}
TradeWeapons(weapon, player){
weaponAmmoClip = player GetWeaponAmmoClip( weapon );
weaponAmmoStock = player GetWeaponAmmoStock( weapon );
player TakeWeapon( weapon );
player GiveWeapon(self.Script_Noteworthy);
player SwitchToWeapon( self.Script_Noteworthy);
player SetWeaponAmmoClip(self.Script_Noteworthy,self.weaponAmmoClip);
player SetWeaponAmmoStock(self.Script_Noteworthy,self.weaponAmmoStock);
self.Script_Noteworthy = weapon;
self.weaponAmmoClip = weaponAmmoClip;
self.weaponAmmoStock = weaponAmmoStock;
}
Last Edit: September 29, 2014, 04:15:36 pm by MakeCents
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?
×
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
Code Snippet
Plaintext
#include maps\_utility;
#include common_scripts\utility;
#include maps\_zombiemode_utility;
/*
#########################
by: M.A.K.E C E N T S
_mc_weapon_trade
modified by: DidUknowiPwn
#########################
*/
init()
{
set_dvar_int_if_unset("scr_zom_weapon_trade_cost", 0); //DUKIP - Default cost to 0, unless already defined by config, menu, etc.
set_dvar_if_unset("scr_zom_weapon_trade_start", "kar98k"); //DUKIP - Default wt (weapon trade) to kar98k, unless already defined by config, menu, etc.

wtStartingWeapon = GetDvar("scr_zom_weapon_trade_start");

cost = GetDvarInt("scr_zom_weapon_trade_cost");
trigs = GetEntArray("weapontrade", "targetname");

for( i = 0; i < trigs.size; i++ )
{
trigs[i] SetCursorHint("HINT_NOICON");
trigs[i] UseTriggerRequireLookAt();
trigs[i].zombie_cost = cost;

if(trigs[i].zombie_cost == 0)
trigs[i] SetHintString("Press &&1 to trade your weapon");
else
trigs[i] SetHintString("Press &&1 to trade your weapon [Cost: " + trigs[i].zombie_cost + "]");

trigs[i] thread WeaponTrade(wtStartingWeapon);
}
}

WeaponTrade(wtStartingWeapon)
{
wtWeapon = wtStartingWeapon;
wtModel = GetWeaponModel(wtWeapon);
self SetModel(wtModel);
wtAmmoClip = undefined;
wtAmmoStock = undefined;
wtTradeWeap = undefined;

while( true )
{
self.trigger waittill("trigger", player);

if( player.score >= self.trigger.zombie_cost && !IsDefined( player.revivetrigger ) )
{
weapon = player GetCurrentWeapon();
if( weaponClass( weapon ) != "grenade" && !IsSubStr( weapon, "m7_launcher" ) && weapon != "none" )
{
totalWeapons = player GetWeaponsListPrimaries();
if( !( player HasWeapon( wtWeapon ) ) )
{
if( self.trigger.zombie_cost > 0 )
{
player maps\_zombiemode_score::minus_to_player_score( self.trigger.zombie_cost );
player PlayLocalSound( "cha_ching" );
}

if( totalWeapons.size > 1 )
{
tradeWeapAmmoClip = player GetWeaponAmmoClip( weapon );
tradeWeapAmmoStock = player GetWeaponAmmoStock( weapon );
wtTradeWeap = weapon;
player TakeWeapon( weapon );
wtShouldChange = true;
}
else if( totalWeapons.size <= 1 )
{
tradeWeapAmmoClip = player GetWeaponAmmoClip( weapon );
tradeWeapAmmoStock = player GetWeaponAmmoStock( weapon );
wtShouldChange = false;
}
else
continue;

player GiveWeapon( wtWeapon );
player SwitchToWeapon( wtWeapon );
player SetWeaponAmmoClip(wtWeapon, wtAmmoClip);
player SetWeaponAmmoStock(wtWeapon, wtAmmoStock);
wtAmmoClip = tradeWeapAmmoClip;
wtAmmoStock = tradeWeapAmmoStock;
if( wtShouldChange )
{
wtWeapon = wtTradeWeap;
self SetModel( GetWeaponModel( wtWeapon ) );
self.origin += (0, 0, 10);
self PhysicsLaunch( self.origin, (0,0,0) );
wtShouldChange = undefined;
}

}
else
player IPrintLnBold("You already have that weapon!");
}
}
else
player PlayLocalSound( "no_cha_ching" );
wait 1;
}
}

//DUKIP - Copied from another WaW GSC.
set_dvar_int_if_unset(dvar, value)
{
if (GetDvar(dvar)=="")
{
SetDvar(dvar, value);
return int(value);
}

return GetDvarInt(dvar);
}

set_dvar_if_unset(dvar, value)
{
if (GetDvar(dvar)=="")
{
SetDvar(dvar, value);
return value;
}

return GetDvar(dvar);
}
This is my version of it, there's a random bug that happens where it'll not take your weapon and you'll have an empty hand and the model will keep calling physicslaunch. I just added check for weapon != "none" and haven't tested as I have to go to sleep. Give it a try, I also modified it for GSC calling (for testing) which is why you see self stuff for setmodel, you can remodify that if it doesn't work right (showGun). Probably should modify the cost/weapon start to a KVP thingy, no idea how to do that right now can't check either, night.
Last Edit: September 29, 2014, 05:46:42 am by DidUknowiPwn

 
Loading ...