Any one can make a tutorial on how to make a toggle on/off?
|
Request How We Make A Toggle?
|
(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
07-25-2011, 14:46
(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? 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
07-25-2011, 15:18
Instead of [Tutorial] choose [Request].
07-25-2011, 15:22
(This post was last modified: 07-25-2011, 15:23 by Madnesslink5.)
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.
07-25-2011, 17:08
(07-25-2011, 15:22)Madnesslink5 Wrote: but how I desactivate after?
07-25-2011, 17:18
where do you need to add these lines, just in _rank.gsc beneath OnPlayerSpawn?
07-25-2011, 17:50
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.
07-25-2011, 19:27
^to the above, it does work. Took the code out of my mod
|
| Possibly Related Threads… | |||||
| Thread | Author | Replies | Views | Last Post | |
| Make area detect. flag Teleport | lewisbibo | 4 | 6,723 |
10-12-2013, 18:10 Last Post: EnVi Sweden Rocks |
|
|
|
Make Platforme | lewisbibo | 5 | 7,033 |
10-08-2013, 14:35 Last Post: 8q4s8 |
| Make obj MW3.by lewisbibo | lewisbibo | 3 | 4,988 |
10-05-2013, 20:16 Last Post: Nekochan |
|
| Make obj MW3.by lewisbibo | lewisbibo | 0 | 3,280 |
10-03-2013, 20:19 Last Post: lewisbibo |
|
| Help need help?how to make plugins code | hXnarutoXone | 12 | 11,725 |
09-01-2013, 18:30 Last Post: Bandarigoda123 |
|
| Help Make ac130 shoot custom bullets | Ra3shed | 0 | 3,646 |
07-23-2013, 13:02 Last Post: Ra3shed |
|
| how to make a plugin (mod) | E-losev | 5 | 5,987 |
07-12-2013, 15:48 Last Post: OzonE |
|
| [Release] Make Trees Fall | Yamato | 8 | 14,453 |
06-15-2013, 11:45 Last Post: xfxtroll |
|
| How to make superjump mod TDM sniper | hipperz | 4 | 5,451 |
03-28-2013, 15:09 Last Post: hillbilly |
|
| Help Make Waypoint | FaiR_PLaY | 10 | 8,774 |
02-12-2013, 13:09 Last Post: archit |
|
| Users browsing this thread: |
| 1 Guest(s) |


