What's new

Discussion [Code] Nightvision Toggle

  • Thread starter Data Overload
  • Start date
  • Views 3,221
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
I've been searching for this code for a while and now I've found it. In the class.gsc section scroll down to the area where it says:
Code:
self _SetActionSlot( 1, "" )
Add nightvision inbetween the quotations like so:
Code:
self _SetActionSlot( 1, "nightvision" )
Add this to the on screen instructions:
Code:
displayInstruct = self createFontString( "+actionslot 1", 1.5 );
displayInstruct setPoint( "TOPRIGHT", "TOPRIGHT",0, 72+260);
Then you will also want to add a destroy function after you use it or after death.
Code:
displayInstruct destroy();
*Thanks To Crazy Fairy Hopn for The Code Fix

For all the leechers who don't know actionslot 1 is up on the D-Pad...

I've highlighted where it is in class.gsc cause it's kind of secluded :smile:

giveLoadout( team, class, allowCopycat )
{
self takeAllWeapons();

primaryIndex = 0;

self.specialty = [];

if ( !isDefined( allowCopycat ) )
allowCopycat = true;

primaryWeapon = undefined;

if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
{
self maps\mp\gametypes\_class::confused:etClass( "copycat" );
self.class_num = getClassIndex( "copycat" );

clonedLoadout = self.pers["copyCatLoadout"];

loadoutPrimary = clonedLoadout["loadoutPrimary"];
loadoutPrimaryAttachment = clonedLoadout["loadoutPrimaryAttachment"];
loadoutPrimaryAttachment2 = clonedLoadout["loadoutPrimaryAttachment2"] ;
loadoutPrimaryCamo = clonedLoadout["loadoutPrimaryCamo"];
loadoutSecondary = clonedLoadout["loadoutSecondary"];
loadoutSecondaryAttachment = clonedLoadout["loadoutSecondaryAttachment"];
loadoutSecondaryAttachment2 = clonedLoadout["loadoutSecondaryAttachment2"];
loadoutSecondaryCamo = clonedLoadout["loadoutSecondaryCamo"];
loadoutEquipment = clonedLoadout["loadoutEquipment"];
loadoutPerk1 = clonedLoadout["loadoutPerk1"];
loadoutPerk2 = clonedLoadout["loadoutPerk2"];
loadoutPerk3 = clonedLoadout["loadoutPerk3"];
loadoutOffhand = clonedLoadout["loadoutOffhand"];
loadoutDeathStreak = "specialty_copycat";
}
else if ( isSubstr( class, "custom" ) )
{
class_num = getClassIndex( class );
self.class_num = class_num;

loadoutPrimary = cac_getWeapon( class_num, 0 );
loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
loadoutSecondary = cac_getWeapon( class_num, 1 );
loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
loadoutEquipment = cac_getPerk( class_num, 0 );
loadoutPerk1 = cac_getPerk( class_num, 1 );
loadoutPerk2 = cac_getPerk( class_num, 2 );
loadoutPerk3 = cac_getPerk( class_num, 3 );
loadoutOffhand = cac_getOffhand( class_num );
loadoutDeathStreak = cac_getDeathstreak( class_num );
}
else
{
class_num = getClassIndex( class );
self.class_num = class_num;

loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1 , 0);
loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
loadoutOffhand = table_getOffhand( level.classTableName, class_num );
loadoutDeathstreak = table_getDeathstreak( level.classTableName, class_num );
}

if ( level.killstreakRewards )
{
loadoutKillstreak1 = self getPlayerData( "killstreaks", 0 );
loadoutKillstreak2 = self getPlayerData( "killstreaks", 1 );
loadoutKillstreak3 = self getPlayerData( "killstreaks", 2 );
}
else
{
loadoutKillstreak1 = "none";
loadoutKillstreak2 = "none";
loadoutKillstreak3 = "none";
}

secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
self _giveWeapon( secondaryName, int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );

self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
self.loadoutPrimary = loadoutPrimary;
self.loadoutSecondary = loadoutSecondary;
self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));

self SetOffhandPrimaryClass( "other" );

self _SetActionSlot( 1, "nightvision" );
self _SetActionSlot( 3, "altMode" );
self _SetActionSlot( 4, "" );


self _clearPerks();
self _detachAll();

Edit Oct 2nd-Here's exactly what the icon looks like
nightvisionk.jpg
 
W

Wafflespro

Enthusiast
Messages
78
Reaction score
15
Points
55
Sin$
7
Or you could do this:

Code:
toggle()
{
for(;;)
{
self waittill("dpad_right");
self VisionSetNakedForPlayer( "nightvision", 5 );
self waittill("dpad_right");
self VisionSetNakedForPlayer( "default", 5 );
}
}
 
KRiMiNAL

KRiMiNAL

Enthusiast
Messages
930
Reaction score
117
Points
165
Sin$
0
Or you could do this:

Code:
toggle()
{
for(;;)
{
self waittill("dpad_right");
self VisionSetNakedForPlayer( "nightvision", 5 );
self waittill("dpad_right");
self VisionSetNakedForPlayer( "default", 5 );
}
}

This. ^^
 
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
Or you could do this:

Code:
toggle()
{
for(;;)
{
self waittill("dpad_right");
self VisionSetNakedForPlayer( "nightvision", 5 );
self waittill("dpad_right");
self VisionSetNakedForPlayer( "default", 5 );
}
}

That is good too but my code is shorter :tongue: Missions gets crowded sometimes easier just to hide in class.gsc :wink: Thanks for the advice, but you still need to add the instruction.
 
W

Wafflespro

Enthusiast
Messages
78
Reaction score
15
Points
55
Sin$
7
no you dont and you can still put it in the class gsc, stop trying to sound smart

#include maps/mp/gametypes/_class.gsc

put that at the top of missions and you can use it like normal
 
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
no you dont and you can still put it in the class gsc, stop trying to sound smart

#include maps/mp/gametypes/_class.gsc

put that at the top of missions and you can use it like normal

Okay thanks...Btw when did you make your account? Yesterday?
 
N

Nickelodeon

Enthusiast
Messages
944
Reaction score
169
Points
125
Sin$
7

It's not the same thing

This had been posted at least 3 times.

I've been searching for this code for a while and now I've found it. In the class.gsc section scroll down to the area where it says:
Code:
says self _SetActionSlot( 1, "" )
Add nightvision inbetween the quotations like so:
Code:
says self _SetActionSlot( 1, "nightvision" )
Then under the instruction section type something similar to this where you want:
Code:
displayButton setText("[{+actionslot 1}]  ");
displayInstruct setText("TO ACTIVATE ^3NIGHT VISION");
wait 3.5;
For all the leechers who don't know actionslot 1 is up on the D-Pad...

I've highlighted where it is in class.gsc cause it's kind of secluded :smile:

giveLoadout( team, class, allowCopycat )
{
self takeAllWeapons();

primaryIndex = 0;

self.specialty = [];

if ( !isDefined( allowCopycat ) )
allowCopycat = true;

primaryWeapon = undefined;

if ( isDefined( self.pers["copyCatLoadout"] ) && self.pers["copyCatLoadout"]["inUse"] && allowCopycat )
{
self maps\mp\gametypes\_class::confused:etClass( "copycat" );
self.class_num = getClassIndex( "copycat" );

clonedLoadout = self.pers["copyCatLoadout"];

loadoutPrimary = clonedLoadout["loadoutPrimary"];
loadoutPrimaryAttachment = clonedLoadout["loadoutPrimaryAttachment"];
loadoutPrimaryAttachment2 = clonedLoadout["loadoutPrimaryAttachment2"] ;
loadoutPrimaryCamo = clonedLoadout["loadoutPrimaryCamo"];
loadoutSecondary = clonedLoadout["loadoutSecondary"];
loadoutSecondaryAttachment = clonedLoadout["loadoutSecondaryAttachment"];
loadoutSecondaryAttachment2 = clonedLoadout["loadoutSecondaryAttachment2"];
loadoutSecondaryCamo = clonedLoadout["loadoutSecondaryCamo"];
loadoutEquipment = clonedLoadout["loadoutEquipment"];
loadoutPerk1 = clonedLoadout["loadoutPerk1"];
loadoutPerk2 = clonedLoadout["loadoutPerk2"];
loadoutPerk3 = clonedLoadout["loadoutPerk3"];
loadoutOffhand = clonedLoadout["loadoutOffhand"];
loadoutDeathStreak = "specialty_copycat";
}
else if ( isSubstr( class, "custom" ) )
{
class_num = getClassIndex( class );
self.class_num = class_num;

loadoutPrimary = cac_getWeapon( class_num, 0 );
loadoutPrimaryAttachment = cac_getWeaponAttachment( class_num, 0 );
loadoutPrimaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 0 );
loadoutPrimaryCamo = cac_getWeaponCamo( class_num, 0 );
loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
loadoutSecondary = cac_getWeapon( class_num, 1 );
loadoutSecondaryAttachment = cac_getWeaponAttachment( class_num, 1 );
loadoutSecondaryAttachment2 = cac_getWeaponAttachmentTwo( class_num, 1 );
loadoutSecondaryCamo = cac_getWeaponCamo( class_num, 1 );
loadoutEquipment = cac_getPerk( class_num, 0 );
loadoutPerk1 = cac_getPerk( class_num, 1 );
loadoutPerk2 = cac_getPerk( class_num, 2 );
loadoutPerk3 = cac_getPerk( class_num, 3 );
loadoutOffhand = cac_getOffhand( class_num );
loadoutDeathStreak = cac_getDeathstreak( class_num );
}
else
{
class_num = getClassIndex( class );
self.class_num = class_num;

loadoutPrimary = table_getWeapon( level.classTableName, class_num, 0 );
loadoutPrimaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 0 , 0);
loadoutPrimaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 0, 1 );
loadoutPrimaryCamo = table_getWeaponCamo( level.classTableName, class_num, 0 );
loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
loadoutSecondary = table_getWeapon( level.classTableName, class_num, 1 );
loadoutSecondaryAttachment = table_getWeaponAttachment( level.classTableName, class_num, 1 , 0);
loadoutSecondaryAttachment2 = table_getWeaponAttachment( level.classTableName, class_num, 1, 1 );;
loadoutSecondaryCamo = table_getWeaponCamo( level.classTableName, class_num, 1 );
loadoutEquipment = table_getEquipment( level.classTableName, class_num, 0 );
loadoutPerk1 = table_getPerk( level.classTableName, class_num, 1 );
loadoutPerk2 = table_getPerk( level.classTableName, class_num, 2 );
loadoutPerk3 = table_getPerk( level.classTableName, class_num, 3 );
loadoutOffhand = table_getOffhand( level.classTableName, class_num );
loadoutDeathstreak = table_getDeathstreak( level.classTableName, class_num );
}

if ( level.killstreakRewards )
{
loadoutKillstreak1 = self getPlayerData( "killstreaks", 0 );
loadoutKillstreak2 = self getPlayerData( "killstreaks", 1 );
loadoutKillstreak3 = self getPlayerData( "killstreaks", 2 );
}
else
{
loadoutKillstreak1 = "none";
loadoutKillstreak2 = "none";
loadoutKillstreak3 = "none";
}

secondaryName = buildWeaponName( loadoutSecondary, loadoutSecondaryAttachment, loadoutSecondaryAttachment2 );
self _giveWeapon( secondaryName, int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ) ) );

self.loadoutPrimaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutPrimaryCamo, 0 ));
self.loadoutPrimary = loadoutPrimary;
self.loadoutSecondary = loadoutSecondary;
self.loadoutSecondaryCamo = int(tableLookup( "mp/camoTable.csv", 1, loadoutSecondaryCamo, 0 ));

self SetOffhandPrimaryClass( "other" );

self _SetActionSlot( 1, "nightvision" );
self _SetActionSlot( 3, "altMode" );
self _SetActionSlot( 4, "" );


self _clearPerks();
self _detachAll();
 
G

george777

Enthusiast
Messages
182
Reaction score
8
Points
70
Sin$
0
this is old i have has this for over 3-4 months u need to search
 
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
This is different then just adding toggle bit. By putting Nightvision in the class section an actual Nightvision icon will show up.
 
Inspired

Inspired

Enthusiast
Messages
508
Reaction score
94
Points
95
Sin$
0
I'm not being rude, but this has been posted so many times before.
 
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
This is from like 2 weeks ago why bump it especially when this thread is a fail?

Thanks for the advice man but I really don't need yours lol. Would prefer some constructive critism in anything, but I guess you don't really have anything to offer seeing as most of your posts are degrading and have nothing to do with the thread itself. Boosting your post count up by saying threads are a fail is kind of dumb as well -.-
 
CrAzY FaIrYHoPn

CrAzY FaIrYHoPn

FairyHopn' All Day
Retired
Grammar Nazi TotM MotM
Messages
3,449
Reaction score
1,909
Points
770
Sin$
0
I hope you guys realize that none of your codes will work. Data, your set text is binded to "displayInstruct", so you need to include that font string like so:
Code:
displayInstruct = self createFontString( "objective", 1.5 );
displayInstruct setPoint( "TOPRIGHT", "TOPRIGHT",0, 72+260);
Then you will also want to add a destroy function after you use it or after death.
Code:
displayInstruct destroy();

And waffles, yyour code doesn't include the notifyoncommand before the waittill:
Code:
self notifyOnPlayerCommand( "dpad_right", "+actionslot 4" );
 
Data Overload

Data Overload

VIP
VIP
Retired
Messages
3,428
Reaction score
1,025
Points
570
Sin$
0
I hope you guys realize that none of your codes will work. Data, your set text is binded to "displayInstruct", so you need to include that font string like so:
Code:
displayInstruct = self createFontString( "objective", 1.5 );
displayInstruct setPoint( "TOPRIGHT", "TOPRIGHT",0, 72+260);
Then you will also want to add a destroy function after you use it or after death.
Code:
displayInstruct destroy();

And waffles, yyour code doesn't include the notifyoncommand before the waittill:
Code:
self notifyOnPlayerCommand( "dpad_right", "+actionslot 4" );

Fixed it thanks for that and can u test to make sure it works? There should be a Nightvision icon if u remember from Cod4 =)
 
Top Bottom
Login
Register