weapon storage locker (carries on between games) v1.2

broken avatar :(
Created 1789 days ago
by death_reaper0
0 Members and 1 Guest are viewing this topic.
15,694 views
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 days 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 :) [You are not allowed to view external links. Register or Login to see them]
discord server:
[You are not allowed to view external links. Register or Login to see them]
×
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.
change the code in mapname.gsc to this instead :

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 :

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?
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 135 days ago
Posts
6,879
Respect
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
can do
broken avatar :(
×
broken avatar :(
Location: usIndiana
Date Registered: 13 September 2013
Last active: 205 days ago
Posts
62
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
krimzon's Groups
krimzon's Contact & Social Links
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.
broken avatar :(
×
broken avatar :(
Location: usIndiana
Date Registered: 13 September 2013
Last active: 205 days ago
Posts
62
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
krimzon's Groups
krimzon's Contact & Social Links
Updated to perks 4.0.3

Getting this error with harry's above script
unknown function
If ( !self harrybo21_has_weapon(gun))
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 135 days ago
Posts
6,879
Respect
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
Change the text "gun" to

Name

I think
broken avatar :(
×
broken avatar :(
Location: usIndiana
Date Registered: 13 September 2013
Last active: 205 days ago
Posts
62
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
krimzon's Groups
krimzon's Contact & Social Links
I realize that I may not have given enough info
 this is where it throws the error.

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.
Last Edit: May 13, 2016, 04:14:09 pm by krimzon
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 135 days ago
Posts
6,879
Respect
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
i misread, change

if ( !self harrybo21_has_weapon( gun ) )

to

if ( !self hasWeapon( gun ) )

it was a missing "function" error
Last Edit: May 13, 2016, 05:50:28 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: usIndiana
Date Registered: 13 September 2013
Last active: 205 days ago
Posts
62
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
krimzon's Groups
krimzon's Contact & Social Links
i misread, change

if ( !self harrybo21_has_weapon( gun ) )

to

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()
Last Edit: May 13, 2016, 06:02:02 pm by krimzon
broken avatar :(
×
broken avatar :(
Location: usIndiana
Date Registered: 13 September 2013
Last active: 205 days ago
Posts
62
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
krimzon's Groups
krimzon's Contact & Social Links
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
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.
Last Edit: May 14, 2016, 08:42:45 pm by krimzon
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 24 May 2016
Last active: 186 days ago
Posts
32
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Strangers are just friends you haven’t met yet.
Signature
I don't post often but when I do I probably make myself seem like an idiot. Also, I don't need people to help me grow up! I drink milk.
×
Fancygamer1738's Contact & Social LinksH3X-4h3x_4H3X--4
Pretty nice script. Can't wait to put it into my map.

 

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