Posts: 474
Threads: 67
Joined: May 2011
Reputation:
11
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?
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
07-05-2011, 08:43
(This post was last modified: 07-05-2011, 08:44 by Pozzuh.)
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: pawnPlayer() giveloadout get's called. Try to edit that...
Posts: 474
Threads: 67
Joined: May 2011
Reputation:
11
07-05-2011, 10:33
(This post was last modified: 07-05-2011, 10:37 by koil.)
could you give an example of how giveloadout works? ive never heard of it before & cant find crap on google
Posts: 6,052
Threads: 429
Joined: Oct 2010
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();
}
Posts: 474
Threads: 67
Joined: May 2011
Reputation:
11
07-05-2011, 11:19
(This post was last modified: 07-05-2011, 11:20 by koil.)
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.
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
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.
Posts: 474
Threads: 67
Joined: May 2011
Reputation:
11
07-05-2011, 11:55
(This post was last modified: 07-05-2011, 12:25 by koil.)
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?
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
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"] );
Posts: 474
Threads: 67
Joined: May 2011
Reputation:
11
thanks.. ill try it out..
Posts: 1,830
Threads: 104
Joined: Jan 2011
Reputation:
46
07-05-2011, 12:30
(This post was last modified: 07-05-2011, 12:30 by iAegle.)
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" ) );
|