Jump to content

OnItemAdded Help Script


ajs52698

Recommended Posts

You have to add an AddInventoryEventFilter for everything you want to catch. A small example for detecting when some armors are added through keywords:

Event OnInit()
	AddInventoryEventFilter(pma_Railroad_ClothingArmor)
	AddInventoryEventFilter(pObjectTypeArmor)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	If (akBaseItem.HasKeyword(pma_Railroad_ClothingArmor) || akBaseItem.HasKeyword(pObjectTypeArmor))
		DoSomethingFunction(akBaseItem)
	EndIf
EndEvent
Edited by Dielos
Link to comment
Share on other sites

Will This Work?

 

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
AddInventoryEventFilter(Caps001)
if akBaseItem == caps001
Search()
Edited by ajs52698
Link to comment
Share on other sites

No it wont. An event needs a defined start and end, just like my example above. Also, for the OnItemAdded event to fire, you need to have registered for the event before. For that I used in my example the OnInit event, as that one fires when the script is run the first time.

 

On the CK wiki there are nice tutorials that can help you through the basics. You should understand those, and I'd recommend to start with the basic "Hello World" one, as that one already helps define events. It's amazing what you can do once you have some understanding of how scripts work, really tons of fun...

 

If what you want to do is not too complex, explain it here and I can give you some code to start with.

Edited by Dielos
Link to comment
Share on other sites

Im aware you have to end a event, but what Id like is for this event to go off as a papyrus fragment script checking if the npc has recieved gold.

 

aka caps :tongue:

 

 

 

Npc Receives Caps from player -> Npc Runs Script checking if received caps -> if received, do something!

Edited by ajs52698
Link to comment
Share on other sites

I also am in need of a way to enable packages and disable packages for certain conditions which go along with what im trying to do here aka npc receives caps-> packages is started,if not another package started /:

 

 

Ive been stuck on this all day

Edited by ajs52698
Link to comment
Share on other sites

Ok so let me try to explain what im having problems with now a little better.

 

 

Player Enables Activator

Activator Starts Quest

Activator Calls/enables package that sends npc to player

Quest is finished when npc talks to player and enables Second Package

Then npc just returns to where he came from when the second package no longer finds its targets, npc returning would be a third package I guess.

Quest would be repeatable

 

Hopefully this explains what im trying to achieve a little better.

 

Everything else this mod would need ive already done.

 

I just need a way to tell the npc what to do other than using pathtoreference since I wasnt able to get that working

Edited by ajs52698
Link to comment
Share on other sites

Ok sorry, didn't get this was on fragments. Never used them before myself, so I have no idea. And I was sending you to tutorials... Really sorry!

 

Actually, I'm trying to learn packages myself, so this could be really useful for me as well, although I need to control them through script ideally.

 

In theory (didn't try), you should be able to put a condition in your package for when your quest changes stages. Or you could have the activator change a variable and this variable be the condition to start the package. My guess (really, just a guess, never did this before!) is that you could set up a global variable that starts at 0. Your activator or even quest start could change it to 1, and the first package kicks in. Change it then to 2 on another stage and the second package starts.

 

pathtoreference didn't work for me either too well. So now the need for packages for me as well. :mad:

Edited by Dielos
Link to comment
Share on other sites

  • Recently Browsing   0 members

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