Need help with script to remove an item and add an item

Post » Wed Jun 20, 2012 8:29 pm

I'm trying to create a script that removes an item from the player's inventory and adds another item without them knowing. This is the first script i've tried to make so I don't know a great deal but I can't get it to compile and wondering if anyone knows what's wrong with it.

Your in a room thats 5 times the size of the player, a Giant World, and you need to carry a giant key that makes you overencumbered to the door to unlock it, right after you are loaded out of this giant world the player will be standing in a trigger that I want to run the script of removing the key that weighs alot and add a key that weighs nothing to make it seem like you have regained your size. Here is what I have so far:

Scriptname YetiSwitchKeys extends ObjectReference
{Replaces Giant Key}

Event OnActivate(ObjectReference akActionRef)

Game.GetPlayer().RemoveItem("YetiCastleKey07", 1, True)

Game.GetPlayer().AddItem("YetiCastleKey07sm", 1, True)

endEvent


Im getting the "type mismatch on parameter 1 (did you forget a cast?)" error twice at (5,18) and (6,18)

As I understand it I believe I'll also have to add a wait time so it runs correctly right after the next room is loaded?
User avatar
louise fortin
 
Posts: 3327
Joined: Wed Apr 04, 2007 4:51 am

Post » Wed Jun 20, 2012 10:23 pm

I don't see why your items are in quotes. Aren't they passed in properties? (They need to be.)
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Wed Jun 20, 2012 2:27 pm

Ok that fixed the previous error, but now I'm getting a new error that the 2 items are "undefined"
User avatar
Thema
 
Posts: 3461
Joined: Thu Sep 21, 2006 2:36 am

Post » Wed Jun 20, 2012 11:58 am

You have to add them as Properties using this format:

Key Property YetiCastleKey07sm auto

Then you have to autofill the properties for YetiSwitchKeys.

Edit: The original line of code had some extraneous crap about fonts or something. It was unnecessary.
User avatar
FirDaus LOVe farhana
 
Posts: 3369
Joined: Thu Sep 13, 2007 3:42 am

Post » Wed Jun 20, 2012 12:38 pm

You need to declare them as key properties, and then set the values to those properties outside of the script.

http://www.creationkit.com/Variables_and_Properties

ninja'd
User avatar
Sebrina Johnstone
 
Posts: 3456
Joined: Sat Jun 24, 2006 12:58 pm

Post » Thu Jun 21, 2012 1:03 am

Wait, what's with all the font stuff? I've never seen that before.
User avatar
Emma Louise Adams
 
Posts: 3527
Joined: Wed Jun 28, 2006 4:15 pm

Post » Wed Jun 20, 2012 1:26 pm

Wait, what's with all the font stuff? I've never seen that before.

That's just message board code. You only see it right now because it's in between some code tags.
User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Wed Jun 20, 2012 9:43 pm

Phew.
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am


Return to V - Skyrim