Jump to content

Additem to Npc


ajs52698

Recommended Posts

Im attempting to give a npc some caps when a conversation ends but when I check his inventory its not there.

 

Heres my Scripts

 

 

Fragment On Conversation:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:TopicInfos:TIF_Quest_02004CED Extends TopicInfo Hidden Const
;BEGIN FRAGMENT Fragment_Begin
Function Fragment_Begin(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if Game.GetPlayer().GetItemCount(pCaps001) >= 600
Game.GetPlayer().RemoveItem(pcaps001, 600)
npc.additem(pcaps001,600)
Endif
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment
MiscObject Property pCaps001 Auto Const Mandatory
objectreference Property Npc Auto const mandatory
And My Script On The NPC:
Scriptname TestScript extends Actor
Quest property Quest auto
Event Onactivate (objectreference akactionref)
Quest.setobjectivecompleted(10)
Quest.setstage(15)
Quest.Setobjectivedisplayed (15)
EndEvent
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
AddInventoryEventFilter(Caps001)
If AiitemCount <= 600
Quest.setobjectivecompleted(15)
Quest.setstage(20)
Quest.setobjectivedisplayed(20)
Utility.WaitGameTime(24.0)
Quest.completequest()
Endif
Endevent
Endevent
Not Sure Why Its Not Working :sad:
Edited by ajs52698
Link to comment
Share on other sites

It may be the fact that you try to tweak with referencing the NPC to the speaker of a conversation. in the dialogue you do get a slider of who's the speaker of that particular dialogue, you may set it to that NPC you want to give money... Or just reference that NPC in the Properties.

 

1 Go to the ending dialogue which you want to result in giving NPC money.

2 Set properties "pcaps001" (money) and "Actor"(NPC)

3. Place fragment.

 

If Game.getPlayer().GetItemCount (pcaps001) >= 600

Game.GetPlayer().AddItem (pcaps001, 600)

Game.GetActor().AddItem (pcaps001, 600)

endif

 

or

 

If Game.getPlayer().GetItemCount (pcaps001) >= 600

Game.GetPlayer().AddItem (pcaps001, 600)

Actor().AddItem (pcaps001, 600)

endif

 

I may not be right on the spelling or spacebars on those, so it my take some tweaks before it compiles.

Edited by Galejro
Link to comment
Share on other sites


if Game.GetPlayer().GetItemCount(pCaps001) >= 600

Game.GetPlayer().RemoveItem(pcaps001, 600)

Npc().additem(pcaps001,600)



Endif





Npc is not a function or does not exist

void is not a known user-defined script type



Get These Errors

Link to comment
Share on other sites

For your script on the npc If you want to detect that he got the caps you have to put the AddInventoryEventFilter before the OnItemAdded event for example inside your OnActivate event Like this:

 ScriptName TestScript extends Actor
 
Quest Property Quest Auto
MiscObject Property Caps001 Auto
 
Event OnActivate(ObjectReference akActionRef)   ;not sure if this will work on an actor
     Quest.SetObjectiveCompleted(10)
     Quest.SetStage(15)
     Quest.SetObjectiveDisplayed(15)
     AddInventoryEventFilter(Caps001)
EndEvent
 
Event OnItemAdded(Form akBaseItem, Int iaItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If(aiItemCount <= 600)   ; *1
         Quest.SetObjectiveCompleted(15)
         Quest.SetStage(20)
         Quest.SetObjectiveDisplayed(20)
         Utility.WaitGameTime(24.0)
         Quest.CompleteQuest()
    EndIf
EndEvent
*1: this will trigger if the Npc has been given 600 or less caps. In the script where you add the caps you already chek if the player can give 600 caps and then give the Npc 600 caps. If you want to make sure the rest of the script only runs if he receives the 600 caps from the player the I would use >= 600 or even == 600 Edited by LoneRaptor
Link to comment
Share on other sites

The InventoryEventFilter tells the script wich items to look for for the OnItemAdded event. without it the script won't register any items being added.

that's wy the filter needs to be first because only after the filter wil the script pay attention to the filters item(s) for the OnItemAdded event.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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