Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. I need a function for my script, which turns a certain action on and off when pressing a button

I need a function for my script, which turns a certain action on and off when pressing a button

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
5 Posts 2 Posters 199 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • alejandrodarzundefined Offline
    alejandrodarzundefined Offline
    alejandrodarz
    wrote on last edited by
    #1

    This is my script, as you can see I had to put the same function by directing buttons one to turn on and another to turn it off because I don't know what I should do to use only one button, join my script in 1 only and it will turn on when press a button and pressing that button again turns it off.

    NightVisionON()

    {

    self endon("disconnect");
    
    self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado");
    
    
    for(;;)
    
    {
    
    	if(self actionslotfourbuttonpressed())
    
    	{
    
    	self setinfraredvision(true);
    
        }
    	
    wait 0.01;
    	
    }
    

    }

    NightVisionOFF()

    {

    self endon("disconnect");
    
    
    for(;;)
    
    {
    
    	if(self  actionslotonebuttonpressed())
    
    	{
    
    	self setinfraredvision(false);
    
        }
    	
    wait 0.01;
    	
    }
    

    }

    Cahzundefined 1 Reply Last reply
    0
    • Cahzundefined Offline
      Cahzundefined Offline
      Cahz VIP
      replied to alejandrodarz on last edited by
      #2

      alejandrodarz

      NightVisionToggle()
      {
      	level endon("game_ended");
      	self endon("disconnect");
      	self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado");
      	for(;;)
      	{
      		if(self actionslotfourbuttonpressed())
      		{
      			if (!isDefined(self.nightvision))
      			{
      				self.nightvision = true;
      				self setinfraredvision(true);
      			}
      			else
      			{
      				self.nightvision = undefined;
      				self setinfraredvision(false);
      			}
          	        }
      		wait 0.05;
      	}
      }
      

      using the isDefined(variable) you can create a variable on the player and use that as the check for the toggle. Hopefully this makes sense

      alejandrodarzundefined 2 Replies Last reply
      0
      • alejandrodarzundefined Offline
        alejandrodarzundefined Offline
        alejandrodarz
        replied to Cahz on last edited by
        #3

        Cahz I speak Spanish and when translating it I understood something like

        if(isdefined(self setinfraredvision))
            if(self actionslotonebuttonpressed())
        	{
                self setinfraredvision(false);
            }
        
        1 Reply Last reply
        0
        • alejandrodarzundefined Offline
          alejandrodarzundefined Offline
          alejandrodarz
          replied to Cahz on last edited by
          #4

          Cahz Thank you very much for helping me again, very kind of you. I already did it, I am going to leave the code here in case someone is interested or is looking for the same goal as me.

          1 Reply Last reply
          0
          • alejandrodarzundefined Offline
            alejandrodarzundefined Offline
            alejandrodarz
            wrote on last edited by
            #5

            Remember call night vision

            NightVision()

            {

            self endon("disconnect");
            
            self iprintlnbold("^2Presiona [{+actionslot 4}] para activar visión de Infectado");
            
            
            for(;;)
            
            {
            
            	if(self actionslotfourbuttonpressed())
                
            	{
            
            	self InfraredVision();
            
                }
            	
            wait 0.01;
            	
            }
            

            }

            InfraredVision()
            {
            if (!IsDefined(self.InfraredVision))
            {
            self.InfraredVision = true;
            self setinfraredvision(true);
            self IPrintLn("InfraredVision: ^2Enabled");
            }
            else
            {
            self.InfraredVision = undefined;
            self setinfraredvision(false);
            self IPrintLn("InfraredVision: ^1Disabled");
            }
            }

            1 Reply Last reply
            0

            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Donate