UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: death_reaper0 on September 13, 2015, 03:57:38 am

Title: weapon storage locker (carries on between games) v1.2
Post by: death_reaper0 on September 13, 2015, 03:57:38 am
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.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2Fzvsrra.jpg&hash=9b58aca91baa46b7af255b82d29b4b2fa324bb78)
https://www.youtube.com/watch?v=F_1gGypc5CQ (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 (https://mega.co.nz/#!PFZQXBaA!XyiHpYPvG4_-6mwye7vupBU5E1P80H1FKwRG_Rta7ls)
or here
http://www.mediafire.com/download/05bmhh8ub2361zw/F3ARxReaper666%27s_bank_system.zip (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)
Title: Re: weapon storage locker (like bo2)
Post by: a231 on December 07, 2015, 12:45:55 pm
Getting bad syntax errors...


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

Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 10, 2015, 03:58:38 am
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
Title: Re: weapon storage locker (like bo2)
Post by: Utamia on December 10, 2015, 06:56:32 pm
Does it save over games?
Title: Re: weapon storage locker (like bo2)
Post by: Harry Bo21 on December 10, 2015, 07:59:59 pm
Does it save over games?
i cant see anything that would make it do that
Title: Re: weapon storage locker (like bo2)
Post by: LegendHugo on December 10, 2015, 08:55:02 pm
Amazing stuff man. Will most likely use it in my map :D
Title: Re: weapon storage locker (like bo2)
Post by: DeletedUser on December 10, 2015, 08:56:31 pm
i cant see anything that would make it do that
Proper way of doing that would be via stats ::)
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 10, 2015, 08:57:11 pm
i cant see anything that would make it do that
is there a way to make that happen? if so that would be amazing
Title: Re: weapon storage locker (like bo2)
Post by: Harry Bo21 on December 10, 2015, 09:01:39 pm
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
Title: Re: weapon storage locker (like bo2)
Post by: DeletedUser on December 10, 2015, 09:07:52 pm
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 :)
Title: Re: weapon storage locker (like bo2)
Post by: Harry Bo21 on December 10, 2015, 09:33:41 pm
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
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 10, 2015, 10:33:56 pm
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
Title: Re: weapon storage locker (like bo2)
Post by: DeletedUser on December 10, 2015, 10:34:57 pm
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.
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 10, 2015, 10:38:27 pm
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?
Title: Re: weapon storage locker (like bo2)
Post by: DeletedUser on December 11, 2015, 06:37:36 am
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
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 11, 2015, 06:42:06 am
Default is always 0
i managed to get a bank working with this, weapon locker though is still nonworking. i'll keep trying though
Title: Re: weapon storage locker (like bo2)
Post by: alaurenc9 on December 12, 2015, 02:10:57 pm
i managed to get a bank working with this, weapon locker though is still nonworking. i'll keep trying though

this might be because you followed what Ray1235 told you to do, which was use level.zombie_weapons. level.zombie_weapons is not an array of integers, remember the array keys are all of the weapon names. That means if u use an integer to get something in that array like he told you to do, it will come up undefined. My best recommendation would be to list out all the weapons in an array of integers separately and use that. But if you want something easier,  this *MIGHT work.

Code Snippet
Plaintext
weapon = player GetCurrentWeapon();
keys = GetArrayKeys( level.zombie_weapons );
for( i = 0; i < keys.size; i ++ )
{
if( keys[i] == weapon )
{
player SetStat( 3005, i );
break;
}
}

Code Snippet
Plaintext
keys = GetArrayKeys( level.zombie_weapons );
weapon = keys[ player GetStat( 3005 ) ];
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 12, 2015, 06:45:04 pm
this might be because you followed what Ray1235 told you to do, which was use level.zombie_weapons. level.zombie_weapons is not an array of integers, remember the array keys are all of the weapon names. That means if u use an integer to get something in that array like he told you to do, it will come up undefined. My best recommendation would be to list out all the weapons in an array of integers separately and use that. But if you want something easier,  this *MIGHT work.

Code Snippet
Plaintext
weapon = player GetCurrentWeapon();
keys = GetArrayKeys( level.zombie_weapons );
for( i = 0; i < keys.size; i ++ )
{
if( keys[i] == weapon )
{
player SetStat( 3005, i );
break;
}
}

Code Snippet
Plaintext
keys = GetArrayKeys( level.zombie_weapons );
weapon = keys[ player GetStat( 3005 ) ];
i'll try it out soon, thank you
Title: Re: weapon storage locker (like bo2)
Post by: DeletedUser on December 12, 2015, 06:47:25 pm
level.zombie_weapons is an array of structs, so you can't just compare
Code Snippet
Plaintext
level.zombie_weapons[i]
with a weapon name :P
You have to do
Code Snippet
Plaintext
level.zombie_weapons[i].weapon_name == <weapon name>
Title: Re: weapon storage locker (like bo2)
Post by: Harry Bo21 on December 12, 2015, 06:59:21 pm
level.zombie_weapons is an array of structs, so you can't just compare
Code Snippet
Plaintext
level.zombie_weapons[i]
with a weapon name :P
You have to do
Code Snippet
Plaintext
level.zombie_weapons[i].weapon_name == <weapon name>
its stored by string, and the string is the weapon name

level.zombie_weapons[weapon_name] = struct;

so using getKeys would have returned the weapon names

Code Snippet
Plaintext
keys = GetArrayKeys( level.zombie_weapons );
keys[i] == weapon

code is valid ;)


i can think of loads of cool stuff you could do with this setStat business lol
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 12, 2015, 07:14:06 pm
i got it to work using alaurenc9's method, im just gonna do a few tests, then i'll update the script
Title: Re: weapon storage locker (like bo2)
Post by: alaurenc9 on December 12, 2015, 07:18:53 pm
i got it to work using alaurenc9's method, im just gonna do a few tests, then i'll update the script


Nice ;) the only thing I was worried about with that method was if GetArrayKeys would return the weapons in the same order every time. I'm pretty sure it does though so no worries there. I think it orders the keys from like last defined to first defined, meaning it isn't random, so yes the system I posted should work 100%, and I'm glad as you say, it did.

A question for Ray1235, how would I find unused stat slots? 3005, 3006, 3007, and 3008 are unused? And until I make any edits to these, they will return 0?
Title: Re: weapon storage locker (like bo2)
Post by: Soy-Yo on December 12, 2015, 07:20:11 pm
I think if we start making things with setStat, we all should save the number of the stat in a global variable, like:
Code Snippet
Plaintext
level.stats[ "weapon_storage_locker" ] = 3005;
So we can easily change them to avoid overwriting other things. Because if I wanted to add this and the bank to my map, I would have to find every line where setStat or getStat is written to change the number, but maybe someone with no idea in scripting wouldn't know that.
Just my opinion.
Title: Re: weapon storage locker (like bo2)
Post by: alaurenc9 on December 12, 2015, 07:23:19 pm
I think if we start making things with setStat, we all should save the number of the stat in a global variable, like:
Code Snippet
Plaintext
level.stats[ "weapon_storage_locker" ] = 3005;
So we can easily change them to avoid overwriting other things. Because if I wanted to add this and the bank to my map, I would have to find every line where setStat or getStat is written to change the number, but maybe someone with no idea in scripting wouldn't know that.
Just my opinion.

Well, for now, atleast death_reaper0 could you just change the bank one to use a different stat slot? So people would not get confused?
Title: Re: weapon storage locker (like bo2)
Post by: death_reaper0 on December 12, 2015, 07:26:21 pm
I think if we start making things with setStat, we all should save the number of the stat in a global variable, like:
Code Snippet
Plaintext
level.stats[ "weapon_storage_locker" ] = 3005;
So we can easily change them to avoid overwriting other things. Because if I wanted to add this and the bank to my map, I would have to find every line where setStat or getStat is written to change the number, but maybe someone with no idea in scripting wouldn't know that.
Just my opinion.
dont worry, the bank uses 3005 and this uses 3006-3009. it should only need to be changed if your using one of those for something else

anyway, its been updated, thank you everyone who helped!
Title: Re: weapon storage locker (like bo2)
Post by: Soy-Yo on December 12, 2015, 07:33:01 pm
dont worry, the bank uses 3005 and this uses 3006-3009. it should only need to be changed if your using one of those for something else
Oh. Ok. Thought you were using 3005 for both. And yeah, for now there's no problem, but maybe more people start using this method and it would be nice to have everything organized at the top of the script so we'll know in one second which stats are in use.
As I said, it's just my opinion, you don't have to do it if you don't want.
Title: Re: weapon storage locker (carries on between games) v1.1
Post by: alaurenc9 on December 12, 2015, 08:07:30 pm
I'm confused....

You defined literally every variable on the user. Only the stored information needs to be defined on the user. Everything else are just temporary variables that do not need to be this way. Here is how I would put the script together.

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

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

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( true )
{
weapon_locker waittill( "trigger", user );
if( is_player_valid( user ) )
{
weapon = user GetCurrentWeapon();
gun_ammo_clip = user GetWeaponAmmoClip( weapon );
gun_ammo_stock = user GetWeaponAmmoStock( weapon );
if( weapon == "colt" || weapon == "zombie_colt" || weapon == "zombie_colt_upgraded" || weapon == "tesla_gun" || weapon == "tesla_gun_upgraded" || weapon == "thundergun" || weapon == "thundergun_upgraded" || weapon == "ray_gun" || weapon == "ray_gun_upgraded" || weapon == "scavenger" || weapon == "scavenger_upgraded" || weapon == "vorkuta_knife" || weapon == "vorkuta_knife_upgraded" )
{
user IPrintLnBold( "^7You Cannot Store This Weapon" );
wait 2;
}
else if( weapon == "none" || weapon == "syrette" || weapon == "zombie_melee" || weapon == "zombie_perk_bottle_revive" || weapon == "zombie_perk_bottle_doubletap" || weapon == "zombie_perk_bottle_jugg" || weapon == "zombie_perk_bottle_sleight" || weapon == "zombie_perk_bottle_staminup" || weapon == "zombie_perk_bottle_phd" || weapon == "zombie_perk_bottle_mulekick" || weapon == "zombie_perk_bottle_deadshot" || weapon == "zombie_perk_bottle_cherry" || weapon == "zombie_perk_bottle_vulture" || weapon == "zombie_knuckle_crack" || weapon == "stielhandgranate" || weapon == "zombie_cymbal_monkey" || weapon == "zombie_bowie_flourish" )
{
user IPrintLnBold( "^7You Are Not Holding a Weapon" );
wait 2;
}
else
{
PrimaryWeapons = user GetWeaponsListPrimaries();
weapon_limit = 2;
if( user HasPerk( "specialty_extraammo" ) )
{
weapon_limit = 3;
}
if( IsDefined( PrimaryWeapons ) && PrimaryWeapons.size < weapon_limit && user.has_stored_weapon == 1 )
{
user GiveWeapon( user.stored_weapon );
user SetWeaponAmmoClip( user.stored_weapon, user.stored_ammo_clip );
user SetWeaponAmmoStock( user.stored_weapon, user.stored_ammo_stock );
user SwitchToWeapon( user.stored_weapon );
user.stored_weapon = "";
user.stored_ammo_clip = 0;
user.stored_ammo_stock = 0;
user.has_stored_weapon = 0;
}
else
{
user TakeWeapon( weapon );
    if( user.has_stored_weapon == 1 )
{
user GiveWeapon( user.stored_weapon );
user SetWeaponAmmoClip( user.stored_weapon, user.stored_ammo_clip );
user SetWeaponAmmoStock( user.stored_weapon, user.stored_ammo_stock );
user SwitchToWeapon( user.stored_weapon );
}
else if( IsDefined( PrimaryWeapons ) && PrimaryWeapons.size > 0 )
{
user SwitchToWeapon( PrimaryWeapons[0] );
}
user.stored_weapon = weapon;
user.stored_ammo_clip = gun_ammo_clip;
user.stored_ammo_stock = gun_ammo_stock;
user.has_stored_weapon = 1;
}
index = 0;
keys = GetArrayKeys( level.zombie_weapons );
for( i = 0; i < keys.size; i ++ )
{
if( keys[i] == user.stored_weapon )
{
index = i;
break;
}
}
user SetStat( 3006, index );
user SetStat( 3007, user.stored_ammo_clip );
user SetStat( 3008, user.stored_ammo_stock );
user SetStat( 3009, user.has_stored_weapon );
user PlayLocalSound( "cha_ching" );
wait 2;
}
}
}
}

I also made it where if you are under the weapon limit, and you have a stored weapon, you can simply take it out without trading your current weapon and have no stored weapon in the locker. Otherwise it will store your current weapon, and if you had a stored weapon, it will give you it. Of course if you feel that it is now more of my script than your script, you don't have to use it. But I don't mind you taking this script and calling it yours and using it etc. as long as credit is given.
Title: Re: weapon storage locker (carries on between games) v1.1
Post by: death_reaper0 on December 12, 2015, 08:18:15 pm
I'm confused....

You defined literally every variable on the user. Only the stored information needs to be defined on the user. Everything else are just temporary variables that do not need to be this way. Here is how I would put the script together.

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

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

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( true )
{
weapon_locker waittill( "trigger", user );
if( is_player_valid( user ) )
{
weapon = user GetCurrentWeapon();
gun_ammo_clip = user GetWeaponAmmoClip( weapon );
gun_ammo_stock = user GetWeaponAmmoStock( weapon );
if( weapon == "colt" || weapon == "zombie_colt" || weapon == "zombie_colt_upgraded" || weapon == "tesla_gun" || weapon == "tesla_gun_upgraded" || weapon == "thundergun" || weapon == "thundergun_upgraded" || weapon == "ray_gun" || weapon == "ray_gun_upgraded" || weapon == "scavenger" || weapon == "scavenger_upgraded" || weapon == "vorkuta_knife" || weapon == "vorkuta_knife_upgraded" )
{
user IPrintLnBold( "^7You Cannot Store This Weapon" );
wait 2;
}
else if( weapon == "none" || weapon == "syrette" || weapon == "zombie_melee" || weapon == "zombie_perk_bottle_revive" || weapon == "zombie_perk_bottle_doubletap" || weapon == "zombie_perk_bottle_jugg" || weapon == "zombie_perk_bottle_sleight" || weapon == "zombie_perk_bottle_staminup" || weapon == "zombie_perk_bottle_phd" || weapon == "zombie_perk_bottle_mulekick" || weapon == "zombie_perk_bottle_deadshot" || weapon == "zombie_perk_bottle_cherry" || weapon == "zombie_perk_bottle_vulture" || weapon == "zombie_knuckle_crack" || weapon == "stielhandgranate" || weapon == "zombie_cymbal_monkey" || weapon == "zombie_bowie_flourish" )
{
user IPrintLnBold( "^7You Are Not Holding a Weapon" );
wait 2;
}
else
{
PrimaryWeapons = user GetWeaponsListPrimaries();
weapon_limit = 2;
if( user HasPerk( "specialty_extraammo" ) )
{
weapon_limit = 3;
}
if( IsDefined( PrimaryWeapons ) && PrimaryWeapons.size < weapon_limit && user.has_stored_weapon == 1 )
{
user GiveWeapon( user.stored_weapon );
user SetWeaponAmmoClip( user.stored_weapon, user.stored_ammo_clip );
user SetWeaponAmmoStock( user.stored_weapon, user.stored_ammo_stock );
user SwitchToWeapon( user.stored_weapon );
user.stored_weapon = "";
user.stored_ammo_clip = 0;
user.stored_ammo_stock = 0;
user.has_stored_weapon = 0;
}
else
{
user TakeWeapon( weapon );
    if( user.has_stored_weapon == 1 )
{
user GiveWeapon( user.stored_weapon );
user SetWeaponAmmoClip( user.stored_weapon, user.stored_ammo_clip );
user SetWeaponAmmoStock( user.stored_weapon, user.stored_ammo_stock );
user SwitchToWeapon( user.stored_weapon );
}
else if( IsDefined( PrimaryWeapons ) && PrimaryWeapons.size > 0 )
{
user SwitchToWeapon( PrimaryWeapons[0] );
}
user.stored_weapon = weapon;
user.stored_ammo_clip = gun_ammo_clip;
user.stored_ammo_stock = gun_ammo_stock;
user.has_stored_weapon = 1;
}
index = 0;
keys = GetArrayKeys( level.zombie_weapons );
for( i = 0; i < keys.size; i ++ )
{
if( keys[i] == user.stored_weapon )
{
index = i;
break;
}
}
user SetStat( 3006, index );
user SetStat( 3007, user.stored_ammo_clip );
user SetStat( 3008, user.stored_ammo_stock );
user SetStat( 3009, user.has_stored_weapon );
user PlayLocalSound( "cha_ching" );
wait 2;
}
}
}
}

I also made it where if you are under the weapon limit, and you have a stored weapon, you can simply take it out without trading your current weapon and have no stored weapon in the locker. Otherwise it will store your current weapon, and if you had a stored weapon, it will give you it. Of course if you feel that it is now more of my script than your script, you don't have to use it. But I don't mind you taking this script and calling it yours and using it etc. as long as credit is given.

i used varriables cause i was just adapting my original script, its also a little chuncky, i'll probably make a better one later, and i didnt make it ake the weapon if you have a free slot since the bo2 one didnt (at least i dont think it did)
Title: Re: weapon storage locker (carries on between games) v1.1
Post by: alaurenc9 on December 12, 2015, 08:22:41 pm
i used varriables cause i was just adapting my original script, its also a little chuncky, i'll probably make a better one later, and i didnt make it ake the weapon if you have a free slot since the bo2 one didnt (at least i dont think it did)


According to the bo2 script, yes you can take the weapon if you have a free slot and it clears the weapon locker data. So my script is accurate completely to bo2. Anyways let me know if you are going to use my script. If you aren't could you at least do me a favor and test it for me? Because if you don't use it, I want to release it in my own post, and I'll credit you for original script. Would you mind if I did that?
Title: Re: weapon storage locker (carries on between games) v1.1
Post by: death_reaper0 on December 12, 2015, 08:26:44 pm
According to the bo2 script, yes you can take the weapon if you have a free slot and it clears the weapon locker data. So my script is accurate completely to bo2. Anyways let me know if you are going to use my script. If you aren't could you at least do me a favor and test it for me? Because if you don't use it, I want to release it in my own post, and I'll credit you for original script. Would you mind if I did that?
i just looked it up yeah it does use free slots like you said. i'll probably make an update later, im kinda a little busy to test right now so maybe in a few hours from now, i'll pm if it works, or what didnt work
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: RichGaming on April 03, 2016, 02:48:32 pm
Dont know if anyone has pointed this out but if you buy a wall weapon, store it in the fridge then try and rebuy the same wall weapon it will charge you for the weapon but not give it to you. Same happens if you try to take the weapon out of the box.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: death_reaper0 on April 08, 2016, 04:43:09 pm
its been pointed out to me that this is not compatible with Harry Bo21's perks, so dont use this if you are or plan to use those until i can get it fixed
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 06, 2016, 01:25:00 pm
I'm not claiming to know the solution, merely asking a question and making a suggestion given the context.

 is it possible harry's perks are using a stat slot some where in the same range you are eg 3005?

 If so maybe adapt numbers to follow after his?

Maybe it's something else you have an idea on?

I'd be willing to test in any case as my map is currently only using ugx script placer/ugx modtools patch and harry's bo1 perks and wunderfizz( havent updated to widows wine version yet although I hear it has who's who now, not that it's ever been useful to me lolz, but for continuity sake)

Would like to see this working properly as it is a great function that would go great with a multi map style mod (eg. Transit's Bus stop/town/farm inspired mod like Dawnville)
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 06, 2016, 01:32:19 pm
I already know what the issue is and it's nothing to do with set stat

I wrote a "give" weapon function to work with my inventory but not a "take" weapon

So when you put your gun in this fridge, player.inventory array still "thinks" you have that gun
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 09, 2016, 01:04:17 pm
Is it possible to add the take weapon function to your scripts from my end?
With your permission of course.
Or might that break some other function?
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: RichGaming on May 09, 2016, 02:25:13 pm
Is it possible to add the give weapon function to your scripts from my end?
With your permission of course.
Or might that break some other function?

Just accept that this doesn't work with Harry's perks. Give Fear and Harry some time to come up with a solution and in the mean time don't include it in your map. Simples.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 09, 2016, 02:37:20 pm
Just accept that this doesn't work with Harry's perks. Give Fear and Harry some time to come up with a solution and in the mean time don't include it in your map. Simples.

Can we at least give the man a chance to answer please?
I don't feel that I'm out of line in requesting this with respect to his work.
Also I'm not trying to rush him just merely offering my assistance in testing and brain storming.
Trying to be progressive and active in the community sir.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 09, 2016, 03:03:23 pm
All you need to do is set that array index back to "none"

Prob loop through the array to get the right index
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 09, 2016, 04:15:36 pm
Would you be willing to assist me on this in a pm when you get a chance sir?
I'm in no particular rush as I lead a busy life as well with a home studio,full time job and committed relationship.
But I usually have a few hours every morning to put in on my map, taking my time and paying attention to detail on it.

I still have to repurchase bo1&2 on pc (own on console but just recently built new rig capable of modern gaming) so I can port the guns I want in.

Plus I'm producing some custom sounds for ambient,ee song, ee confirm sound as well as building some textures from scratch using source photo's of my own. All of which I intend to release when the map does, as well as any non basic prefabs I have made.

Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 09, 2016, 05:16:41 pm
Code Snippet
Plaintext
take_gun( name )
{
    if ( isDefined( self.inventory ) && self.inventory.size > 0 )
    {
        for ( i = 0; i < self.inventory.size; i++ )
        {
            if ( self.inventory[ i ] == name )
            {
                self.inventory[ i ] = "none";
                break;
            }
        }
    }
    self takeWeapon( name );
}

player take_gun( "weapon_name" );

Wrote that on my phone so forgive any syntax errors
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 10, 2016, 11:58:49 am
Haven't tested above script yet but I'm not having the specific wall weapon error mentioned above.

Using ugx mod tools patch v1.0.6
Harrys perks v2.0.4
And reapers current script on front page.

No other edits that would affect inventory

Perks version I have had the array index already set to "none"

I did get a few other inventory oddities.

Noticed

somewhere it's not checking for full weapon inventory gave 3 weapon glitch at some point buying wall weap with same weap in fridge and two gun in inventory

Also doesn't check for same weapon in inventory.  When pulling g43 out of fridge and one in inventory it took my pistol and left me with one g43
upon hitting fridge again, got pistol back no issue, g43 in fridge still had g43  in inventory.

Another thing is hintstring stays the same whether you're trading or just putting one in but I also haven't got around to adding trems hintstring fix either, will follow up on that once it's implemented and tested.

I am aware though that these are old perk scripts so I will back up map at this point
add update, sort through 50+ pages for error fixing and also add trems hintstring fix.
Then I will test above changes thoroughly and report my finding

Should be able to sort syntax errors to as long as I make sure to get updated perks working first sonI know errors aren't coming from different places.

Thanks for taking the time harry as I read you've moved on from modding cod5.
Still trying to catch up but I appreciate your patience and assistance very much sir.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 10, 2016, 12:23:33 pm
Haven't tested above script yet but I'm not having the specific wall weapon error mentioned above.

Using ugx mod tools patch v1.0.6
Harrys perks v2.0.4
And reapers current script on front page.

No other edits that would affect inventory

Perks version I have had the array index already set to "none"

I did get a few other inventory oddities.

Noticed

somewhere it's not checking for full weapon inventory gave 3 weapon glitch at some point buying wall weap with same weap in fridge and two gun in inventory

Also doesn't check for same weapon in inventory.  When pulling g43 out of fridge and one in inventory it took my pistol and left me with one g43
upon hitting fridge again, got pistol back no issue, g43 in fridge still had g43  in inventory.

Another thing is hintstring stays the same whether you're trading or just putting one in but I also haven't got around to adding trems hintstring fix either, will follow up on that once it's implemented and tested.

I am aware though that these are old perk scripts so I will back up map at this point
add update, sort through 50+ pages for error fixing and also add trems hintstring fix.
Then I will test above changes thoroughly and report my finding

Should be able to sort syntax errors to as long as I make sure to get updated perks working first sonI know errors aren't coming from different places.

Thanks for taking the time harry as I read you've moved on from modding cod5.
Still trying to catch up but I appreciate your patience and assistance very much sir.
sigh...

This will mean you haven't changed the normal give weapon function to mine either

I don't get what's so complicated about this...

The game by default only let's you hold two and "does not" track the order

I had to make a custom function to imitate this behaviour which means you have to edit any scripts you get off this site

Seriously - where is the complication


I'm going to reiterate this one more time

Any - ANY reference to give or take weapon functions needs to be REPLACED with mine or my system will have no idea what you do or don't have. I made it as simple as swapping

Giveweapon

To.

Harrybo21_give_gun

Or something like that - it's in harrybo21_utilities

Seriously that's all it needs - and in this case you need a take gun function coz this script also TAKES your weapons

I gave Instructions on how to change the wall buys and mystery box in the video on page one of said 50 page post....
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: alaurenc9 on May 10, 2016, 10:05:27 pm
Another thing is hintstring stays the same whether you're trading or just putting one in but I also haven't got around to adding trems hintstring fix either, will follow up on that once it's implemented and tested.
What is trem's hintstring fix got to do with anything?

Changing the hintstring depending on the trading or placing or whatever the hell else it says can only be accomplished by BO2's trigger-per-player system, where it spawns multiple triggers and makes them only visible to their specific players, that way different people can see different hinstrings.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 11, 2016, 05:15:42 am
Merely missed that fact harry as I haven't updated to 4.0.2 perks yet.
Hadn't had any troubles yet so it hadn't come up yet, pehaps because the perks were the only thing I had added.
sometime ago as well so I may have just forgot that fact
Just stating observations and what scripts I have.
Not so much asking for help fixing the things I mentioned, considering I haven't updated perks yet, just stating that I wasn't able to recreate the issue with not receiving wall weapon.


About hintstrings,
Again stating observations and that I didn't have trems hintsring update fix so I wasn't sure if that was why or not. Hadn't tested multiplayer yet either.
I wasn't aware that was the way it worked alaurenc9 thank you for letting me know.

Might also mention again that I map in what little free time I have, I understand you guy's get alot of issues brought to you by people who need help with every little thing, I'm sorry if I seem like I should know these things but I don't have as much time invested in the forums as most so it's possible that I'll make mistakes but please forgive me, I'd like to be able to bring something to the table and not just be helpless.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 11, 2016, 08:55:34 am
change the code in mapname.gsc to this instead :

Code Snippet
Plaintext
weapon_locker_begin()
{
level.harry_perks_fix = true;

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 )
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_give_gun( user.old_gun );
else
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" ) ))
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_take_gun( user.old_gun );
else
user takeWeapon( user.old_gun );

}

if(user.has_stored_weapon == 1)
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_give_gun( user.old_gun );
else
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;
}
}
}
}
}

harrybo21_take_gun( name )
{
if ( isDefined( self.grenade ) && self.grenade == name )
self.grenade = undefined;
else if ( isDefined( self.alt_grenade ) && self.alt_grenade == name )
self.alt_grenade = undefined;
    else if ( isDefined( self.inventory ) && self.inventory.size > 0 )
    {
        for ( i = 0; i < self.inventory.size; i++ )
        {
            if ( self.inventory[ i ] == name )
            {
                self.inventory[ i ] = "none";
                break;
            }
        }
    }
    self takeWeapon( name );
}

harrybo21_give_gun( gun, model_index )
{
primaryWeapons = self GetWeaponsListPrimaries();
currentWeapon = self getCurrentWeapon();
for ( i = 0; i < primaryWeapons.size; i++ )
if ( primaryWeapons[ i ] == gun + "_upgraded" )
gun = gun + "_upgraded";

if ( !self harrybo21_has_weapon( gun ) )
{
if ( gun == "zombie_cymbal_monkey" )
{
self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
self harrybo21_set_alt_grenade( gun, 3 );
}
else if ( gun == "stielhandgranate" )
self harrybo21_set_grenade( gun, 4 );
else if ( gun == "molotov" || gun == "molotov_zombie"  )
self harrybo21_set_alt_grenade( gun, 4 );
else
self harrybo21_set_weapon( gun, model_index );

}
else
{
if ( weaponClass( gun ) == "grenade" )
self giveMaxAmmo( gun );
else
self giveMaxAmmo( gun );
}
self notify( "weapon_obtained" );
}

harrybo21_get_weapon_index( gun )
{
for ( i = 0; i < self.inventory.size; i++ )
{
if ( self.inventory[ i ] == gun )
{
return i;
}
}
return undefined;
}

harrybo21_set_weapon( gun, model_index )
{
if ( !isDefined( model_index ) )
model_index = 0;

slot = self harrybo21_get_weapon_index( "none" );
if ( !isDefined( slot ) )
slot = self harrybo21_get_weapon_index( self getCurrentWeapon() );

if ( self.inventory[ slot ] != "none" )
self takeWeapon( self.inventory[ slot ] );

self.inventory[ slot ] = gun;
self giveWeapon( gun, model_index );
self switchToWeapon( gun );
}

harrybo21_set_grenade( gun, ammo )
{
ammo = ammo;
if ( !isDefined( ammo ) )
ammo = 0;

if ( isDefined( self.grenade ) && self.grenade != gun )
self takeWeapon( self.grenade );

self.grenade = gun;
self giveWeapon( gun );

self setWeaponAmmoClip( self.grenade, ammo );
}

harrybo21_set_alt_grenade( gun, ammo )
{
ammo = ammo;
if ( !isDefined( ammo ) )
ammo = 0;

if ( isDefined( self.alt_grenade ) && self.alt_grenade != gun )
self takeWeapon( self.alt_grenade );

self.alt_grenade = gun;
self giveWeapon( gun );

self setWeaponAmmoClip( self.alt_grenade, ammo );
}

they can change this :

Code Snippet
Plaintext
level.harry_perks_fix = true;

to true or false if they need the fix with my perks or not
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: death_reaper0 on May 11, 2016, 01:00:12 pm
change the code in mapname.gsc to this instead :

Code Snippet
Plaintext
weapon_locker_begin()
{
level.harry_perks_fix = true;

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 )
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_give_gun( user.old_gun );
else
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" ) ))
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_take_gun( user.old_gun );
else
user takeWeapon( user.old_gun );

}

if(user.has_stored_weapon == 1)
{
if ( isDefined( level.harry_perks_fix ) && level.harry_perks_fix )
harrybo21_give_gun( user.old_gun );
else
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;
}
}
}
}
}

harrybo21_take_gun( name )
{
if ( isDefined( self.grenade ) && self.grenade == name )
self.grenade = undefined;
else if ( isDefined( self.alt_grenade ) && self.alt_grenade == name )
self.alt_grenade = undefined;
    else if ( isDefined( self.inventory ) && self.inventory.size > 0 )
    {
        for ( i = 0; i < self.inventory.size; i++ )
        {
            if ( self.inventory[ i ] == name )
            {
                self.inventory[ i ] = "none";
                break;
            }
        }
    }
    self takeWeapon( name );
}

harrybo21_give_gun( gun, model_index )
{
primaryWeapons = self GetWeaponsListPrimaries();
currentWeapon = self getCurrentWeapon();
for ( i = 0; i < primaryWeapons.size; i++ )
if ( primaryWeapons[ i ] == gun + "_upgraded" )
gun = gun + "_upgraded";

if ( !self harrybo21_has_weapon( gun ) )
{
if ( gun == "zombie_cymbal_monkey" )
{
self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
self harrybo21_set_alt_grenade( gun, 3 );
}
else if ( gun == "stielhandgranate" )
self harrybo21_set_grenade( gun, 4 );
else if ( gun == "molotov" || gun == "molotov_zombie"  )
self harrybo21_set_alt_grenade( gun, 4 );
else
self harrybo21_set_weapon( gun, model_index );

}
else
{
if ( weaponClass( gun ) == "grenade" )
self giveMaxAmmo( gun );
else
self giveMaxAmmo( gun );
}
self notify( "weapon_obtained" );
}

harrybo21_get_weapon_index( gun )
{
for ( i = 0; i < self.inventory.size; i++ )
{
if ( self.inventory[ i ] == gun )
{
return i;
}
}
return undefined;
}

harrybo21_set_weapon( gun, model_index )
{
if ( !isDefined( model_index ) )
model_index = 0;

slot = self harrybo21_get_weapon_index( "none" );
if ( !isDefined( slot ) )
slot = self harrybo21_get_weapon_index( self getCurrentWeapon() );

if ( self.inventory[ slot ] != "none" )
self takeWeapon( self.inventory[ slot ] );

self.inventory[ slot ] = gun;
self giveWeapon( gun, model_index );
self switchToWeapon( gun );
}

harrybo21_set_grenade( gun, ammo )
{
ammo = ammo;
if ( !isDefined( ammo ) )
ammo = 0;

if ( isDefined( self.grenade ) && self.grenade != gun )
self takeWeapon( self.grenade );

self.grenade = gun;
self giveWeapon( gun );

self setWeaponAmmoClip( self.grenade, ammo );
}

harrybo21_set_alt_grenade( gun, ammo )
{
ammo = ammo;
if ( !isDefined( ammo ) )
ammo = 0;

if ( isDefined( self.alt_grenade ) && self.alt_grenade != gun )
self takeWeapon( self.alt_grenade );

self.alt_grenade = gun;
self giveWeapon( gun );

self setWeaponAmmoClip( self.alt_grenade, ammo );
}

they can change this :

Code Snippet
Plaintext
level.harry_perks_fix = true;

to true or false if they need the fix with my perks or not

shall i put this in the original post?
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 11, 2016, 04:11:21 pm
can do
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 11, 2016, 04:40:43 pm
Thank you both for your work here. Good stuff all around.

Reaper, I have a pretty decently detailed modern style fridge prefab made up, can post screens of it.
If you like it, You'd be more than welcome to add along side yours in dl.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 13, 2016, 12:03:32 pm
Updated to perks 4.0.3

Getting this error with harry's above script
Code Snippet
Plaintext
unknown function
If ( !self harrybo21_has_weapon(gun))
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 13, 2016, 02:09:23 pm
Change the text "gun" to

Name

I think
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 13, 2016, 04:01:01 pm
I realize that I may not have given enough info
 this is where it throws the error.

Code Snippet
Plaintext
if ( !self harrybo21_has_weapon( gun ) )
{
if ( gun == "zombie_cymbal_monkey" )
{
self maps\_zombiemode_cymbal_monkey::player_give_cymbal_monkey();
self harrybo21_set_alt_grenade( gun, 3 );
}
else if ( gun == "stielhandgranate" )
self harrybo21_set_grenade( gun, 4 );
else if ( gun == "molotov" || gun == "molotov_zombie"  )
self harrybo21_set_alt_grenade( gun, 4 );
else
self harrybo21_set_weapon( gun, model_index );

}

There are a lot of references to gun but if I change it to name on initial line I'll have to change it on all references related to that line but not sure which neeed changed and which need left as gun.

I know at least on the == "     "  instances but not sure if its needed elsewhere.

Edit: these are my assumptions on what is happening in function still learning so good chance I'm wrong entirely.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Harry Bo21 on May 13, 2016, 05:38:22 pm
i misread, change

Code Snippet
Plaintext
if ( !self harrybo21_has_weapon( gun ) )

to

Code Snippet
Plaintext
if ( !self hasWeapon( gun ) )

it was a missing "function" error
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 13, 2016, 05:56:50 pm
i misread, change

Code Snippet
Plaintext
if ( !self harrybo21_has_weapon( gun ) )

to

Code Snippet
Plaintext
if ( !self hasWeapon( gun ) )

it was a missing "function" error


Thank you harry, +1
That got me past it and into the map.
Will now continue testing of functions in game and report back anything i find although given your abilities I doubt I'll have many if any at all.



Double Post Merge: May 13, 2016, 06:02:02 pm
Well I was too hasty and should have expected at least something to come up.

Instantly crashes with use of locker with any gun.

Error reads as follows:
Attempted to overrun string in call to va()
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: krimzon on May 14, 2016, 08:07:39 pm
Sorry for double post but I've obtained some info that might be of use.

The above error i mentioned is commonly attributed to servers and map rotations with too many maps which causes an overrun in the string because it has too many characters in the string causing it to hit the limit of char's that can be used in a string.

Now considering I'm hitting this on solo without a server mind you i'm not so sure that it's anything to do with server settings.

I also only get it once i hit the locker.

Somewhere it's hitting that character limit on a string once we trigger the storage function.

I make a lot of backups of my mod especially any time i go to add a new feature and this is with only me using harry's perks and his locker fix code provided by him here.

I understand some of what's happening but harry you might know better than i would about what might be causing the string character limit here to be hit.

Taking a look at the script you provided I wonder if it has to do with the way the non storable guns are set up but this is purely my speculation.

Anybody have any ideas on this? I'd be more than happy to learn about the inner workings of the engine and what could be causing this overrun.

Edit:
I've also read that a long dvar string can cause this as well which seems more likely, at this juncture, than the server related cause of this error.

Edit 2:
Tested setting
Code Snippet
Plaintext
level.harry_perks_fix = true;
To false>compiled mod>pulled gun out of locker>closed game>set fix to true>compiled mod>
Was able to place gun in locker but it also kept it in inventory and on attempt to trade gun, whether same gun is in inventory or not, it throws the overrun error again.
Title: Re: weapon storage locker (carries on between games) v1.2
Post by: Fancygamer1738 on March 25, 2018, 07:49:15 pm
Pretty nice script. Can't wait to put it into my map.