Jump to content

Need script help: How to remove/add gold to a player's/npc's i


Guest Messenjah

Recommended Posts

Guest Messenjah

Ok, I'm still trying to get the hang of how to script.

 

 

I need to write an end fragment script for dialogue and I need an npc to remove 200 gold from the player and add it to their own inventory.

 

Do I need to add an alias or a property for the gold?

 

I've already got a quest property so that I can check the stage of the quest and set a new stage for the quest, but I need the gold to move. I've tried it a few different ways.

 

I've tried:

Game.GetPlayer().RemoveItem(Gold001, 200)

 

However, it says that Gold001 is an undefined variable?

 

I basically modified a line of code I found on the wiki for this.

 

What exactly does "Game" do? I'm assuming it has something to do with player related properties or variables?

 

I've figured a few things out but I'm finding the scripting language fairly difficult to follow. I can't just slap in a reference name or write in the name of a quest or script anymore to change variables.

Link to comment
Share on other sites

Guest Messenjah
Update: Figured out how to add it to the player. Just trying to figure out how to add it to an npc now. :P
Link to comment
Share on other sites

"Game" is the script that has the native "GetPlayer()" function in it.

 

You need to define a Property for the gold (MiscItem Property Gold001 auto) iirc.

 

"NPC alias".GetRef().AddItem(Gold001, 200, true)

 

I think you also need to prefix the "NPC alias" with "Alias_", so if your NPC's alias is "Fred", then use:

 

Alias_Fred.GetRef().AddItem(Gold001, 200, true)

Edited by steve40
Link to comment
Share on other sites

However, it says that Gold001 is an undefined variable?

 

It sounds like you need to go set the property on this script.

 

The property you set will be to have Gold001 be a Misc Item property referring to the object in the CK named Gold001.

 

Right click on the script and select the "Edit Properties" option from the pulldown menu or click the "Properties" box. You will need to get your properties set before you can compile a script that uses them. If you want the CK to shut up and stop giving you error messages, you can comment out your script and then successfully compile it:

 

; Game.GetPlayer().RemoveItem(Gold001, 200)

 

After your properties are set, you can remove the semi-colon and compile again.

Link to comment
Share on other sites

ok, reading this actually made me have a question sort of relating to this.

 

Is there a way to first check if the player has a certain thing/amount of that item in his inventory? I was looking through the CK wiki and could not find anything of that nature.

 

So say you want to first check if the player has 200 gold on him and if he does then take it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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