ajs52698 Posted August 20, 2016 Share Posted August 20, 2016 (edited) 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 commentScriptname Fragments:TopicInfos:TIF_Quest_02004CED Extends TopicInfo Hidden Const ;BEGIN FRAGMENT Fragment_BeginFunction Fragment_Begin(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEif Game.GetPlayer().GetItemCount(pCaps001) >= 600 Game.GetPlayer().RemoveItem(pcaps001, 600) npc.additem(pcaps001,600) Endif;END CODEEndFunction;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 <= 600Quest.setobjectivecompleted(15)Quest.setstage(20)Quest.setobjectivedisplayed(20)Utility.WaitGameTime(24.0)Quest.completequest() EndifEndevent Endevent Not Sure Why Its Not Working :sad: Edited August 20, 2016 by ajs52698 Link to comment Share on other sites More sharing options...
Galejro Posted August 21, 2016 Share Posted August 21, 2016 (edited) 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) >= 600Game.GetPlayer().AddItem (pcaps001, 600)Game.GetActor().AddItem (pcaps001, 600)endif or If Game.getPlayer().GetItemCount (pcaps001) >= 600Game.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 August 21, 2016 by Galejro Link to comment Share on other sites More sharing options...
ajs52698 Posted August 21, 2016 Author Share Posted August 21, 2016 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 More sharing options...
LoneRaptor Posted August 22, 2016 Share Posted August 22, 2016 (edited) Remove the () behind your Npc, should be like this: Npc.Additem(pcaps001, 600) Also the property for your Npc should be like this: Actor Property Npc Auto Const Edited August 22, 2016 by LoneRaptor Link to comment Share on other sites More sharing options...
LoneRaptor Posted August 22, 2016 Share Posted August 22, 2016 (edited) 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 August 22, 2016 by LoneRaptor Link to comment Share on other sites More sharing options...
ajs52698 Posted August 23, 2016 Author Share Posted August 23, 2016 (edited) ok it seems putting the inventoryfilter before onitemadded fixed the problem, do you mind explaining why that fixed it,for future reference? Edited August 23, 2016 by ajs52698 Link to comment Share on other sites More sharing options...
LoneRaptor Posted August 23, 2016 Share Posted August 23, 2016 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 More sharing options...
ajs52698 Posted August 23, 2016 Author Share Posted August 23, 2016 alright, thanks for the help Link to comment Share on other sites More sharing options...
Recommended Posts