Jump to content

Photo

Enable/Disable an NPC

construction set scripting npc

  • Please log in to reply
3 replies to this topic

#1
Crackomint

Crackomint

    Old hand

  • Supporter
  • PipPipPip
  • 563 posts

I'm adding some vendors to the IC Market District. Since I'm super lazy, I want these vendors to simply be disabled at night, and enabled during the day when open for business. I'm a complete dunce when it comes to scripting, but I thought this would be pretty simple. But I can't get it to work right.

 

I have the NPC in game, with the "Initially Disabled" box checked. Here is the script attached to his reference:

scn JFICMarketPriestScript

short doOnce

Begin GameMode
	
	If GameHour >= 8 && GameHour <= 20
		If doOnce == 0
			JFICMarketPriestREF.enable		
			set doOnce to 1
		endIf
	endIf

	If GameHour > 21
		If doOnce == 1
			JFICMarketPriestREF.disable
			set doOnce to 0
		endIf
	endIf			

End

It compiles fine and all, but seems to have no effect. I've tried having the NPC enabled or disabled to start, and he stays in either state irrespective of game time. If anyone could tell me what I'm doing wrong, I would really appreciate it. (And I'm sorry if my code is horrific, I really do not "get" scripting very well.)



#2
Jokerine

Jokerine

    Longer Monger

  • Account closed
  • PipPipPipPipPip
  • 10,728 posts

Hm... well, if I remember correctly scripting for Oblivion is very similar to New Vegas, so you could try this script I use in one of my NV mods. Really simple so it may work for you. It needs to be linked to a quest that starts game-enabled.

Begin GameMode	
  if GameHour >= 18 || GameHour < 7	
     NPCMarkerREF.enable	
   else	
     NPCMarkerREF.disable 
EndIf
END

Hope it helps :)



#3
Contrathetix

Contrathetix

    merry within reason

  • Supporter
  • PipPipPipPip
  • 2,126 posts

Edit: Nevermind, I had made some wrong assumptions, and was thankfully corrected by someone more knowledgeable (thank you!). My bad, sorry. :blush:

 

Edit 2: To add back the relevant pieces I deleted (leaving out the irrelevant false assumptions about scripts on disabled references), the script by Jokerine looks like valid Oblivion scripting. And if you run into any similar issues later, you can always temporarily add some messageboxes or other printing to your scripts to track where the script goes. For example:

MessageBox "It is night, disabling the NPC."
MessageBox "It is night, the NPC is already disabled."
MessageBox "It is day, enabling the NPC."

There are also command to print to the console, but those seem to all require OBSE according to the wiki (like PrintToConsole, PrintD, DebugPrint and the like).


Edited by Contrathetix, 21 May 2017 - 08:11 AM.


#4
Crackomint

Crackomint

    Old hand

  • Supporter
  • PipPipPip
  • 563 posts

Sorry I forgot to respond here- things are now working as intended. I appreciate the responses :)







Also tagged with one or more of these keywords: construction set, scripting, npc

Page loaded in: 1.042 seconds