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

Forceviewmodel animation freezes weapon?

broken avatar :(
Created 8 years ago
by Scobalula
0 Members and 1 Guest are viewing this topic.
3,562 views
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
Signature
Aye mate you don't know me so y don't you shut tf up ok buddy :)

×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
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.
Scobalula's Contact & Social Links
I am working on a Dual Mag script which appears to be working but I've run into an issue.

When it came to playing a different anim when they had 0 bullets I decided to use forceviewmodelanimation and set it to reload, which would be the dual_mag_empty anim.

It works, but for some reason after it switches back to my original weapon I can't shoot for 1 or so seconds.

This is the script:

Code Snippet
Plaintext
init_dual_mag()
{
flag_wait("all_players_connected");
players = get_players(  );
for(i=0;i<players.size;i++)
{
players[i] thread dual_mag_check();
players[i] thread test();
}

}

dual_mag_check()
{
self endon( "disconnect" );
IPrintLn( "START" );
self.reloads = 0;
while(true)
{
weapon = self GetCurrentWeapon();
if(weapon == "k7")
{
IPrintLn( "Has K7!!" );
self waittill( "reload_start" );
IPrintLn( "Reloading" );
self.reloads++;
if(self.reloads == 2)
{
self.reloads = 0;
self SwitchToWeapon( "k7_alt" );
self DisableWeaponCycling(  );
self DisableOffhandWeapons(  );
self AllowMelee( false );
if(self GetCurrentWeaponClipAmmo() == 0)
{
self ForceViewmodelAnimation( "k7_alt", "reload" );
wait 1.98; // reload is 2 seconds long.
}
else
{
wait 2.48; // reload aka raise is 2.5 seconds long
}
self SwitchToWeapon( "k7" );
self SetWeaponAmmoClip( "k7", 30 );
self EnableWeaponCycling(  );
self EnableOffhandWeapons(  );
self AllowMelee( true );
}
}
wait 0.005;
}
}

Shooting and reloading when there is ammo in weapon works no issues, but if it's reloading empty with the dual mag anim, it freezes the gun for a few seconds.

Any info would be appreciated, if I can't get it to work I can just use same dual mag anim. :P
broken avatar :(
×
broken avatar :(
Location: usChicago, IL
Date Registered: 8 January 2015
Last active: 2 years ago
Posts
136
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
FinalKill9175's Groups
FinalKill9175's Contact & Social LinksFinalKillGamingFinalKill917FinalKill9175
I am working on a Dual Mag script which appears to be working but I've run into an issue.

When it came to playing a different anim when they had 0 bullets I decided to use forceviewmodelanimation and set it to reload, which would be the dual_mag_empty anim.

It works, but for some reason after it switches back to my original weapon I can't shoot for 1 or so seconds.

This is the script:

Code Snippet
Plaintext
init_dual_mag()
{
flag_wait("all_players_connected");
players = get_players(  );
for(i=0;i<players.size;i++)
{
players[i] thread dual_mag_check();
players[i] thread test();
}

}

dual_mag_check()
{
self endon( "disconnect" );
IPrintLn( "START" );
self.reloads = 0;
while(true)
{
weapon = self GetCurrentWeapon();
if(weapon == "k7")
{
IPrintLn( "Has K7!!" );
self waittill( "reload_start" );
IPrintLn( "Reloading" );
self.reloads++;
if(self.reloads == 2)
{
self.reloads = 0;
self SwitchToWeapon( "k7_alt" );
self DisableWeaponCycling(  );
self DisableOffhandWeapons(  );
self AllowMelee( false );
if(self GetCurrentWeaponClipAmmo() == 0)
{
self ForceViewmodelAnimation( "k7_alt", "reload" );
wait 1.98; // reload is 2 seconds long.
}
else
{
wait 2.48; // reload aka raise is 2.5 seconds long
}
self SwitchToWeapon( "k7" );
self SetWeaponAmmoClip( "k7", 30 );
self EnableWeaponCycling(  );
self EnableOffhandWeapons(  );
self AllowMelee( true );
}
}
wait 0.005;
}
}

Shooting and reloading when there is ammo in weapon works no issues, but if it's reloading empty with the dual mag anim, it freezes the gun for a few seconds.

Any info would be appreciated, if I can't get it to work I can just use same dual mag anim. :P
This is the code I use for my dual clips, I just worked it out with MC on zombiemodding:
Code Snippet
Plaintext
ALLPLAYERTHREAD(){
players = get_players();
for(i=0;i<players.size;i++){
        //Copy and paste these two lines for every dual clip gun you add
//The Two numbers at the end represent the time in your weapon file it takes for the mag to enter the gun (when the counter refills) for normal, and then for quick
players[i] thread AltReload("commando_fastmag", "commando_fastmag_quick", 1.55, 1.13);
players[i] thread hud_check_alt_reload("commando_fastmag", "commando_fastmag_quick");
players[i] thread AltReload("commando_fastmag_upgraded", "commando_fastmag_quick_upgraded", 1.55, 1.13);
players[i] thread hud_check_alt_reload("commando_fastmag_upgraded", "commando_fastmag_quick_upgraded");
}
}
hud_check_alt_reload(specialgun, specialgun_other){
while(1){
if(self GetCurrentWeapon() == specialgun || self GetCurrentWeapon() == specialgun_other){
self SetClientDvar( "hideAlt", true );
wait 0.1;
continue;
}
else{
self SetClientDvar( "hideAlt", false );
wait 0.1;
continue;
}
}
}
AltReload(specialgun, specialgun_other, norm_reload_time, quick_reload_time){
   counter = 0;
 
   while(1){
      self waittill("reload");
      if(self GetCurrentWeapon()==specialgun || self GetCurrentWeapon()==specialgun_other)
      {
//self SetClientDvar( "hideAlt", 1 );
         counter++;
      }
      else
      {   
         //self SetClientDvar( "hideAlt", 0 );
         continue;
      }
      //iprintln(counter);
      if(counter>0){
                     self AltWatch(specialgun_other, specialgun, norm_reload_time, quick_reload_time);
                     counter =0;
                }
   }

}
AltWatch(specialgun_other, specialgun, norm_reload_time, quick_reload_time){

player_has_speed = self hasPerk("specialty_fastreload");
   if(self GetCurrentWeapon()== specialgun)
   {
   if(!player_has_speed){
   wait(norm_reload_time);
   }
   else{
   wait(norm_reload_time/2);
   }
     
      self SwitchToWeapon( specialgun_other );
      //self SetWeaponAmmoClip( specialgun_other, 500 );
   }
   else if(self GetCurrentWeapon()==specialgun_other)
   {
      if(!player_has_speed){
   wait(quick_reload_time);
   }
   else{
   wait(quick_reload_time/2);
   }
      self SwitchToWeapon( specialgun );
      //self SetWeaponAmmoClip( specialgun, 500 );
   }
}
Marked as best answer by Scobalula 8 years ago
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 9 months ago
Posts
577
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
My preferred name is "xSanchez78".
Check me out here: www.steamcommunity.com/id/xSanchez78
×
alaurenc9'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.
alaurenc9's Contact & Social LinksxSanchez78xSanchez78xSanchez78xSanchez78xSanchez78xSanchez78
If you switch weapon to fast after playing a forced animation with ForceViewModelAnimation, it freezes the gun up and waits the reload time all over again. For those wait times you added, add 0.05 to them so it has a nice extra frame of time to finish the animation. Also for your reload wait times, don't forget to account for speed cola.
Code Snippet
Plaintext
n_reload_time = THE TIME;
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
Your script also looks like you can switch from 'k7' but still have this work. You have to constantly check that your current weapon is the k7, you cannot just wait until reload start because the player might have switched from it during that time.

Here I made a little script you could try that fixes what I just mentioned:
Code Snippet
Plaintext
dual_mag_check()
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count();
k7_active = false;
while( true )
{
weapon = self GetCurrentWeapon();
if( weapon == "k7" || weapon == "k7_alt" )
{
if( !k7_active )
{
self thread check_dual_mag_reload();
k7_active = true;
}
}
else
{
if( k7_active )
{
self notify( "switched_from_k7" );
k7_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count()
{
self endon( "disconnect" );
self.dual_mag_reloads = 0;
while( true )
{
while( !self HasWeapon( "k7" ) )
{
wait 0.05;
}
self.dual_mag_reloads = 0; // reset this every time you get the weapon
while( self HasWeapon( "k7" ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload()
{
self endon( "disconnect" );
self endon( "switched_from_k7" );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads ++;
if( self.dual_mag_reloads >= 2 )
{
self.dual_mag_reloads = 0;
self SwitchToWeapon( "k7_alt" );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( "k7" ) == 0 )
{
self ForceViewmodelAnimation( "k7_alt", "reload" );
n_reload_time = 2.05;
}
else
{
n_reload_time = 2.55;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time;
self SwitchToWeapon( "k7" );
self SetWeaponAmmoClip( "k7", 30 );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
}
}
}
BTW this script is actually pretty smart. Mind if I use it?
Last Edit: March 19, 2016, 08:36:54 pm by alaurenc9
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
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.
Scobalula's Contact & Social Links
If you switch weapon to fast after playing a forced animation with ForceViewModelAnimation, it freezes the gun up and waits the reload time all over again. For those wait times you added, add 0.05 to them so it has a nice extra frame of time to finish the animation. Also for your reload wait times, don't forget to account for speed cola.
Code Snippet
Plaintext
n_reload_time = THE TIME;
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
Your script also looks like you can switch from 'k7' but still have this work. You have to constantly check that your current weapon is the k7, you cannot just wait until reload start because the player might have switched from it during that time.

Here I made a little script you could try that fixes what I just mentioned:
Code Snippet
Plaintext
dual_mag_check()
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count();
k7_active = false;
while( true )
{
weapon = self GetCurrentWeapon();
if( weapon == "k7" )
{
if( !k7_active )
{
self thread check_dual_mag_reload();
k7_active = true;
}
}
else
{
if( k7_active )
{
self notify( "switched_from_k7" );
k7_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count()
{
self endon( "disconnect" );
self.dual_mag_reloads = 0;
while( true )
{
while( !self HasWeapon( "k7" ) )
{
wait 0.05;
}
self.dual_mag_reloads = 0; // reset this every time you get the weapon
while( self HasWeapon( "k7" ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload()
{
self endon( "disconnect" );
self endon( "switched_from_k7" );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads ++;
if( self.dual_mag_reloads >= 2 )
{
self.dual_mag_reloads = 0;
self SwitchToWeapon( "k7_alt" );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( "k7" ) == 0 )
{
self ForceViewmodelAnimation( "k7_alt", "reload" );
n_reload_time = 2.05;
}
else
{
n_reload_time = 2.55;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time;
self SwitchToWeapon( "k7" );
self SetWeaponAmmoClip( "k7", 30 );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
}
}
}
BTW this script is actually pretty smart. Mind if I use it?

Thanks, nice to know that when I use forceviewmodelanimation again, lol. and thanks for making the edits for me. :D

I forgot to add it to the bottom of this, but with anything I post in this section when asking for help, anyone is more than welcome to use this stuff and apply it to what they want. :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 9 months ago
Posts
577
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
alaurenc9'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.
alaurenc9's Contact & Social LinksxSanchez78xSanchez78xSanchez78xSanchez78xSanchez78xSanchez78
Thanks, nice to know that when I use forceviewmodelanimation again, lol. and thanks for making the edits for me. :D

I forgot to add it to the bottom of this, but with anything I post in this section when asking for help, anyone is more than welcome to use this stuff and apply it to what they want. :)
K thanks. I made some changes after the first time I posted this script, can I see the script that you are using right now to make sure it is right?
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
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.
Scobalula's Contact & Social Links
K thanks. I made some changes after the first time I posted this script, can I see the script that you are using right now to make sure it is right?

Sure, I made some edits but nothing major, just made it so I can call it with add_dual_mag_weapon(); and check their weapon so they can't switch to the alt weapon:

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

init()
{
add_dual_mag_weapon("commando", "commando_alt");
}


add_dual_mag_weapon(wpn,wpn2)
{
flag_wait("all_players_connected");
players = get_players(  );
for(i=0;i<players.size;i++)
{
players[i] thread dual_mag_check(wpn,wpn2);
players[i] thread is_alt(wpn,wpn2);
}

}

is_alt(wpn,wpn2)
{
self endon( "disconnect" );
self.is_reloading_dual_mags = 0;
while( 1 )
{
weapon = self GetCurrentWeapon();
if(weapon == wpn2)
{
if(!self.is_reloading_dual_mags)
{
self SwitchToWeapon( wpn );
}
}
wait 0.05;
}
}

dual_mag_check(wpn,wpn2)
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count(wpn);
dual_mag_active = false;
while( true )
{
weapon = self GetCurrentWeapon();
if( weapon == wpn || weapon == wpn2 )
{
if( !dual_mag_active )
{
self thread check_dual_mag_reload(wpn,wpn2);
dual_mag_active = true;
}
}
else
{
if( dual_mag_active )
{
self notify( "switched_from_dual_mag" );
dual_mag_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count(wpn)
{
self endon( "disconnect" );
self.dual_mag_reloads = 0;
while( true )
{
while( !self HasWeapon( wpn ) )
{
wait 0.05;
}
self.dual_mag_reloads = 0; // reset this every time you get the weapon
while( self HasWeapon( wpn ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload(wpn,wpn2)
{
self endon( "disconnect" );
self endon( "switched_from_dual_mag" );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads ++;
if( self.dual_mag_reloads >= 2 )
{
self.dual_mag_reloads = 0;
self.is_reloading_dual_mags = 1;
self SwitchToWeapon( wpn2 );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( wpn ) == 0 )
{
self ForceViewmodelAnimation( wpn2, "reload" );
n_reload_time = 2.05;
}
else
{
n_reload_time = 2.55;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time;
self SwitchToWeapon( wpn );
self SetWeaponAmmoClip( wpn, 30 );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
self.is_reloading_dual_mags = 0;
}
}
}



I did notice however, that if they have speed cola, it can freeze again, and if they are reloading they can switch back to their original. According to DUKIP it is not possible to override this at all. I just need to rely on them not pressing 5. :P
Last Edit: March 20, 2016, 11:27:05 pm by Scobalula
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 9 months ago
Posts
577
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
alaurenc9'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.
alaurenc9's Contact & Social LinksxSanchez78xSanchez78xSanchez78xSanchez78xSanchez78xSanchez78
Sure, I made some edits but nothing major, just made it so I can call it with add_dual_mag_weapon(); and check their weapon so they can't switch to the alt weapon:

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

init()
{
add_dual_mag_weapon("commando", "commando_alt");
}


add_dual_mag_weapon(wpn,wpn2)
{
flag_wait("all_players_connected");
players = get_players(  );
for(i=0;i<players.size;i++)
{
players[i] thread dual_mag_check(wpn,wpn2);
players[i] thread is_alt(wpn,wpn2);
}

}

is_alt(wpn,wpn2)
{
self endon( "disconnect" );
self.is_reloading_dual_mags = 0;
while( 1 )
{
weapon = self GetCurrentWeapon();
if(weapon == wpn2)
{
if(!self.is_reloading_dual_mags)
{
self SwitchToWeapon( wpn );
}
}
wait 0.05;
}
}

dual_mag_check(wpn,wpn2)
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count(wpn);
dual_mag_active = false;
while( true )
{
weapon = self GetCurrentWeapon();
if( weapon == wpn || weapon == wpn2 )
{
if( !dual_mag_active )
{
self thread check_dual_mag_reload(wpn,wpn2);
dual_mag_active = true;
}
}
else
{
if( dual_mag_active )
{
self notify( "switched_from_dual_mag" );
dual_mag_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count(wpn)
{
self endon( "disconnect" );
self.dual_mag_reloads = 0;
while( true )
{
while( !self HasWeapon( wpn ) )
{
wait 0.05;
}
self.dual_mag_reloads = 0; // reset this every time you get the weapon
while( self HasWeapon( wpn ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload(wpn,wpn2)
{
self endon( "disconnect" );
self endon( "switched_from_dual_mag" );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads ++;
if( self.dual_mag_reloads >= 2 )
{
self.dual_mag_reloads = 0;
self.is_reloading_dual_mags = 1;
self SwitchToWeapon( wpn2 );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( wpn ) == 0 )
{
self ForceViewmodelAnimation( wpn2, "reload" );
n_reload_time = 2.05;
}
else
{
n_reload_time = 2.55;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time;
self SwitchToWeapon( wpn );
self SetWeaponAmmoClip( wpn, 30 );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
self.is_reloading_dual_mags = 0;
}
}
}



I did notice however, that if they have speed cola, it can freeze again, and if they are reloading they can switch back to their original. According to DUKIP it is not possible to override this at all. I just need to rely on them not pressing 5. :P
Or you can do
Code Snippet
Plaintext
self SetActionSlot( 3, "" );
while reloading and then
Code Snippet
Plaintext
self SetActionSlot( 3, "altmode" );
to re-enable alt weapon switching when done. Also if you are making multiple weapons, I would suggest making an array for self.dual_mag_reloads, so each weapon would have self.dual_mag_reloads[ weapon ].

Here I made some changes for you again, this time I also made it set the ammo to the weapon's clip size rather than just '30' as not all guns have a clip size of 30. I also added the alt weapon switch disable instead of your 'is_alt' function. I used a little something I got from origins staffs scripts that was used to manage the "fake" alt weapon that was the revive staff, but heavily edited to fit for this. Basically it just handles some logic about when to allow or disallow alt weapon switching, so that it doesn't break other gun's alt weapons. You also said that if the player has speed cola, it still freezes? I put the weapon reload times back to their default and manually added +0.05 in the reload time multiplier for speed cola.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
add_dual_mag_weapon( "commando", "commando_alt", 2.5, 2 );
level thread onPlayerConnect();
}

add_dual_mag_weapon( weapon, alt_weapon, reload_time, empty_reload_time )
{
if( !IsDefined( level.dual_mag_weapons ) )
{
level.dual_mag_weapons = [];
}
struct = SpawnStruct();
struct.alt_weapon = alt_weapon;
struct.reload_time = reload_time;
struct.empty_reload_time = empty_reload_time;
level.dual_mag_weapons[ weapon ] = struct;
}

onPlayerConnect()
{
for( ;; )
{
level waittill( "connecting", player );
player thread disable_alt_weapon_switching();
player.dual_mag_reloads = [];
keys = GetArrayKeys( level.dual_mag_weapons );
for( i = 0; i < keys.size; i ++ )
{
player thread dual_mag_check( keys[i] );
}
}
}

disable_alt_weapon_switching()
{
self endon( "disconnect" );
while( true )
{
self waittill( "weapon_change", weapon );
has_dual_mag = false;
weapon_is_dual_mag = is_weapon_dual_mag( weapon );
a_str_weapons = self GetWeaponsList();
for( i = 0; i < a_str_weapons.size; i ++ )
{
str_weapon = a_str_weapons[i];
if( is_weapon_upgraded_staff( str_weapon ) )
{
has_dual_mag = true;
break;
}
}
if( !has_dual_mag || ( !weapon_is_dual_mag && weapon != "none" && WeaponAltWeaponName( weapon ) != "none" ) )
{
self SetActionSlot( 3, "altmode" );
}
else
{
self SetActionSlot( 3, "" );
}
}
}

is_weapon_dual_mag( weapon )
{
keys = GetArrayKeys( level.dual_mag_weapons );
weapon_is_dual_mag = false;
for( i = 0; i < keys.size; i ++ )
{
if( weapon == keys[i] || weapon == level.dual_mag_weapons[ keys[i] ].alt_weapon )
{
weapon_is_dual_mag = true;
break;
}
}
return weapon_is_dual_mag;
}

dual_mag_check( weapon )
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count( weapon );
dual_mag_active = false;
while( true )
{
current_weapon = self GetCurrentWeapon();
if( current_weapon == weapon || current_weapon == level.dual_mag_weapons[ weapon ].alt_weapon )
{
if( !dual_mag_active )
{
self thread check_dual_mag_reload( weapon );
dual_mag_active = true;
}
}
else
{
if( dual_mag_active )
{
self notify( "switched_from_dual_mag_" + weapon );
dual_mag_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count( weapon )
{
self endon( "disconnect" );
self.dual_mag_reloads[ weapon ] = 0;
while( true )
{
while( !self HasWeapon( weapon ) )
{
wait 0.05;
}
self.dual_mag_reloads[ weapon ] = 0;
while( self HasWeapon( weapon ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload( weapon )
{
self endon( "disconnect" );
self endon( "switched_from_dual_mag_" + weapon );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads[ weapon ] ++;
if( self.dual_mag_reloads[ weapon ] >= 2 )
{
self.dual_mag_reloads[ weapon ] = 0;
self SwitchToWeapon( level.dual_mag_weapons[ weapon ].alt_weapon );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( weapon ) == 0 )
{
self ForceViewmodelAnimation( level.dual_mag_weapons[ weapon ].alt_weapon, "reload" );
n_reload_time = level.dual_mag_weapons[ weapon ].empty_reload_time;
}
else
{
n_reload_time = level.dual_mag_weapons[ weapon ].reload_time;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time + 0.05;
self SwitchToWeapon( weapon );
self SetWeaponAmmoClip( weapon, WeaponClipSize( weapon ) );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
}
}
}
Also I realized that if you have speed cola, and you use the alt raise animation like you have been doing to play the animation, speed cola will not speed that up. I'm tired right now so maybe make sure this works first and I will think of a way to speed up the normal reload time w/ speed cola and script it for you, only because I want to use this too and I don't mind who else uses it because I don't like seeing fake dual mags like I have before. Infact, if you confirm it works, could I make a tutorial in the scripts section?
Last Edit: March 21, 2016, 04:55:33 am by alaurenc9
broken avatar :(
×
broken avatar :(
OnionmanVere Bo21
Location: ieu dnt wnt 2 no
Date Registered: 27 September 2013
Last active: 1 year ago
Posts
1,864
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Mapper
My Groups
More
Personal Quote
ok
×
Scobalula's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Box Mappers Elite
Box Mappers Elite
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.
Scobalula's Contact & Social Links
Or you can do
Code Snippet
Plaintext
self SetActionSlot( 3, "" );
while reloading and then
Code Snippet
Plaintext
self SetActionSlot( 3, "altmode" );
to re-enable alt weapon switching when done. Also if you are making multiple weapons, I would suggest making an array for self.dual_mag_reloads, so each weapon would have self.dual_mag_reloads[ weapon ].

Here I made some changes for you again, this time I also made it set the ammo to the weapon's clip size rather than just '30' as not all guns have a clip size of 30. I also added the alt weapon switch disable instead of your 'is_alt' function. I used a little something I got from origins staffs scripts that was used to manage the "fake" alt weapon that was the revive staff, but heavily edited to fit for this. Basically it just handles some logic about when to allow or disallow alt weapon switching, so that it doesn't break other gun's alt weapons. You also said that if the player has speed cola, it still freezes? I put the weapon reload times back to their default and manually added +0.05 in the reload time multiplier for speed cola.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
add_dual_mag_weapon( "commando", "commando_alt", 2.5, 2 );
level thread onPlayerConnect();
}

add_dual_mag_weapon( weapon, alt_weapon, reload_time, empty_reload_time )
{
if( !IsDefined( level.dual_mag_weapons ) )
{
level.dual_mag_weapons = [];
}
struct = SpawnStruct();
struct.alt_weapon = alt_weapon;
struct.reload_time = reload_time;
struct.empty_reload_time = empty_reload_time;
level.dual_mag_weapons[ weapon ] = struct;
}

onPlayerConnect()
{
for( ;; )
{
level waittill( "connecting", player );
player thread disable_alt_weapon_switching();
player.dual_mag_reloads = [];
keys = GetArrayKeys( level.dual_mag_weapons );
for( i = 0; i < keys.size; i ++ )
{
player thread dual_mag_check( keys[i] );
}
}
}

disable_alt_weapon_switching()
{
self endon( "disconnect" );
while( true )
{
self waittill( "weapon_change", weapon );
has_dual_mag = false;
weapon_is_dual_mag = is_weapon_dual_mag( weapon );
a_str_weapons = self GetWeaponsList();
for( i = 0; i < a_str_weapons.size; i ++ )
{
str_weapon = a_str_weapons[i];
if( is_weapon_upgraded_staff( str_weapon ) )
{
has_dual_mag = true;
break;
}
}
if( !has_dual_mag || ( !weapon_is_dual_mag && weapon != "none" && WeaponAltWeaponName( weapon ) != "none" ) )
{
self SetActionSlot( 3, "altmode" );
}
else
{
self SetActionSlot( 3, "" );
}
}
}

is_weapon_dual_mag( weapon )
{
keys = GetArrayKeys( level.dual_mag_weapons );
weapon_is_dual_mag = false;
for( i = 0; i < keys.size; i ++ )
{
if( weapon == keys[i] || weapon == level.dual_mag_weapons[ keys[i] ].alt_weapon )
{
weapon_is_dual_mag = true;
break;
}
}
return weapon_is_dual_mag;
}

dual_mag_check( weapon )
{
self endon( "disconnect" );
self thread watch_dual_mag_reload_count( weapon );
dual_mag_active = false;
while( true )
{
current_weapon = self GetCurrentWeapon();
if( current_weapon == weapon || current_weapon == level.dual_mag_weapons[ weapon ].alt_weapon )
{
if( !dual_mag_active )
{
self thread check_dual_mag_reload( weapon );
dual_mag_active = true;
}
}
else
{
if( dual_mag_active )
{
self notify( "switched_from_dual_mag_" + weapon );
dual_mag_active = false;
}
}
wait 0.05;
}
}

watch_dual_mag_reload_count( weapon )
{
self endon( "disconnect" );
self.dual_mag_reloads[ weapon ] = 0;
while( true )
{
while( !self HasWeapon( weapon ) )
{
wait 0.05;
}
self.dual_mag_reloads[ weapon ] = 0;
while( self HasWeapon( weapon ) )
{
wait 0.05;
}
}
}

check_dual_mag_reload( weapon )
{
self endon( "disconnect" );
self endon( "switched_from_dual_mag_" + weapon );
while( true )
{
self waittill( "reload_start" );
self.dual_mag_reloads[ weapon ] ++;
if( self.dual_mag_reloads[ weapon ] >= 2 )
{
self.dual_mag_reloads[ weapon ] = 0;
self SwitchToWeapon( level.dual_mag_weapons[ weapon ].alt_weapon );
self DisableWeaponCycling();
self DisableOffhandWeapons();
self AllowMelee( false );
if( self GetWeaponAmmoClip( weapon ) == 0 )
{
self ForceViewmodelAnimation( level.dual_mag_weapons[ weapon ].alt_weapon, "reload" );
n_reload_time = level.dual_mag_weapons[ weapon ].empty_reload_time;
}
else
{
n_reload_time = level.dual_mag_weapons[ weapon ].reload_time;
}
if( self HasPerk( "specialty_fastreload" ) )
{
n_reload_time *= GetDvarFloat( "perk_weapReloadMultiplier" );
}
wait n_reload_time + 0.05;
self SwitchToWeapon( weapon );
self SetWeaponAmmoClip( weapon, WeaponClipSize( weapon ) );
self EnableWeaponCycling();
self EnableOffhandWeapons();
self AllowMelee( true );
}
}
}
Also I realized that if you have speed cola, and you use the alt raise animation like you have been doing to play the animation, speed cola will not speed that up. I'm tired right now so maybe make sure this works first and I will think of a way to speed up the normal reload time w/ speed cola and script it for you, only because I want to use this too and I don't mind who else uses it because I don't like seeing fake dual mags like I have before. Infact, if you confirm it works, could I make a tutorial in the scripts section?

Tested and worked, however there is still that pesky issue with speedcola and freezing, lol, but other than that works.

As for tutorial: go for it.

 
Loading ...