Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request How We Make A Toggle?
#11
add to init

Code:
//set the variable so it doesnt error when we want to use it.
setDvar("timescale",0.5);

add to on spawned


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

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


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
       setDvar("timescale",0.5);

// check iff the dvar is off or on - first time round it will be 0 and skip this.
    ifset(Dvar("timescale",0.5);== "off")
    {
//our first option in the toggle..
        setDvar("timescale",0.5);
        setDvar("timescale",0.5);= "on";
    
    }
// set variable to off so next time around it toggles the above option
    else
    {
//our second option in the toggle..
        setDvar("timescale",0.5);
        setDvar("timescale",0.5);= "off";
    }
  }
}
}

Is this the right code to activate slow motion? or did i something wrong?


Reply

#12
its very wrong..

add to init -

Code:
setDvar("timescale",0.5);
self.speed = 0;

if you want people to spawn slow.. or

Code:
setDvar("timescale",1);
self.speed = 0;

If you want them to spawn normal pace.. then.. keep the on spawned part you have there posted.. then delete the old thirdperson alias and use this one..


Code:
TimeScale()
{
    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

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

#13
really awesome +thanks and +rep Big Grin
Reply

#14
When i load a level in my mod (after i changed the timescale toggle),
an error pops up when a level is loaded:
server script compile error
unintaliased variable 'on'
(check console for info)
Huh
Reply

#15
Code:
TimeScale()
{
    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

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


Try that.. also there is no "on" variable in the code so its something else causing it.
Reply

#16
(07-25-2011, 22:03)koil Wrote: its very wrong..

add to init -

This is dumb, in init self is the level, you do know self isn't the player most of the time?


Edit: Here's mine

Code:
toggle3p()
{
    while(isalive(self))
    {
        if(self ActionSlotThreeButtonPressed())
            self setclientdvar("cg_thirdperson",!getdvarint("cg_thirdperson"));
        wait 0.05;
    }
}
Reply

#17
(07-26-2011, 12:22)koil Wrote:
Code:
TimeScale()
{
    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

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


Try that.. also there is no "on" variable in the code so its something else causing it.

it gives no crash anymore, but it doesnt work i cant toggle game speed, does it work by you?
Reply

#18
setDvar("timescale",0.5);

change to

self setMoveSpeedScale(0.5);
self iPrintLn("^8You are.... SLOOOOOOOOOW!");

for slow

setDvar("timescale",1);

to

self setMoveSpeedScale(1);
self iPrintLn("^8You are.... fast!");

for normal speed





also lost, i do it to remove the speed variable being = to nothing and erroring randomly.. it works so w/e..




i just tested and it works for me - might be better dvars for it then that though..
Reply

#19
it doesnt work for me
Reply

#20
Code:
TimeScale()
{
    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

// check if the dvar is off or on - first time round it will be 0 and skip this.
    if(self.speed != 0)
    {
//our first option in the toggle..
self setMoveSpeedScale(0.5);
self iPrintLn("^8You are.... SLOOOOOOOOOW!");
        self.speed = 0;
    
    }
// set variable to off so next time around it toggles the above option
    else
    {
//our second option in the toggle..
       self setMoveSpeedScale(1);
       self iPrintLn("^8You are.... fast!");
        self.speed = 1;
    }
  }
}
}


Does work, i've tested it.
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:
1 Guest(s)

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