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

wepon storage fail

broken avatar :(
Created 12 years ago
by jjbradman
0 Members and 1 Guest are viewing this topic.
2,388 views
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
 ok i made this script(ripping most of it from the mightydud) which is supposed to store your weapon like in tranzit and refill its ammo over time but after adding the script the trigger doesnt even shows in game .-. its s trigger use can anyone help me :(

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_zombiemode_weapons;

main()
{
self.storagecost = 500; // Set the cost of the storage/regenerate ammo
trig = getEnt("storage_trig","targetname");
startorig = getEnt("storage_start","targetname");
endorig = getEnt("storage_end","targetname");
level.upgrade = 0;
level.take = 1;

thread storage_trig(trig, startorig, endorig);
}


storage_trig(trig, startorig, endorig)
    {
      trig setHintString("Requires Power");
      trig SetCursorHint( "HINT_NOICON" );
      flag_wait("electricity_on");
          while(1)
              {
                trig setHintString("Press f to store your weapon["+self.storagecost+"]");
                trig waittill("trigger",player);
                if( player.score >= self.storagecost )
                    {
                      player playsound( "cha_ching" );
                      player maps\_zombiemode_score::minus_to_player_score( self.storagecost );
                      current_weapon = player GetCurrentWeapon();
                      trig setHintString("Storing...");
                      weapon_stock_ammo = player getWeaponAmmoStock(current_weapon);
                      weapList = player GetWeaponsListPrimaries();
                      player takeweapon(current_weapon);
                      player switchtoweapon(weapList[1]);
                      spawnweapon(current_weapon, startorig, endorig, player);
                      thread give_ammo();
                      trig setHintString("Press f to take your weapon out of storage");
                      trig enable_trigger();
                      trig waittill("trigger",player);
                      spawngive(player);
                      giveback(current_weapon,player,0);
                      level.stop = 1;
                      player setWeaponAmmoStock(current_weapon, (weapon_stock_ammo+level.addammo));
                      wait 0.5;
                      level.stop = 0;
                      level.addammo = 0;
                    }
               }
    }

spawnweapon(weapon, startorig, endorig, player)
{
level.modeln = spawn( "script_model", startorig.origin );
modelname = GetWeaponModel(weapon);
level.modeln setmodel(modelname);
level.modeln.angles = self.angles +( 0, 90, 0 );
level.modeln moveto( endorig.origin,5,1,1);
wait 5;
}
spawngive(player)
{
timer = 2;
on = 0;
while(1)
{
level.modeln moveto( player.origin+(0,0,50),timer,0,0);
on = on+1;
wait 1;
if(on == 5){ break; }
}
level.modeln Delete();
}

rotate(entity, time)
{
on = 0;
while(1)
{
entity rotateYaw(360,1);
on = on+1;
if( on == time )
{
break;
}
wait 1;
}
}

//devmap nazi_zombie_family

give_ammo()
{
level.addammo = 0;
while(1)
{
level.addammo = level.addammo+1;
wait 0.5;
if(level.stop == 1)
{
 break;
}
}
}

giveback(weapon, player, up)
{
weapList = player GetWeaponsListPrimaries();
current_weapon = player GetCurrentWeapon();
if(weapList.size >= 2)
{
player takeweapon(current_weapon);
}
if(up == 0)
{
player giveweapon(weapon);
player switchtoweapon(weapon);
}
}

Post Merge: January 20, 2014, 03:45:35 am
.___. somebody help? x'c
Last Edit: January 20, 2014, 03:45:35 am by jjbradman
Marked as best answer by jjbradman 12 years ago
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
I took the liberty to start over, tell me if there's anything missing.. Btw it adds bullets for every type of gun at the same rate. You might want to change that, but i figured i should leave some work for you  ;D

put this:

Code Snippet
Plaintext
	thread maps\_storage::main();


below the

Code Snippet
Plaintext
	maps\_zombiemode::main();

line, and add this to a text file named _storage.gsc:

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_zombiemode_weapons;

main()
{
level.storagecost = 500; // Set the cost of the storage/regenerate ammo

trig = getEnt("storage_trig","targetname");
trig thread storage_func();
}

storage_func()
{
player = undefined;

self setHintString("Press f to store your weapon["+level.storagecost+"]");
self waittill("trigger",player);

weapList = player GetWeaponsListPrimaries();
if( weaplist.size <= 1 )
{
player iprintlnbold( "Only got one weapon, can't put it in storage" );
self thread storage_func();
}

else if( weaplist.size >= 2 )
{
            if( player.score >= level.storagecost )
            {
            player playsound( "cha_ching" );
            player maps\_zombiemode_score::minus_to_player_score( level.storagecost );
player thread store_weapon( self, player );
}
if( player.score < level.storagecost )
            {
player iprintlnbold( "Not enough points" );
self thread storage_func();
}
}
}


store_weapon( trig, player )
{
    trig setHintString("Storing weapon...");

    weapList = player GetWeaponsListPrimaries();
stored_weapon = player GetCurrentWeapon();
weapon_stock_ammo = player getWeaponAmmoStock( stored_weapon );
clip_stock_ammo = player GetWeaponAmmoClip( stored_weapon );
player takeweapon( stored_weapon );
    weapList = player GetWeaponsListPrimaries();
switch_gun = weapList[0];
if( switch_gun == "none" )
{
switch_gun = weapList[1];
iprintln( "changing gun to switch to");
}
// if( switch_gun == "none" ) // MULE KICK ???
// {
// switch_gun = weapList[2];
// iprintln( "changing gun to switch to");
// }

player switchtoweapon( switch_gun );
trig thread storage_anims( stored_weapon );
trig thread fill_ammo( player, stored_weapon, weapon_stock_ammo, clip_stock_ammo );

wait 5;

trig setHintString("Press f to take your weapon out of storage");

trig waittill("trigger", player );
    weapList = player GetWeaponsListPrimaries();

if( weaplist.size >= 2 )
{
player iprintlnbold( "This will replace your current weapon!" );
trig setHintString("Press f to take pick up weapon");
trig waittill("trigger", player );
trig notify( "gun_grabbed" );
player thread gun_storage_hud_destroy();
wait 2;
current_weapon = player GetCurrentWeapon();
player takeweapon( current_weapon );
player giveweapon(stored_weapon);
player setWeaponAmmoStock(stored_weapon, player.gun_stock );
player SetWeaponAmmoClip(stored_weapon, player.clip_stock );
player switchtoweapon(stored_weapon);
trig thread storage_func();
}

else if( weaplist.size <= 1 )
{
trig notify( "gun_grabbed" );
player thread gun_storage_hud_destroy();
wait 2;
player giveweapon(stored_weapon);
player setWeaponAmmoStock(stored_weapon, player.gun_stock );
player SetWeaponAmmoClip(stored_weapon, player.clip_stock );
player switchtoweapon(stored_weapon);
trig thread storage_func();
}
}


fill_ammo( player, weapon, weapon_stock, clip_stock )
{
player endon( "disconnect" );
player endon( "death" );
self endon( "gun_grabbed" );

player.gun_max = 0;
player.clip_max = 0;
player.total_max = 0;
player.gun_stock = 0;
player.clip_stock = 0;
player.total_gun = 0;

player.gun_max = WeaponMaxAmmo( weapon );
player.clip_max = WeaponClipSize( weapon );

player.total_max = player.gun_max + player.clip_max ;

player.gun_stock = weapon_stock;
player.clip_stock = clip_stock;

player.total_gun = player.gun_stock + player.clip_stock ;

player thread hud_create_gun_storage();

for(i=player.clip_stock;player.clip_stock< player.clip_max;player.clip_stock++ )
{
wait 0.5;
iprintln( "adding bullet to clip" );
player.total_gun = player.gun_stock + player.clip_stock ;
player.store_hud[ "stock2" ] SetValue(  player.total_gun );
}

iprintln( "clip full, changing to gun stock" );

for(i=player.gun_stock;player.gun_stock< player.gun_max;player.gun_stock++ )
{
wait 0.5;
iprintln( "adding bullet to gun" );
player.total_gun = player.gun_stock + player.clip_stock ;
player.store_hud[ "stock2" ] SetValue(  player.total_gun );
}

player thread gun_storage_hud_destroy();
iprintln( "gun filled to max!" );
}






storage_anims( weapon )
{
start = getent( "store_start" , "targetname" );
end = getent( "store_end" , "targetname" );
gun_model = GetWeaponModel( weapon );
gun = Spawn( "script_model" , start.origin );
gun.angles = self.angles;
gun SetModel( gun_model );
gun moveto( end.origin, 2 );
gun rotateyaw( 540, 2);
wait 2;
playfx (level._effect["powerup_grabbed_wave"], end.origin );

self waittill( "gun_grabbed" );

gun moveto( start.origin, 2 );
gun rotateyaw( 540, 2);
wait 2;
playfx (level._effect["powerup_grabbed_wave"], start.origin );
gun delete();
}


hud_create_gun_storage()
{
iprintln( "creating HUD element" );

texthud = create_simple_hud( self );
texthud.foreground = true;
texthud.sort = 1;
texthud.hidewheninmenu = false;
texthud.alignX = "left";
texthud.alignY = "bottom";
texthud.horzAlign = "left";
texthud.vertAlign = "bottom";
texthud.x =  10;
texthud.y = -220;
texthud.fontScale = 1;
texthud.color = ( 1.0, 1.0, 90 );
texthud.alpha = 1;
texthud setText( "Stored weapon max ammo:" );

self.store_hud[ "text" ] = texthud;

hud = create_simple_hud( self );
hud.foreground = true;
hud.sort = 1;
hud.hidewheninmenu = false;
hud.alignX = "left";
hud.alignY = "bottom";
hud.horzAlign = "left";
hud.vertAlign = "bottom";
hud.x =  10;
hud.y = -200;
hud.fontScale = 1;
hud.color = ( 1.0, 1.0, 90 );
hud.alpha = 1;
hud SetValue( self.total_max ) ;

self.store_hud[ "stock" ] = hud;

text2hud = create_simple_hud( self );
text2hud.foreground = true;
text2hud.sort = 1;
text2hud.hidewheninmenu = false;
text2hud.alignX = "left";
text2hud.alignY = "bottom";
text2hud.horzAlign = "left";
text2hud.vertAlign = "bottom";
text2hud.x =  10;
text2hud.y = -180;
text2hud.fontScale = 1;
text2hud.color = ( 1.0, 1.0, 90 );
text2hud.alpha = 1;
text2hud setText( "Current ammo:" );

self.store_hud[ "text2" ] = text2hud;

text3hud = create_simple_hud( self );
text3hud.foreground = true;
text3hud.sort = 1;
text3hud.hidewheninmenu = false;
text3hud.alignX = "left";
text3hud.alignY = "bottom";
text3hud.horzAlign = "left";
text3hud.vertAlign = "bottom";
text3hud.x =  10;
text3hud.y = -160;
text3hud.fontScale = 1;
text3hud.color = ( 1.0, 1.0, 90 );
text3hud.alpha = 1;
text3hud SetValue( self.total_gun ) ;

self.store_hud[ "stock2" ] = text3hud;

}


gun_storage_hud_destroy()
{
iprintln( "removing HUD element" );
self.store_hud[ "stock" ] destroy_hud();
self.store_hud[ "stock" ] = undefined;
self.store_hud[ "stock2" ] destroy_hud();
self.store_hud[ "stock2" ] = undefined;
self.store_hud[ "text" ] destroy_hud();
self.store_hud[ "text" ] = undefined;
self.store_hud[ "text2" ] destroy_hud();
self.store_hud[ "text2" ] = undefined;
}

I did zome testing, but now extensively. Iff you find bugs, let me know..

EDIT:
Lol, you also need a trigger offcourse: a trigger_use

Code Snippet
Plaintext
storage_trig - targetname

and 2 script_origins:

1 where the gun first appears:

Code Snippet
Plaintext
store_start - targetname

and one where the gun is floating while stored:

Code Snippet
Plaintext
store_end - targetname

Then it should work! my bad!!

CoD WaW Custom Zombies: Weapon storage that refills ammo..
Last Edit: January 20, 2014, 10:25:41 am by BluntStuffy
broken avatar :(
×
broken avatar :(
Former UGX Lead Asset Creator
Location: ca
Date Registered: 17 August 2012
Last active: 7 years ago
Posts
1,932
Respect
Forum Rank
Zombie Destroyer
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
Eh?
Signature

(Click to enter portfolio)
×
SajeOne's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
I took the liberty to start over, tell me if there's anything missing.. Btw it adds bullets for every type of gun at the same rate. You might want to change that, but i figured i should leave some work for you  ;D
Seeing as you already did all the work it would be really nice if you posted this in the user tutorials section so other members could easily access it. :)
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Seeing as you already did all the work it would be really nice if you posted this in the user tutorials section so other members could easily access it. :)

Lol, well i was actually looking for a way to store ammo value's for my own map so that's part of the reason i did it. But like i said it's not fully tested, and not tested with mule-kick at all ( i haven't updated mule-kick yet, guess it should work with the old/'glitched' version). May be someone could test that first?
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
wowawawaowow man you're awsome :D!!!! it seems that making this script wasnt as easy as i thought :/ i'll try to test it with mule kick(i also noticed the part you commented out for it o.O lol) ill let you know about any bugs and i think it would be cool to share it :)

 
Loading ...