[script]Preventing player from reading a letter

Post » Tue Jun 19, 2012 8:09 am

Hello,

First of all, I'm not an english native speaker, so forgive me for my poor english :smile:

The context is quite simple, player find a letter on the corpse of, or is given a letter by, a Thongue in Markarth. The letter adresse will be very unpleased if the letter has been unsealed.

So, I'm trying to block the reading of a letter, or at least to ask the player if he is really sure to unseale it. To do so, I put a Message with two buttons, reference in the further script as "dialogueBox". My script work for a letter placed on the ground, but I can't figure out how to do that if the letter is on the player inventory.

Script :

Spoiler

Scriptname EL_MarkarthLangueLetterScript extends ObjectReference  Bool unsealed = falseBool doOnce = trueMessage property dialogueBox autoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)  if akNewContainer == Game.GetPlayer()	Debug.Notification("change to player")	Game.getPlayer().EquipItem(self, false, false) ;<= this line raise an error on log  endIfendEventEvent OnCellAttach()	if doOnce		Debug.Notification("cell Attach")		BlockActivation(true)		doOnce = false	endifendEventEvent OnActivate(ObjectReference akActionRef)   if akActionRef == Game.GetPlayer()		if dialogueBox.show() == 0			Debug.Notification("OUI")			activate(Game.getPlayer(), true)		endif   endIf   Debug.Notification("addItem")   Game.getPlayer().addItem(self, 1, true)EndEventEvent OnEquipped(Actor akActor)  if akActor == Game.GetPlayer()	if dialogueBox.show() == 1		Debug.Notification("non")	endif  endIfendEvent

The main difficulty (for me) is that event are raised after the occurence of the event and I didn't find a way to cancel an event. To bypass that for the "letter on the ground" case, I used "BlockActivation(true)" to cancel any automatic reading of the letter, and on activation, do nothing and move letter to inventory if player doesn't want to unseal the letter, or activate with a defaultProcess tag to read the content of the letter.

But what if the letter is on the inventory? I try unequippItem with preventEquip tag, but this raise this error on scriptlog:
error:  (09009A85): has no 3d and cannot be equipped.stack:	[ (00000014)].Actor.EquipItem() - "" Line ?	[Item 1 in container  (00000014)].EL_MarkarthLangueLetterScript.OnContainerChanged() - "EL_MarkarthLangueLetterScript.psc" Line 12
A letter can not be Equipped/Unequipped, even if the OnEquipped event is raised ? That's odd...
User avatar
JESSE
 
Posts: 3404
Joined: Mon Jul 16, 2007 4:55 am

Return to V - Skyrim