Jump to content

Script to give an Item to the player


danatoth666

Recommended Posts

So I want to give the player an item for the quest.

I'm not a scripter at all and barely understand how to do any of it, but I've been learning.

 

So I created an item, then made it an Alias in my quest (created at the quest giver) of it.

When the quest reaches stage 10 I want to give the player the item. I had no idea how to do this

so I just tried to find a quest that did the same thing. Here is what I found, but it doesn't work.

(The alias name I made for my item was "Letter")

 

Alias_Letter.TryToEnable()

Game.GetPlayer().AddItem(Alias_Letter.GetReference())

 

Can anyone give me the correct code?

 

Also if you know, what is the script to remove an item?

Link to comment
Share on other sites

hope this work :wallbash:

 

to give a item, you have to find the ID first, this can be seen with type "showinventory" to a container or NPC with console

then type "player.additem (item ID) (quantity)"

 

it will automatically give the item to player

 

to remove it ... well

target the NPC or Container then type "removeitem (item ID) (quantity)"

 

should work, but not sure. :facepalm:

just try it. lol :laugh:

Link to comment
Share on other sites

hope this work :wallbash:

 

to give a item, you have to find the ID first, this can be seen with type "showinventory" to a container or NPC with console

then type "player.additem (item ID) (quantity)"

 

it will automatically give the item to player

 

to remove it ... well

target the NPC or Container then type "removeitem (item ID) (quantity)"

 

should work, but not sure. :facepalm:

just try it. lol :laugh:

 

Are you talking about command console here?

This doesn't work by putting it as a script and compiling it, I get errors.

Link to comment
Share on other sites

Skyrim uses a completely new scripting system called Papyrus. All of the scripting information on the Oblivion Construction Kit Wiki is no longer relevant for scripting.

 

AddItem is the correct function for adding an item, and RemoveItem can be used to remove an item. You might also try Debug.Notification to make sure that your code is actually running - it should print a message to the screen.

 

Cipscis

Link to comment
Share on other sites

So I tried using this code:

 

Game.GetPlayer().AddItem(EGPMedicineNote, 1, false)

 

But I get this error:

 

 

\Scripts\Source\temp\QF_EGPTestQuest_02005F97.psc(34,25): variable EGPMedicineNote is undefined

No output generated for QF_EGPTestQuest_02005F97, compilation failed.

 

Just to make it clear, EGPMedicineNote is an item I created. It is not placed anywhere in the world.

Edited by danatoth666
Link to comment
Share on other sites

 

Hmmm...I checked that link out and tried the code it suggested:

 

Game.GetPlayer().AddItem(Diamond, 2, true)

 

Just to see if it would actually add the diamond.

 

I got this error when I compiled the script:

 

\Data\Scripts\Source\temp\QF_EGPTestQuest_02005F97.psc(34,25): variable Diamond is undefined

No output generated for QF_EGPTestQuest_02005F97, compilation failed.

 

I don't understand why though...

 

The compiler is throwing an error because it doesn't know which object "Diamond" refers to.

 

  1. First make sure you have an object with a unique ID.
  2. Create a quest alias for it with a unique name
  3. In quest stages add a property and property type to the script
  4. It should list the alias and object type in the Properties window.

Edited by Guest
Link to comment
Share on other sites

 

Hmmm...I checked that link out and tried the code it suggested:

 

Game.GetPlayer().AddItem(Diamond, 2, true)

 

Just to see if it would actually add the diamond.

 

I got this error when I compiled the script:

 

\Data\Scripts\Source\temp\QF_EGPTestQuest_02005F97.psc(34,25): variable Diamond is undefined

No output generated for QF_EGPTestQuest_02005F97, compilation failed.

 

I don't understand why though...

 

The compiler is throwing an error because it doesn't know which object "Diamond" refers to.

 

  1. First make sure you have an object with a unique ID.
  2. Create a quest alias for it with a unique name
  3. In quest stages add a property and property type to the script
  4. It should list the alias and object type in the Properties window.

 

I've made my item (EGPMedicineNote) into an Alias called "Letter"

I then tried this code:

 

Alias_Letter.TryToEnable()
Game.GetPlayer().AddItem(Alias_Letter.GetReference())

 

Which is a direct copy of another quest that gives the player a note. It compiles fine, but in game it doesn't give me the note.

Link to comment
Share on other sites

So I tried using this code:

 

Game.GetPlayer().AddItem(EGPMedicineNote, 1, false)

 

But I get this error:

 

 

\Scripts\Source\temp\QF_EGPTestQuest_02005F97.psc(34,25): variable EGPMedicineNote is undefined

No output generated for QF_EGPTestQuest_02005F97, compilation failed.

 

Just to make it clear, EGPMedicineNote is an item I created. It is not placed anywhere in the world.

 

I don't really get the new scripting, but I think you need a declaration in your script along the lines of:

 

Book Property EGPMedicineNote auto

 

That should tell the compiler that what you're trying to do is link something in.

Link to comment
Share on other sites

Yeah I was reading on the official forums about this (i posted this question there as well) and Cipscis pretty much said the same thing about the editor ID.

I tried to use your code:

Book Property EGPMedicineNote auto

but it says there is "no viable alternative at input 'Book'" or EGP Medicine note...Hmmm

Headache!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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