What's new

Discussion [Code] Nightvision Toggle

  • Thread starter Data Overload
  • Start date
  • Views 2,810
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
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
 
U

-Unrated

Enthusiast
Messages
275
Reaction score
22
Thanks, I'm gonna have to try this :o
 
P

Party

Party Animal
Messages
100
Reaction score
14
Nice... Im about to try it out. :smile:
 
W

Wafflespro

Enthusiast
Messages
78
Reaction score
15
Or you could do this:

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

KRiMiNAL

Enthusiast
Messages
930
Reaction score
117
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. ^^
 
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
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
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
 
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
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

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
this is old i have has this for over 3-4 months u need to search
 
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
This is different then just adding toggle bit. By putting Nightvision in the class section an actual Nightvision icon will show up.
 
I

Inspired

Enthusiast
Messages
509
Reaction score
93
I'm not being rude, but this has been posted so many times before.
 
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
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 -.-
 
K

KieranxX

Enthusiast
Messages
599
Reaction score
64
Thanks Mate Im Gonna Do This
 
C

CrAzY FaIrYHoPn

FairyHopn' All Day
Retired
Messages
3,452
Reaction score
1,907
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" );
 
D

Data Overload

VIP
VIP
Retired
Messages
3,432
Reaction score
1,023
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