Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help How to store a weapon so you spawn with it?
#1
setspawnweapon didnt seem to work? does it work and i just done it wrong or?

is there a way to do it with a variable?
Reply

#2
The function works. It probably doesn't work because _class.gsc::giveLoadout() overwrites it. Try to use the giveLoadout() function to give weapons

edit: In _globallogic_spawn:ConfusedpawnPlayer() giveloadout get's called. Try to edit that...
[Image: MaEIQ.png]
Reply

#3
could you give an example of how giveloadout works? ive never heard of it before & cant find crap on google Big Grin
Reply

#4
Code:
giveLoadout( team, class )
{
        self takeAllWeapons();
        
        /*
        if ( level.splitscreen )
                primaryIndex = 0;
        else
                primaryIndex = self.pers["primary"];
        */
        
        primaryIndex = 0;
        
        // initialize specialty array
        self.specialty = [];

        primaryWeapon = undefined;
        
        // ============= custom class selected ==============
        if( isSubstr( class, "CLASS_CUSTOM" ) )
        {      
                // gets custom class data from stat bytes
                self cac_getdata();
        
                // obtains the custom class number
                class_num = int( class[class.size-1] )-1;
                self.class_num = class_num;
                
                assertex( isdefined( self.custom_class[class_num]["primary"] ), "Custom class "+class_num+": primary weapon setting missing" );
                assertex( isdefined( self.custom_class[class_num]["secondary"] ), "Custom class "+class_num+": secondary weapon setting missing" );
                assertex( isdefined( self.custom_class[class_num]["specialty1"] ), "Custom class "+class_num+": specialty1 setting missing" );
                assertex( isdefined( self.custom_class[class_num]["specialty2"] ), "Custom class "+class_num+": specialty2 setting missing" );
                assertex( isdefined( self.custom_class[class_num]["specialty3"] ), "Custom class "+class_num+": specialty3 setting missing" );
                
                // clear of specialty slots, repopulate the current selected class' setup
                self reset_specialty_slots( class_num );
                self get_specialtydata( class_num, "specialty1" );
                self get_specialtydata( class_num, "specialty2" );
                self get_specialtydata( class_num, "specialty3" );
                
                // set re-register perks to code
                self register_perks();
                // at this stage, the specialties are loaded into the correct weapon slots, and special slots
                
                // weapon override for round based gametypes
                // TODO: if they switched to a sidearm, we shouldn't give them that as their primary!
                if ( isDefined( self.pers["weapon"] ) && self.pers["weapon"] != "none" )
                        weapon = self.pers["weapon"];
                else
                        weapon = self.custom_class[class_num]["primary"];
                
                sidearm = self.custom_class[class_num]["secondary"];

                self GiveWeapon( sidearm );
                if ( self cac_hasSpecialty( "specialty_extraammo" ) )
                        self giveMaxAmmo( sidearm );
                        
                // give primary weapon
                primaryWeapon = weapon;
                
                assertex( isdefined( self.custom_class[class_num]["camo_num"] ), "Player's camo skin is not defined, it should be at least initialized to 0" );

                primaryTokens = strtok( primaryWeapon, "_" );
                self.pers["primaryWeapon"] = primaryTokens[0];
                
                self maps\mp\gametypes\_teams::playerModelForWeapon( self.pers["primaryWeapon"] );
                
                self GiveWeapon( weapon, self.custom_class[class_num]["camo_num"] );
                if ( self cac_hasSpecialty( "specialty_extraammo" ) )
                        self giveMaxAmmo( weapon );
                self setSpawnWeapon( weapon );
                
                // give secondary weapon
                
                self SetActionSlot( 1, "nightvision" );
                
                secondaryWeapon = self.custom_class[class_num]["inventory"];
                if ( secondaryWeapon != "" )
                {
                        self GiveWeapon( secondaryWeapon );
                        
                        self setWeaponAmmoOverall( secondaryWeapon, self.custom_class[class_num]["inventory_count"] );
                        
                        self SetActionSlot( 3, "weapon", secondaryWeapon );
                        self SetActionSlot( 4, "" );
                }
                else
                {
                        self SetActionSlot( 3, "altMode" );
                        self SetActionSlot( 4, "" );
                }
                
                // give frag for all no matter what
                grenadeTypePrimary = self.custom_class[class_num]["grenades"];
                if ( grenadeTypePrimary != "" )
                {
                        grenadeCount = self.custom_class[class_num]["grenades_count"];
        
                        self GiveWeapon( grenadeTypePrimary );
                        self SetWeaponAmmoClip( grenadeTypePrimary, grenadeCount );
                        self SwitchToOffhand( grenadeTypePrimary );
                }
                
                // give special grenade
                grenadeTypeSecondary = self.custom_class[class_num]["specialgrenades"];
                if ( grenadeTypeSecondary != "" )
                {
                        grenadeCount = self.custom_class[class_num]["specialgrenades_count"];
        
                        if ( grenadeTypeSecondary == level.weapons["flash"])
                                self setOffhandSecondaryClass("flash");
                        else
                                self setOffhandSecondaryClass("smoke");
                        
                        self giveWeapon( grenadeTypeSecondary );
                        self SetWeaponAmmoClip( grenadeTypeSecondary, grenadeCount );
                }
                
                self thread logClassChoice( class, primaryWeapon, grenadeTypeSecondary, self.specialty );
        }
        else
        {      
                // ============= selected one of the default classes ==============
                                
                // load the selected default class's specialties
                assertex( isdefined(self.pers["class"]), "Player during spawn and loadout got no class!" );
                selected_class = self.pers["class"];
                specialty_size = level.default_perk[selected_class].size;
                
                for( i = 0; i < specialty_size; i++ )
                {
                        if( isdefined( level.default_perk[selected_class][i] ) && level.default_perk[selected_class][i] != "" )
                                self.specialty[self.specialty.size] = level.default_perk[selected_class][i];
                }
                assertex( isdefined( self.specialty ) && self.specialty.size > 0, "Default class: " + self.pers["class"] + " is missing specialties " );
                
                // re-registering perks to code since perks are cleared after respawn in case if players switch classes
                self register_perks();
                
                // weapon override for round based gametypes
                // TODO: if they switched to a sidearm, we shouldn't give them that as their primary!
                if ( isDefined( self.pers["weapon"] ) && self.pers["weapon"] != "none" )
                        weapon = self.pers["weapon"];
                else
                        weapon = level.classWeapons[team][class][primaryIndex];
                
                sidearm = level.classSidearm[team][class];
                
                self GiveWeapon( sidearm );
                if ( self cac_hasSpecialty( "specialty_extraammo" ) )
                        self giveMaxAmmo( sidearm );

                // give primary weapon
                primaryWeapon = weapon;

                primaryTokens = strtok( primaryWeapon, "_" );
                self.pers["primaryWeapon"] = primaryTokens[0];
                
                if ( self.pers["primaryWeapon"] == "m14" )
                        self.pers["primaryWeapon"] = "m21";
        
                self maps\mp\gametypes\_teams::playerModelForWeapon( self.pers["primaryWeapon"] );              

                self GiveWeapon( weapon );
                if( self cac_hasSpecialty( "specialty_extraammo" ) )
                        self giveMaxAmmo( weapon );
                self setSpawnWeapon( weapon );
                
                // give secondary weapon
                self SetActionSlot( 1, "nightvision" );
        
                secondaryWeapon = level.classItem[team][class]["type"];
                if ( secondaryWeapon != "" )
                {
                        self GiveWeapon( secondaryWeapon );
                        
                        self setWeaponAmmoOverall( secondaryWeapon, level.classItem[team][class]["count"] );
                        
                        self SetActionSlot( 3, "weapon", secondaryWeapon );
                        self SetActionSlot( 4, "" );
                }
                else
                {
                        self SetActionSlot( 3, "altMode" );
                        self SetActionSlot( 4, "" );
                }
                
                grenadeTypePrimary = level.classGrenades[class]["primary"]["type"];
                if ( grenadeTypePrimary != "" )
                {
                        grenadeCount = level.classGrenades[class]["primary"]["count"];
        
                        self GiveWeapon( grenadeTypePrimary );
                        self SetWeaponAmmoClip( grenadeTypePrimary, grenadeCount );
                        self SwitchToOffhand( grenadeTypePrimary );
                }
                
                grenadeTypeSecondary = level.classGrenades[class]["secondary"]["type"];
                if ( grenadeTypeSecondary != "" )
                {
                        grenadeCount = level.classGrenades[class]["secondary"]["count"];
        
                        if ( grenadeTypeSecondary == level.weapons["flash"])
                                self setOffhandSecondaryClass("flash");
                        else
                                self setOffhandSecondaryClass("smoke");
                        
                        self giveWeapon( grenadeTypeSecondary );
                        self SetWeaponAmmoClip( grenadeTypeSecondary, grenadeCount );
                }

                self thread logClassChoice( class, primaryWeapon, grenadeTypeSecondary, self.specialty );
        }

        switch ( weaponClass( primaryWeapon ) )
        {
                case "rifle":
                        self setMoveSpeedScale( 0.95 );
                        break;
                case "pistol":
                        self setMoveSpeedScale( 1.0 );
                        break;
                case "mg":
                        self setMoveSpeedScale( 0.875 );
                        break;
                case "smg":
                        self setMoveSpeedScale( 1.0 );
                        break;
                case "spread":
                        self setMoveSpeedScale( 1.0 );
                        break;
                default:
                        self setMoveSpeedScale( 1.0 );
                        break;
        }
        
        // cac specialties that require loop threads
        self cac_selector();
}
Reply

#5
i meant to store a premade class, i already read that, thanks for melting my head again though.

im guna be here a week :x




could i just set the guns selected to a variable when selected then have them given to me on spawn after a second or something? and give an example?


soz sorta new to this, only been modding a week.
Reply

#6
You can edit classes in the Private Match settings, so you can also edit them with GSC files. I remember Eekhoorn used this for his early cmMOD versions.
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#7
i got it working with variables, thanks guys.
ok i ran into a problem, when i save the variable like this in the menu

if( response == "give_asp" )
{
self thread takepistols();
self giveWeapon( "asp_mp" );
self switchToWeapon( "asp_mp" );
level.pistol = "asp_mp";
}


then on spawn i have...

if( level.pistol != undefined) {
self thread takepistols();
self giveweapon( level.pistol );
self switchtoweapon( level.pistol );
}

It seems to only store it if i die, like run off and kill myself, though, if the round switches in SND the variable is no longer stored, why is that?
Reply

#8
else if( response == "give_asp" )
{
self thread takepistols();
self giveWeapon( "asp_mp" );
self switchToWeapon( "asp_mp" );
self.pers["mod_pistol"] = "asp_mp";
}

then use
Code:
self giveWeapon( self.pers["mod_pistol"] );
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#9
thanks.. ill try it out..
Reply

#10
If it doesn't work, then try this:

Code:
game["mod_pistol"] = "asp_mp";

Otherwise

Code:
setDvar( "mod_pistol", "asp_mp" );

Code:
self giveWeapon( getDvar( "mod_pistol" ) );
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help Mw2 weapon skin question FroxIVx4 1 2,953 10-13-2013, 16:54
Last Post: hmann
Question Help Weapon Name iRoNinja 8 6,594 10-08-2013, 08:31
Last Post: iRoNinja
  Mw2 weapon porting? Cuddlyedits 3 4,739 09-15-2013, 16:43
Last Post: DidUknowiPwn
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 33,315 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
Exclamation [Request] Random Weapon At Spawn Scripts18 3 4,743 07-27-2013, 23:53
Last Post: DidUknowiPwn
  Help Spawn Message Playing on Respawn? Killjoy 7 5,235 07-11-2013, 14:53
Last Post: Killjoy
  Help Mw2 weapon skin question FroxIVx4 1 2,923 07-06-2013, 19:22
Last Post: surtek
  [Release] Spawn Polygons and Pyramids Yamato 6 4,621 06-20-2013, 12:30
Last Post: Yamato
  Question on how to "Spawn" a flying rocket as a player? akillj 8 5,548 06-04-2013, 01:54
Last Post: rotceh_dnih
  [Request] List of all weapon models DidUknowiPwn 3 4,631 04-20-2013, 09:13
Last Post: Dominator56

Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.