Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request How We Make A Toggle?
#1
Any one can make a tutorial on how to make a toggle on/off?
Reply

#2
(07-25-2011, 14:25)Scripts18 Wrote: Any one can make a tutorial on how to make a toggle on/off?

Something like

Code:
Trigger_function()
{
      trigger.is.on = 0
      if usebuttonpressed() && trigger.is.on = 0
      {
            //do stuff here
            trigger.is.on = 1
      }
      else if usebuttonpressed() && trigger.is.on = 1
      {
            // do stuff
            trigger.is.on = 0
      }

Should look something like this, but thats definately wrong because i dont know the right comments atm, but it should be something similiar to this Big Grin
Reply

#3
(07-25-2011, 14:34)prisma Wrote:
(07-25-2011, 14:25)Scripts18 Wrote: Any one can make a tutorial on how to make a toggle on/off?

Something like

Code:
Trigger_function()
{
      trigger.is.on = 0
      if usebuttonpressed() && trigger.is.on = 0
      {
            //do stuff here
            trigger.is.on = 1
      }
      else if usebuttonpressed() && trigger.is.on = 1
      {
            // do stuff
            trigger.is.on = 0
      }

Should look something like this, but thats definately wrong because i dont know the right comments atm, but it should be something similiar to this Big Grin

thx but any one can show me a working toggle so I can learn from it :S
I learn easier when I look at a working one
Reply

#4
Instead of [Tutorial] choose [Request].
Reply

#5
PHP Code:
ThirdPerson()
{
    
self setClientDvar("cg_thirdpersonRange"150);
    
self setClientDvar("cg_thirdpersonAngle"356);

    if(
self.thirdperson == "off")
    {
        
self setClientDvar("cg_thirdperson"1);
        
self.thirdperson "on";
    
    }
    else
    {
        
self setClientDvar("cg_thirdperson"0);
        
self.thirdperson "off";
    }


Just call this function whenever you need the toggle to be activated.
Reply

#6
(07-25-2011, 15:22)Madnesslink5 Wrote:
PHP Code:
ThirdPerson()
{
    
self setClientDvar("cg_thirdpersonRange"150);
    
self setClientDvar("cg_thirdpersonAngle"356);

    if(
self.thirdperson == "off")
    {
        
self setClientDvar("cg_thirdperson"1);
        
self.thirdperson "on";
    
    }
    else
    {
        
self setClientDvar("cg_thirdperson"0);
        
self.thirdperson "off";
    }


Just call this function whenever you need the toggle to be activated.

but how I desactivate after?
Reply

#7
where do you need to add these lines, just in _rank.gsc beneath OnPlayerSpawn?
Reply

#8
(07-25-2011, 17:18)Kipiop Wrote: where do you need to add these lines, just in _rank.gsc beneath OnPlayerSpawn?

:S Im asking for a tutorial
Reply

#9
add to init

Code:
//set the variable so it doesnt error when we want to use it.
self.thirdperson = 0;

add to on spawned


Code:
//start the thread
self thread thirdperson();

//print the keybind we are using
self iPrintLn("^8Press ^7 [{+actionslot 3}] ^8 to toggle third person!");


Add this anywhere in ur on spawned file

Code:
ThirdPerson()
{
    self endon ( "death" );

//begin loop til you die
    while( true )
    {
//wait a while so it doesnt freeze up as an endless loop
        wait 0.08;
//designate a key to be pushed
        if( self ActionSlotThreeButtonPressed() )
        {
//setting dvars that dont matter no matter what we toggle
    self setClientDvar("cg_thirdpersonRange", 150);
    self setClientDvar("cg_thirdpersonAngle", 356);

// check iff the dvar is off or on - first time round it will be 0 and skip this.
    if(self.thirdperson == "off")
    {
//our first option in the toggle..
        self setClientDvar("cg_thirdperson", 1);
        self.thirdperson = "on";
    
    }
// set variable to off so next time around it toggles the above option
    else
    {
//our second option in the toggle..
        self setClientDvar("cg_thirdperson", 0);
        self.thirdperson = "off";
    }
  }
}
}


Each time you hit action slot 3, what ever its bound to which will display when you spawn, it will toggle them(if they are the right dvars).. not sure any of these dvars work in BO its just an example.
Reply

#10
^to the above, it does work. Took the code out of my mod Tongue
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Make area detect. flag Teleport lewisbibo 4 4,994 10-12-2013, 18:10
Last Post: EnVi Sweden Rocks
Wink Make Platforme lewisbibo 5 4,992 10-08-2013, 14:35
Last Post: 8q4s8
  Make obj MW3.by lewisbibo lewisbibo 3 3,702 10-05-2013, 20:16
Last Post: Nekochan
  Make obj MW3.by lewisbibo lewisbibo 0 2,333 10-03-2013, 20:19
Last Post: lewisbibo
  Help need help?how to make plugins code hXnarutoXone 12 8,552 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Make ac130 shoot custom bullets Ra3shed 0 2,731 07-23-2013, 13:02
Last Post: Ra3shed
  how to make a plugin (mod) E-losev 5 4,332 07-12-2013, 15:48
Last Post: OzonE
  [Release] Make Trees Fall Yamato 8 12,296 06-15-2013, 11:45
Last Post: xfxtroll
  How to make superjump mod TDM sniper hipperz 4 3,976 03-28-2013, 15:09
Last Post: hillbilly
  Help Make Waypoint FaiR_PLaY 10 6,362 02-12-2013, 13:09
Last Post: archit

Forum Jump:


Users browsing this thread:
3 Guest(s)

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