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?
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;
}
}
}
}
really awesome +thanks and +rep
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)
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.
(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;
}
}
(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?
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..
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.