OBSE Script Causing CTD

Post » Fri May 27, 2011 6:27 am

Okay, I'm working on a mod that will add gold (and eventually other items) to NPCs. What I've done so far is create a token (a Silver Amulet marked as "Unplayable" so the player can't remove it) that gets added to NPC inventories along with the gold to stop the gold from being added in every frame. The script I have so far is:

scn SVGoldAddScriptref ActorBegin GameModeset Actor to GetFirstRef 69 1While Actor  If Actor.getitemcount DontGiveMoneyToken == 0	 Actor.additem Gold001 50	 Actor.additem DontGiveMoneyToken 1  endif  set Actor to GetNextRefloopEnd


However, this causes an immediate CTD every time I load the game. What do I need to do to make this work?

Edit- This is a quest script.
User avatar
NIloufar Emporio
 
Posts: 3366
Joined: Tue Dec 19, 2006 6:18 pm

Post » Fri May 27, 2011 10:17 am

Having these conditions helps narrow down your intended target.

While Actor
if (Actor.GetIsCreature == 0)
if (Actor.GetDead == 0)
if (Actor.GetDisabled ==0)
User avatar
marina
 
Posts: 3401
Joined: Tue Mar 13, 2007 10:02 pm

Post » Fri May 27, 2011 7:27 pm

What is happening here, most likely, is that the script is being executed repeatedly, again and again. This hogs processor power (I think) and can cause the CTD. (Could be wrong though)
User avatar
Rachel Cafferty
 
Posts: 3442
Joined: Thu Jun 22, 2006 1:48 am

Post » Fri May 27, 2011 10:19 am

What is happening here, most likely, is that the script is being executed repeatedly, again and again. This hogs processor power (I think) and can cause the CTD. (Could be wrong though)

Unless the fQuestDelayTime of the quest is adjust externally or in the .ini file this script only runs once every 5 seconds.
User avatar
Andy durkan
 
Posts: 3459
Joined: Fri Aug 03, 2007 3:05 pm

Post » Fri May 27, 2011 6:06 pm

Unless the fQuestDelayTime of the quest is adjust externally or in the .ini file this script only runs once every 5 seconds.

I thought that was just for Quest scripts? This one appears to be on an object (Object script)
User avatar
Matt Gammond
 
Posts: 3410
Joined: Mon Jul 02, 2007 2:38 pm

Post » Fri May 27, 2011 8:05 am

I thought that was just for Quest scripts? This one appears to be on an object (Object script)

Not according to http://www.gamesas.com/bgsforums/index.php?showtopic=1073222&st=60&p=15684593&#entry15684593.
User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am

Post » Fri May 27, 2011 5:05 pm

You might want to add a ( isFormValid rActor ) catch inside the loop - Ref. walking in external cells sometimes returns null references.
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am

Post » Fri May 27, 2011 9:37 pm

If it is a quest script how will it ever do anything? The quest is not in any cell so how does it know where to look?
User avatar
Hot
 
Posts: 3433
Joined: Sat Dec 01, 2007 6:22 pm

Post » Fri May 27, 2011 1:50 pm

getFirstRef walks through the references of the player's parent cell.
User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am

Post » Fri May 27, 2011 8:03 am

Oh, ok thanks.
User avatar
Emily Graham
 
Posts: 3447
Joined: Sat Jul 22, 2006 11:34 am

Post » Fri May 27, 2011 9:28 am

Thanks for all the replies! This is indeed a quest script (should have put this in my first post :facepalm:)

You might want to add a ( isFormValid rActor ) catch inside the loop - Ref. walking in external cells sometimes returns null references.

Something like this?

scn SVGoldAddScriptref ActorBegin GameModeset Actor to GetFirstRef 69 1While Actor If isFormValid rActor == 1  If Actor.getitemcount DontGiveMoneyToken == 0	 Actor.additem Gold001 50	 Actor.additem DontGiveMoneyToken 1  endif  set Actor to GetNextRefloopEnd


Or do I need to put isFormValid rActor somewhere else?
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Fri May 27, 2011 5:40 pm

That's correct. Make sure you add an endIf command to match.
User avatar
Tinkerbells
 
Posts: 3432
Joined: Sat Jun 24, 2006 10:22 pm

Post » Fri May 27, 2011 12:55 pm

That's correct. Make sure you add an endIf command to match.

:banghead: I tried saving the above change (with a matching Endif) but I got a message saying "rActor not found for parameter int" and the script won't compile. :banghead: I changed rActor to Actor and it did save, so I thought the problem solved. :banghead: No joy. :banghead: Still get an instant CTD. :banghead: What do I need to do to make this work?
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am

Post » Fri May 27, 2011 2:53 pm

Try this script:
scn SVGoldAddScriptref rActorBegin GameMode	set rActor to Apple	set rActor to GetFirstRef 69 1	While (rActor != 0)		If (IsFormValid rActor == 1)			If (rActor.getitemcount DontGiveMoneyToken == 0)				rActor.additem Gold001 50				rActor.additem DontGiveMoneyToken 1			endif		endif		set rActor to Apple		set rActor to GetNextRef	loopEnd

User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Fri May 27, 2011 11:44 am

Have you tried using a leveled list?
User avatar
Krystal Wilson
 
Posts: 3450
Joined: Wed Jan 17, 2007 9:40 am

Post » Fri May 27, 2011 3:38 pm

Try this script:
scn SVGoldAddScriptref rActorBegin GameMode	set rActor to Apple	set rActor to GetFirstRef 69 1	While (rActor != 0)		If (IsFormValid rActor == 1)			If (rActor.getitemcount DontGiveMoneyToken == 0)				rActor.additem Gold001 50				rActor.additem DontGiveMoneyToken 1			endif		endif		set rActor to Apple		set rActor to GetNextRef	loopEnd

I tried it. Same result: Instant CTD As soon as the crosshairs passed over an NPC. Thanks though.

Have you tried using a leveled list?

Yeah. I get the same result with that too. I'm using OBSE 17b, so I don't think that's the problem. Is there some other way to do this?
User avatar
Sarah Evason
 
Posts: 3507
Joined: Mon Nov 13, 2006 10:47 pm

Post » Fri May 27, 2011 9:37 am

I tried it. Same result: Instant CTD As soon as the crosshairs passed over an NPC. Thanks though.


Yeah. I get the same result with that too. I'm using OBSE 17b, so I don't think that's the problem. Is there some other way to do this?
Is there a script on your DontGiveMoney token? There is absolutely no reason that script I modified should cause a CTD.

Perhaps you should use ConScribe and PrintToConsole in order to debug the script. But I know it should work just fine.

Are there are other scripts in this mod of yours that are doing something?
User avatar
Lily Evans
 
Posts: 3401
Joined: Thu Aug 31, 2006 11:10 am

Post » Fri May 27, 2011 8:17 am

I tried it. Same result: Instant CTD As soon as the crosshairs passed over an NPC. Thanks though.

Why should the crosshairs be involved? Is there another script/quest trying to add/remove something else to actors.
User avatar
James Shaw
 
Posts: 3399
Joined: Sun Jul 08, 2007 11:23 pm

Post » Fri May 27, 2011 1:57 pm

Is there a script on your DontGiveMoney token?

Nope. The only script in the whole mod was the Quest script. I scrapped the mod and started over. Works perfectly now. Thanks! :foodndrink:

Why should the crosshairs be involved? Is there another script/quest trying to add/remove something else to actors.

Not sure why the crosshairs were causing this. If I looked straight up or down, I could walk around with no problem. If I looked at an NPC, instant CTD. :shrug:


Thank you all for your help! :D
User avatar
GRAEME
 
Posts: 3363
Joined: Sat May 19, 2007 2:48 am


Return to IV - Oblivion