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 storage locker (carries on between games) v1.2

HOT
broken avatar :(
Created 9 years ago
by death_reaper0
0 Members and 1 Guest are viewing this topic.
21,189 views
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
respect the dead

donates greatly appreciated :) paypal.me/F3ARxReaper666
discord server:
https://discord.gg/tsGHW99
×
death_reaper0'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.
this is my script for a weapon locker like in black ops 2 TranZit, die rise and buried. if you don't know what that is, then basically its a place to store a weapon and keep it between games!. it will keep track of your stored weapons ammo in reserve and in clip and can be modified to not accept certain weapons.

v1.2 update
players can now take the weapon if they have a free weapon slot, without it placing your current weapon in


https://www.youtube.com/watch?v=F_1gGypc5CQ

part 1

first you will need to get this prefab and place it in your map. if you do not wish to do this move to step 1b, if you do want to, skip part 1b.

the prefab can be found here
https://mega.co.nz/#!PFZQXBaA!XyiHpYPvG4_-6mwye7vupBU5E1P80H1FKwRG_Rta7ls
or here
http://www.mediafire.com/download/05bmhh8ub2361zw/F3ARxReaper666%27s_bank_system.zip

part 1b

use this if you do not want to use my prefab

make a trigger use by right clicking in radiant on the 2d view, then go to trigger then trigger use. place it where you want and while its selected press N to bring up the KVPs
in the top text box at the bottom insert

Code Snippet
Plaintext
targetname

and in the bottom place

Code Snippet
Plaintext
weapon_locker

press enter and it should appear with the other KVPs

this is where you need to go to use the locker

part 2

now you will need to go to waw root/raw/maps and find your MAPNAME.gsc and open it up

under

Code Snippet
Plaintext
	level thread DLC3_threadCalls2();

place

Code Snippet
Plaintext
	thread weapon_locker_begin();

now at the very bottom of that file place:

Code Snippet
Plaintext
weapon_locker_begin()
{
players = getplayers();
for(i=0; i<players.size; i++)
{
players[i] thread get_stored_gun();
}
self thread weapon_locker();
}

get_stored_gun()
{
wait 1;
self.stored_gun_ammo = self GetStat(3007);
self.stored_ammo_clip = self GetStat(3008);
self.has_stored_weapon = self GetStat(3009);
keys = GetArrayKeys( level.zombie_weapons );
self.stored_weapon = keys[ self GetStat( 3006 ) ];
}

weapon_locker()
{
wait 2;
weapon_locker = getEnt("weapon_locker", "targetname");
    weapon_locker setHintString( "press & hold &&1 to store current weapon" );
weapon_locker setCursorHint("HINT_NOICON");
while(1)
{
weapon_locker waittill( "trigger", user );
    if( is_player_valid(user))
{
user.old_gun = user getcurrentweapon();
user.gun_ammo = user GetAmmoCount( user.old_gun );
user.gun_ammo_clip = user GetWeaponAmmoClip(user.old_gun);

// this line is for non valid weapons, such as perk bottles, knuckle crack and the syringe when reviving, this should only need to be changed if adding extra perks etc.
if (!( user.old_gun == "none" || user.old_gun == "syrette" || user.old_gun == "zombie_melee" || user.old_gun == "zombie_perk_bottle_revive" || user.old_gun == "zombie_perk_bottle_doubletap" || user.old_gun == "zombie_perk_bottle_jugg" || user.old_gun == "zombie_perk_bottle_sleight" || user.old_gun == "zombie_perk_bottle_staminup" || user.old_gun == "zombie_perk_bottle_phd" || user.old_gun == "zombie_perk_bottle_mulekick" || user.old_gun == "zombie_perk_bottle_deadshot" || user.old_gun == "zombie_perk_bottle_cherry" || user.old_gun == "zombie_perk_bottle_vulture" || user.old_gun == "zombie_knuckle_crack" || user.old_gun == "stielhandgranate" || user.old_gun == "zombie_cymbal_monkey" || user.old_gun == "zombie_bowie_flourish" ))
{
primaryWeapons = user GetWeaponsListPrimaries();
if( (IsDefined( primaryWeapons ) && primaryWeapons.size == 1 ||  IsDefined( primaryWeapons ) && primaryWeapons.size == 2 && user hasPerk ("specialty_extraammo")) && user.has_stored_weapon == 1)
{
user giveweapon( user.stored_weapon );
user SetWeaponAmmoStock(user.stored_weapon,user.stored_gun_ammo);
user SetWeaponAmmoClip(user.stored_weapon,user.stored_ammo_clip);
user switchtoweapon( user.stored_weapon );
user.has_stored_weapon = 0;
user SetStat(3009,0);
}
else
// the following line is for weapons that you do not want storeable, i added some from my own map and advise customizing for weapons in your own map. zombie colt should be changed to your starting weapon
if ( user.old_gun == "colt" || user.old_gun == "zombie_colt" || user.old_gun == "zombie_colt_upgraded" || user.old_gun == "tesla_gun" || user.old_gun == "tesla_gun_upgraded" || user.old_gun == "thundergun" || user.old_gun == "thundergun_upgraded" || user.old_gun == "ray_gun" || user.old_gun == "ray_gun_upgraded" || user.old_gun == "scavenger" || user.old_gun == "scavenger_upgraded" || user.old_gun == "vorkuta_knife" || user.old_gun == "vorkuta_knife_upgraded" )
{
user iPrintLnBold("^7cannot store this weapon");
wait 2;
}
else
{
primaryWeapons = user GetWeaponsListPrimaries();
if(!( IsDefined( primaryWeapons ) && primaryWeapons.size == 1 ||  IsDefined( primaryWeapons ) && primaryWeapons.size == 2 && user hasPerk ("specialty_extraammo") ))
user takeweapon( user.old_gun );

    if(user.has_stored_weapon == 1)
{
user giveweapon( user.stored_weapon );
user SetWeaponAmmoStock(user.stored_weapon,user.stored_gun_ammo);
user SetWeaponAmmoClip(user.stored_weapon,user.stored_ammo_clip);
user switchtoweapon( user.stored_weapon );
}
user.switch_weapon = user.stored_weapon;
wait 0.1;
user.stored_weapon = user.old_gun;
user.stored_ammo_clip = user.gun_ammo_clip;
user.stored_gun_ammo = user.gun_ammo - user.stored_ammo_clip;
wait 0.1;

keys = GetArrayKeys( level.zombie_weapons );
for( i = 0; i < keys.size; i ++ )
{
if( keys[i] == user.stored_weapon )
{
user SetStat( 3006, i );
break;
}
}
user SetStat(3007,user.stored_gun_ammo);
user SetStat(3008,user.stored_ammo_clip);
user.has_stored_weapon = 1;
user SetStat(3009,1);

  user playlocalsound("cha_ching");
user.cur_gun = user getcurrentweapon();
primaryWeapons = user GetWeaponsListPrimaries();
if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 && (!(user.cur_gun == user.switch_weapon)))
{
user SwitchToWeapon( primaryWeapons[0] );
}
wait 2;
}
}
}
}
}

thanks to alaurenc9 and Ray1235 for their help!

that should be it, have fun with your new script (please credit if used)
Last Edit: December 15, 2015, 08:39:45 am by death_reaper0
broken avatar :(
×
broken avatar :(
Location: it
Date Registered: 27 February 2015
Last active: 3 years ago
Posts
14
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
a231's Groups
a231's Contact & Social Links
Getting bad syntax errors...


Error: bad syntax: (file 'maps/nazi_zombies_1337.gsc', line 129)
{

broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
death_reaper0'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.
oops, my bad. i fixed it now

move:

Code Snippet
Plaintext
weapon_locker_begin()
{
level.firstlockeruse = true;
stored_weapon = undefined;
gun_ammo = undefined;
user = undefined;
stored_gun_ammo = undefined;
stored_ammo_clip = undefined;

while(1)
{

weapon_locker = getEnt("weapon_locker", "targetname");

    weapon_locker setHintString( "press & hold &&1 to store current weapon" );

weapon_locker setCursorHint("HINT_NOICON");

weapon_locker waittill( "trigger", user );
        if( is_player_valid(user))
{

old_gun = user getcurrentweapon();

gun_ammo = user GetAmmoCount( old_gun );

gun_ammo_clip = user GetWeaponAmmoClip(old_gun);

// the following line is for weapons that you do not want storeable, i added some from my own map and advise customizing for weapons in your own map. zombie colt should be changed to your starting weapon
if ( old_gun == stored_weapon || old_gun == "colt" || old_gun == "zombie_colt" || old_gun == "zombie_colt_upgraded" || old_gun == "tesla_gun" || old_gun == "tesla_gun_upgraded" || old_gun == "thundergun" || old_gun == "thundergun_upgraded" || old_gun == "ray_gun" || old_gun == "ray_gun_upgraded" || old_gun == "scavenger" || old_gun == "scavenger_upgraded" || old_gun == "vorkuta_knife" || old_gun == "vorkuta_knife_upgraded" )
{
user iPrintLnBold("^7cannot store this weapon");
wait 2;
}
// this line is for non valid weapons, such as perk bottles, knuckle crack and the syringe when reviving, this should only need to be changed if adding extra perks etc.
else if ( old_gun == "none" || old_gun == "syrette" || old_gun == "zombie_melee" || old_gun == "zombie_perk_bottle_revive" || old_gun == "zombie_perk_bottle_doubletap" || old_gun == "zombie_perk_bottle_jugg" || old_gun == "zombie_perk_bottle_sleight" || old_gun == "zombie_perk_bottle_staminup" || old_gun == "zombie_perk_bottle_phd" || old_gun == "zombie_perk_bottle_mulekick" || old_gun == "zombie_perk_bottle_deadshot" || old_gun == "zombie_perk_bottle_cherry" || old_gun == "zombie_perk_bottle_vulture" || old_gun == "zombie_knuckle_crack" || old_gun == "stielhandgranate" || old_gun == "zombie_cymbal_monkey" || old_gun == "zombie_bowie_flourish" )
{
user iPrintLnBold("^7you are not holding a weapon");
wait 2;
}
else
{

user takeweapon( old_gun );

user giveweapon( stored_weapon );
user SetWeaponAmmoStock(stored_weapon,stored_gun_ammo);
user SetWeaponAmmoClip(stored_weapon,stored_ammo_clip);
user switchtoweapon( stored_weapon );

wait 0.1;

stored_weapon = old_gun;

stored_ammo_clip = gun_ammo_clip;

stored_gun_ammo = gun_ammo - stored_ammo_clip;

  user playlocalsound("cha_ching");

//iprintln( stored_weapon ); //used to see console name of weapon that gets deposited, uncomment if needed

if (level.firstlockeruse == true) // used to switch weapons after the first use when receiving nothing from the locker
{
primaryWeapons = user GetWeaponsListPrimaries();
if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
{
user SwitchToWeapon( primaryWeapons[0] );
}
level.firstlockeruse = false;
}
wait 2;
}
}
}
}

to the very bottom of the script
Last Edit: December 10, 2015, 04:01:58 am by death_reaper0
broken avatar :(
×
broken avatar :(
Location: usMichigan
Date Registered: 22 July 2013
Last active: 5 years ago
Posts
74
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Utamia's Groups
Utamia's Contact & Social LinksUtamiaUtamiaAdvisorbuggy
Does it save over games?
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
Does it save over games?
i cant see anything that would make it do that
broken avatar :(
×
broken avatar :(
Location: ptLisboa
Date Registered: 21 June 2014
Last active: 3 years ago
Posts
311
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Keep Scrolling...
Signature
I Am New Into Mapping And All Of That Kind Of Stuff.I Appreciate Every Help Provided!
×
LegendHugo's Groups
LegendHugo's Contact & Social LinksHdinis09Hdinis09@hdinis09DonHugo
Amazing stuff man. Will most likely use it in my map :D
Last Edit: December 10, 2015, 08:56:12 pm by LegendHugo
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
i cant see anything that would make it do that
Proper way of doing that would be via stats ::)
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
death_reaper0'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.
i cant see anything that would make it do that
is there a way to make that happen? if so that would be amazing
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
is there a way to make that happen? if so that would be amazing
need to use tables or something, i dunno

lilfria might, he did the persistent perks in BO1, i imagine its the same precidence
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
is there a way to make that happen? if so that would be amazing
First off, you'd need to get an array of weapons and a free or unsused stat slot.
In this example, I'll use 3005.
(for those who don't know, stats store an int which can persist on a player profile permamently in a mod unless the player removes mod's respective mpdata000 file)
level.zombie_weapons is the array which keeps all the weapons.
So, here, I'm going to find the weapon that player wants to put in (player being the player entity):
Code Snippet
Plaintext
weapon = player getcurrentweapon();
for (i = 0; i < level.zombie_weapons.size; i++)
{
    if(level.zombie_weapons[i].weapon_name == weapon)
        player SetStat(3005,i);
}
This will set the weapon's index to 3005 slot.
Now, you probably are wondering, how do you know what is the weapon that the player has put in? Well, there's GetStat
Code Snippet
Plaintext
id = player GetStat(3005);
weapon = level.zombie_weapons[id].weapon_name;
And that's how you can use stats for the weapon cabinet :)
Forgive me if I wasn't clear enough, I'm really tired today but I hope it helped you.
You can use 3006 and 3007 for storing weapon ammo info.
Also, I would recommend using 3008 for storing info if there is a weapon in the cabinet :)
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
First off, you'd need to get an array of weapons and a free or unsused stat slot.
In this example, I'll use 3005.
(for those who don't know, stats store an int which can persist on a player profile permamently in a mod unless the player removes mod's respective mpdata000 file)
level.zombie_weapons is the array which keeps all the weapons.
So, here, I'm going to find the weapon that player wants to put in (player being the player entity):
Code Snippet
Plaintext
weapon = player getcurrentweapon();
for (i = 0; i < level.zombie_weapons.size; i++)
{
    if(level.zombie_weapons[i].weapon_name == weapon)
        player SetStat(3005,i);
}
This will set the weapon's index to 3005 slot.
Now, you probably are wondering, how do you know what is the weapon that the player has put in? Well, there's GetStat
Code Snippet
Plaintext
id = player GetStat(3005);
weapon = level.zombie_weapons[id].weapon_name;
And that's how you can use stats for the weapon cabinet :)
Forgive me if I wasn't clear enough, I'm really tired today but I hope it helped you.
You can use 3006 and 3007 for storing weapon ammo info.
Also, I would recommend using 3008 for storing info if there is a weapon in the cabinet :)
plenty clear, sounds very useful. Surprised it isnt used more
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
death_reaper0'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.
First off, you'd need to get an array of weapons and a free or unsused stat slot.
In this example, I'll use 3005.
(for those who don't know, stats store an int which can persist on a player profile permamently in a mod unless the player removes mod's respective mpdata000 file)
level.zombie_weapons is the array which keeps all the weapons.
So, here, I'm going to find the weapon that player wants to put in (player being the player entity):
Code Snippet
Plaintext
weapon = player getcurrentweapon();
for (i = 0; i < level.zombie_weapons.size; i++)
{
    if(level.zombie_weapons[i].weapon_name == weapon)
        player SetStat(3005,i);
}
This will set the weapon's index to 3005 slot.
Now, you probably are wondering, how do you know what is the weapon that the player has put in? Well, there's GetStat
Code Snippet
Plaintext
id = player GetStat(3005);
weapon = level.zombie_weapons[id].weapon_name;
And that's how you can use stats for the weapon cabinet :)
Forgive me if I wasn't clear enough, I'm really tired today but I hope it helped you.
You can use 3006 and 3007 for storing weapon ammo info.
Also, I would recommend using 3008 for storing info if there is a weapon in the cabinet :)
well i dont understand 100% but i'll test out this later on and see if i can get this working. but i wanna know, would this carry it on between maps? cause if so i'd probably wouldn't use this since most maps would have different guns. it could work for a bo2 style bank though
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
well i dont understand 100% but i'll test out this later on and see if i can get this working. but i wanna know, would this carry it on between maps? cause if so i'd probably wouldn't use this since most maps would have different guns. it could work for a bo2 style bank though
It will be only within the same mod.
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
death_reaper0'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.
It will be only within the same mod.
that's awesome! i'll try it out later when i'm less tired, thank you a lot!

EDIT: one more thing, what is the default of the stat?
Last Edit: December 10, 2015, 10:44:26 pm by death_reaper0
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
that's awesome! i'll try it out later when i'm less tired, thank you a lot!

EDIT: one more thing, what is the default of the stat?
Default is always 0

 
Loading ...