Page 1 of 1

Sleep function won't work

Posted: 20 Jan 2016, 18:46
by nisan
Hi all !
I have altered a script and its all working expect the delay part.
Shortly, I need it to delay the whole script when key 2 or 3 are pressed once, for 4 seconds.
Thing is it does not delay, however it does enter startdelay() function when pressed.

Help would be appreciated !

Thanks!

Code: Select all

#NoEnv
SendMode Input

_norecoil := true ;

F3::ExitApp ; 	
F4::_norecoil := ! _norecoil 
~2::startdelay()
~3::startdelay()

startdelay()
{
_norecoil := false ;
Sleep, 4000
_norecoil := true 
}

~LButton::startloop() 	

startloop()
{
	
 
		Loop
	global _norecoil
	global _weapon
	
	if _norecoil
	{
		
		if GetKeyState("LButton", "P")
			{ 
				SendInput {WheelDown}
				SendInput {LButton DownTemp}
				Sleep 1
				SendInput {LButton Up}
				Sleep 125				
			}
			else
			{
				break ;
			}
		
		
	}
}


	

Re: Sleep function won't work

Posted: 21 Jan 2016, 07:51
by evilC
_norecoil is used inside startdelay, but you do not have global _norecoil inside startdelay, so startdelay is using a local version of _norecoil

Re: Sleep function won't work

Posted: 21 Jan 2016, 08:30
by nisan
Thanks I will try and let you know.

Re: Sleep function won't work

Posted: 21 Jan 2016, 20:18
by nisan
Hi !
I have tried what you are saying and it now changes the var.

But, it does not change it back IN-GAME. only when im on desktop.

Code: Select all

#NoEnv
SendMode Input

_norecoil := true ;

F3::ExitApp ; 	
F4::_norecoil := ! _norecoil 
~2::startdelay2()
~3::startdelay3()

startdelay2()
{
	global _norecoil
	_norecoil := false ;
	Sleep, 4000
	_norecoil := true ;
	Return
}
startdelay3()
{
	global _norecoil
	_norecoil := false ;
	Sleep, 2000
	_norecoil := true ;
	Return
}
~LButton::startloop() 	

startloop()
{
	
 
		Loop
	global _norecoil
	global _weapon
	
	if _norecoil
	{
		
		if GetKeyState("LButton", "P")
			{ 
				SendInput {WheelDown}
				SendInput {LButton DownTemp}
				Sleep 1
				SendInput {LButton Up}
				Sleep 125				
			}
			else
			{
				break ;
			}
		
		
	}
}


	

Re: Sleep function won't work

Posted: 22 Jan 2016, 14:29
by nisan
Please help me