![]() |
|
[Request] How We Make A Toggle? - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html) +--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html) +--- Thread: [Request] How We Make A Toggle? (/Thread-Request-How-We-Make-A-Toggle.html) |
How We Make A Toggle? - Scripts18 - 07-25-2011 Any one can make a tutorial on how to make a toggle on/off? RE: How We Make A Toggle? - prisma - 07-25-2011 (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
RE: How We Make A Toggle? - Scripts18 - 07-25-2011 (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 RE: How We Make A Toggle? - Lemon - 07-25-2011 Instead of [Tutorial] choose [Request]. RE: How We Make A Toggle? - Madnesslink5 - 07-25-2011 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. RE: How We Make A Toggle? - Scripts18 - 07-25-2011 (07-25-2011, 15:22)Madnesslink5 Wrote: but how I desactivate after? RE: How We Make A Toggle? - Kipiop - 07-25-2011 where do you need to add these lines, just in _rank.gsc beneath OnPlayerSpawn? RE: How We Make A Toggle? - Scripts18 - 07-25-2011 (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 RE: How We Make A Toggle? - koil - 07-25-2011 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. RE: How We Make A Toggle? - Madnesslink5 - 07-25-2011 ^to the above, it does work. Took the code out of my mod
|