Jump to content

Need help with Loops


Snake0391

Recommended Posts

Hi, I'm trying to create a loop using Label and goto but the game crashes everytime I try. how do I fix this, I just want to create a basic loop. The code works fine except when I add the loop.

 

here is my code for my script:

scn SxSTheThingMainScript

; Coded by Snake0391 on 1/1/2010
ref Target
short KeyInit
short InitMessage
short InvalidKey
short InvalidMouseKey
short Continue
short Type

long BindKey

ref LoopTarget

begin GameMode

if (KeyInit == 0)
	if (InitMessage == 0)
		ShowMessage SxSInitMessage
		Set InitMessage to 1
	endif
	Set InvalidKey to GetControl 5
	Set InvalidMouseKey to GetControl 4
	Set BindKey to GetKeyPress 0
;Set BindMouseKey to GetMouseButtonPress 0
	if (BindKey == InvalidKey)
		ShowMessage SxSInvalidKeyMessage
		Set InitMessage to 0
		Set Continue to 0
	else
		Set Continue to 1
	endif
	if (BindKey > 0)
		if (Continue == 1)
			ShowMessage SxSInitDoneMessage
			Set KeyInit to 1
		endif
;else if (BindMouseKey > 0)
	;if (Continue == 1)
		;ShowMessage SxSInitDoneMessage
		;Set KeyInit to 1
	;endif
	endif
endif





set Target to GetCrossHairRef
if (IsKeyPressed BindKey)
if (Target)
	Set Type to GetType Target
	if (Type == 42)
	Set LoopTarget to GetFirstRef 42
	Label 25
	if (LoopTarget);&& LoopTarget.GetInFaction FollowerFaction == 0 && LoopTarget.GetInFaction TeamMateFaction == 0 && LoopTarget.GetInFaction PlayerFaction == 0)
		if (LoopTarget.GetDisabled == 0)		
			if (LoopTarget.GetDead == 0)	
				if (LoopTarget != Target)
					if (LoopTarget.GetLOS Player)
						LoopTarget.SetDisposition Player -100
					endif
				endif
			endif
		endif
	endif
	Set LoopTarget to GetNextRef
		Goto 25
end

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...