A script to give an item

Post » Mon Jun 18, 2012 10:13 am

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?
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Mon Jun 18, 2012 10:50 pm

Bump
User avatar
Lexy Corpsey
 
Posts: 3448
Joined: Tue Jun 27, 2006 12:39 am

Post » Mon Jun 18, 2012 11:45 am

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.
User avatar
Charity Hughes
 
Posts: 3408
Joined: Sat Mar 17, 2007 3:22 pm

Post » Mon Jun 18, 2012 12:56 pm

Take a look at this - http://www.cipscis.com/skyrim/tutorials/editorids.aspx

Cipscis
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Mon Jun 18, 2012 3:14 pm

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.
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm

Post » Mon Jun 18, 2012 9:34 am

If anyone would like an example of what I'm trying to do, head over to the quest "BQ01"
This quest gives the player a bounty note.
User avatar
Syaza Ramali
 
Posts: 3466
Joined: Wed Jan 24, 2007 10:46 am

Post » Mon Jun 18, 2012 6:59 pm

try using the trytoenable in an if statement to test if it's enabling the reference

if Alias_Letter.TryToEnable()Game.GetPlayer().AddItem(Alias_Letter.GetReference())debug.messagebox("added item")elsedebug.messagebox("enabling quest reference alias failed")endif
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Mon Jun 18, 2012 9:19 am

try using the trytoenable in an if statement to test if it's enabling the reference

if Alias_Letter.TryToEnable()Game.GetPlayer().AddItem(Alias_Letter.GetReference())debug.messagebox("added item")elsedebug.messagebox("enabling quest reference alias failed")endif

I tried that and it failed, so I'm assuming something is messed up with my Alias?
Here is a link to a screen grab of it: http://i.imgur.com/BTKdn.png
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Mon Jun 18, 2012 12:18 pm

take out the alias_ part of your alias_letter and try again
User avatar
Sarah Kim
 
Posts: 3407
Joined: Tue Aug 29, 2006 2:24 pm

Post » Mon Jun 18, 2012 8:26 pm

take out the alias_ part of your alias_letter and try again

Hmm If I do this I get the errors "variable Letter is undefined" " none is not a known user-defined type"
when I compile it.
I'm using:
Game.GetPlayer().AddItem(Letter.GetReference())
User avatar
Isaiah Burdeau
 
Posts: 3431
Joined: Mon Nov 26, 2007 9:58 am

Post » Mon Jun 18, 2012 10:44 pm

I went to add some gold to the player, based on a messagebox selection.

I got the same error until I attached a 'miscobject' property to the script. then the additem function worked correctly.

I explain it at the bottom of this tutorial I created: http://tesalliance.org/forums/index.php?/topic/4697-class-1-doing-something/

So based on the type of object your adding will depend on the type of property you add.
User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am

Post » Tue Jun 19, 2012 12:01 am

Hmm If I do this I get the errors "variable Letter is undefined" " none is not a known user-defined type"
when I compile it.
I'm using:
Game.GetPlayer().AddItem(Letter.GetReference())

in that case try using a property instead of the alias reference
Book Property EGPMedicineNote auto
then try to use EGPMedicineNote instead of alias_letter.getreference()
without the if statement portions

properties work just fine in the additem function
User avatar
Mistress trades Melissa
 
Posts: 3464
Joined: Mon Jun 19, 2006 9:28 pm

Post » Mon Jun 18, 2012 4:24 pm

in that case try using a property instead of the alias reference
Book Property EGPMedicineNote auto
then try to use EGPMedicineNote instead of alias_letter.getreference()
without the if statement portions

properties work just fine in the additem function

I tried this, my code looks like:
Book Property EGPMedicineNote autoGame.GetPlayer().AddItem(EGPMedicineNote)

I get these errors during compiling: "no viable alternative at input 'Book'" "no viable alternative at input 'EGPMedicineNote'"
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Mon Jun 18, 2012 10:13 pm

Put the property above your Event code, not inside the Event code.
And is your "EGPMedicineNote" defined as a book object?
User avatar
MarilĂș
 
Posts: 3449
Joined: Sat Oct 07, 2006 7:17 am

Post » Mon Jun 18, 2012 2:54 pm

I tried this, my code looks like:
Book Property EGPMedicineNote autoGame.GetPlayer().AddItem(EGPMedicineNote)

I get these errors during compiling: "no viable alternative at input 'Book'" "no viable alternative at input 'EGPMedicineNote'"

properties are placed outside the main block, the CK puts generated properties at the very bottom of the source code
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Mon Jun 18, 2012 10:36 pm

Here is a screen grab of the code, where it's at, and the book: http://i.imgur.com/gXLA2.png
I'm confused by all the technical jargon lol, I'm just starting to script...
User avatar
Marion Geneste
 
Posts: 3566
Joined: Fri Mar 30, 2007 9:21 pm

Post » Mon Jun 18, 2012 9:10 pm

Here is a screen grab of the code, where it's at, and the book: http://i.imgur.com/gXLA2.png
I'm confused by all the technical jargon lol, I'm just starting to script...
hit the properties button for the papyrus fragment, then add property, set the type to book and name to EGPMedicineNote, it should hopefully set the value correctly based on the matching names
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Mon Jun 18, 2012 8:39 pm

hit the properties button for the papyrus fragment, then add property, set the type to book and name to EGPMedicineNote, it should hopefully set the value correctly based on the matching names

This worked! Thanks so much man XD
Now to make a youtube tutorial video on this so nobody else makes my mistakes! Thanks again!!
User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm


Return to V - Skyrim