Jump to content

Change headgear at certain time of day?


blazeda59

Recommended Posts

Ok Im working on a new companion as part of my mod. All the basic stuff is working ie wait, follow, firing, inventory and so on now Im trying to add some extra stuff to her. Im trying to set up her head gear to swap at certain times of day ie shades during the day and NVG at night. I can get it to swap to the NVG at 8:00pm but for some reason they wont change back to the shades when it gets to 9:00am. As far as I can tell the code should be right but it just wont work. Can someone please tell me what Im doing wrong? heres my code.

 

begin GameMode

if Time
	if GetCurrentTime < 20.0 || GetCurrentTime > 9.0
		SinfulCarlaREF.EquipItem SinfulSpecOpsGlasses 0 1
		SinfulCarlaREF.UnEquipItem SinfulSpecOpsCarlaNVG 0 1
	endif
endif

else
	
	if GetCurrentTime > 20.0 || GetCurrentTime < 9.0
		SinfulCarlaREF.EquipItem SinfulSpecOpsCarlaNVG 0 1
		SinfulCarlaREF.UnEquipItem SinfulSpecOpsGlasses 0 1
	endif
endif

Link to comment
Share on other sites

Your code has several problems. I am not familiar with "time" as a separate variable. If that is your variable, give it a more specific name. If there is some game variable you are using, I can't find one with that name.

 

Also, you should check something like cipscis tutorials to understand better about nested if statements. I am a little surprised the geck will let you save this. You have if ... endif ... else, which should not be legal. Remove the else which is on a line by itself. The indentation does not matter to the game, but move the block under that one tabstop left, and it will be more obvious. I think once the nesting is corrected, any logic error will be more apparent.

Link to comment
Share on other sites

Your code has several problems. I am not familiar with "time" as a separate variable. If that is your variable, give it a more specific name. If there is some game variable you are using, I can't find one with that name.

 

Also, you should check something like cipscis tutorials to understand better about nested if statements. I am a little surprised the geck will let you save this. You have if ... endif ... else, which should not be legal. Remove the else which is on a line by itself. The indentation does not matter to the game, but move the block under that one tabstop left, and it will be more obvious. I think once the nesting is corrected, any logic error will be more apparent.

 

well thats strange coz it is working this is basically the same as the code for the building lights in new vagas the only things that are different are the timer the linked refs and the playgroup stuff which is for the lights animations and so on. But I have made a bit of head way since last night Ive figured out that it is changing the items she has its just not visually updating until I check her inventory or make her change combat style.

 

this is the light code so you can see what Im talking about.

 

begin GameMode

if bLit
	if GetCurrentTime < 20.0 || GetCurrentTime > 23.0 
		;ShowWarning "Light turning off."
		set LinkedLight to GetLinkedRef
		PlayGroup Backward 1
		set bLit to 0
		set bFlicker to 0
		LinkedLight.disable
	elseif bFlicker == 0
		if fTimer < fRandomDelay
			set fTimer to fTimer + GetSecondsPassed
		else
			;ShowWarning "Fully bright and flickering."
			set fTimer to 0
			PlayGroup SpecialIdle 1
			set bFlicker to 1
		endif
	endif

else
	;ShowWarning "Light turning on."
	if GetCurrentTime > 20.0 && GetCurrentTime < 23.0 
		set LinkedLight to GetLinkedRef
		PlayGroup Forward 1 ; Light slowly powers on.
		set bLit to 1
		LinkedLight.enable
		set fRandomDelay to 15 + 10.0/99.0 * GetRandomPercent
	endif
endif

end

Link to comment
Share on other sites

I think you need to narrow down the time range using && instead of ||. Also, you should check if the item is already equipped - especially if the script runs every frame.

 

 

begin GameMode 

if Time 
 if GetCurrentTime < 20.0 && GetCurrentTime > 9.0 
  if (SinfulCarlaREF.GetEquipped SinfulSpecOpsGlasses == 0)
   SinfulCarlaREF.EquipItem SinfulSpecOpsGlasses 0 1 
  endif
  SinfulCarlaREF.UnEquipItem SinfulSpecOpsCarlaNVG 0 1 ;If this uses the same biped slot as the glasses, don't need it.
 else 
  if (SinfulCarlaREF.GetEquipped SinfulSpecOpsCarlaNVG == 0)
   SinfulCarlaREF.EquipItem SinfulSpecOpsCarlaNVG 0 1 
  endif
  SinfulCarlaREF.UnEquipItem SinfulSpecOpsGlasses 0 1  ;If this uses the same biped slot as the NVG, don't need it.
 endif 
endif

end

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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