Jump to content

Giving item to player. Papyrus problem.


Noobo

Recommended Posts

I can't seem to give an item to the player via script at the end of a dialogue. But It is refusing to compile

 

Currently im using:

Game.GetPlayer().AddItem(Alias_patronbook)

 

 

The error message:

 

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__010163AF.psc(9,25): variable Alias_patronbook is undefined
No output generated for TIF__010163AF, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on TIF__010163AF
What does it mean by undefined?
I have set up an Alias which uses the 'createrefencetoobject' Fill type. The item appears in the inventory of an NPC.
Im not too sure where I went wrong.
Link to comment
Share on other sites

Im not quite getting it

 

What property should i set for the Alias? I created an empty script with a property of 'book' and editing the value to be the patronbook. It still refuses to compile saying the Alias_patronbook is undefined

Edited by Noobo
Link to comment
Share on other sites

In your brief one line example, Alias_patronbook is being reconized as a variable name. The error you are getting tells you that that variable name has no value assigned to it and is therefore unable to be used and prompts the script to not compile.

 

Not knowing your entire script, I can't really be of that much help. What I can do is show something that does the same thing but using different variable names.

 

 

Scriptname SomeScript Extends ObjectReference

MiscObject Property SomeItem Auto

Event OnActivate(ObjectReference Somebody)
If Somebody == Game.GetPlayer()
Somebody.AddItem(SomeItem,1)
EndIf
EndEvent
 

This is a sample snipet of a script that would be placed on some interactive object that when the player goes to use it will give the player 1 of whatever object was assigned to the property variable SomeItem.

Link to comment
Share on other sites

The script is a single line. A papyrus fragment placed at the end of a dialogue.

 

I'm still not understanding this whole deal with it being undefined. How do i define it? I've created a script with property indicating that it is a book.

 

http://i1279.photobucket.com/albums/y540/arquey/help_zpsab989f2f.jpg

http://i1279.photobucket.com/albums/y540/arquey/Help02_zps670407e8.jpg

Link to comment
Share on other sites

Ok but that script is on the book, the alias_patronbook needs to be setup in the TIF_010163AF that you see in the 2nd image, highlight that script, click properties add the alias_patronbook, you can set it up as an object or reference alias if you have it as an alias in your quest.
Link to comment
Share on other sites

I am guessing Alias_patronbook is an alias you created in the quest.

 

In that case you need to add the .GetReference() function. you can not pass just the alias as a parameter, you need to pass the actual ObjectReference

 

you need to have the: game.GetPlayer().addItem(Alias_patronbook.GetReference())

 

that should do it for you. for more info:

 

http://www.creationkit.com/GetReference_-_ReferenceAlias

Link to comment
Share on other sites

Not working.

 

It doesnt allow me to add a property to TIF_010163AF.

 

Im also getting a second error message by using game.GetPlayer().addItem(Alias_patronbook.GetReference())

 

Compiling "TIF__020163AF"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__020163AF.psc(9,25): variable Alias_patronbook is undefined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__020163AF.psc(9,42): none is not a known user-defined type
No output generated for TIF__020163AF, compilation failed.

 

I've already tried adding property to the alias. This is what it looks like:

 

http://i1279.photobucket.com/albums/y540/arquey/help03_zps95af3290.jpg

Link to comment
Share on other sites

Looking at our screenshots i have no clue what you are trying to do or what you are trying to convey. I see a book with a script on it, an aliase with a script on it. Apparently you want to have the book be given to the player when a line of dialogue is said.

 

So time to start from the ground up.

 

First, remove the script from the book and the alias.

From the looks of it you are creating the aliase correctly so the book is apearing in the inventory of your npc as your said.

 

So, a few things for you to take into account.

1. Don't give the book via a script fragment of dialogue directly like I now see you were trying to do.

2. make the dialogue move to a new stage.

3. on that stage add a the: game.GetPlayer().AddItem(Alias_patronbook.GetReference())

 

that should work, if that doesn't then i dont know where else things have gone screwy on your end

Edited by Hangman4358
Link to comment
Share on other sites

Sometimes the CK won't allow you to add properties to quest scripts by clicking the button. Sometimes, you have to right-click on the script and select "Edit Source." Now you can add your property at the bottom.

ReferenceAlias Property Alias_patronbook Auto 
Toward the top, you should see the fragment that you added in the fragment box. But DON'T edit that code here. Only add the property at the very bottom. Make any other changes in the box.

 

Now, after you save and the script compiles, you should be able to point the property you just added to your reference alias. Don't forget this last step. It's easy to forget.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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