In-game shop

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

If you want to give the player the possibility to buy items in-game, this article tells you how to do it.

The scriptobject

First of all you need the scriptobject handling the behaviour of the specific objects you want the player to be able to buy. You can get it here. It's shop_item.script.

Put it in your script folder, delete the .txt ending and include it by adding the line

 #include "script/shop_item.script"

to your tdm_custom_scripts.script file. If there is no such a file, you have to create it.

Setting it up

In DarkRadiant, create a model of the object you want to sell. Place it at it's position and add the following spawnargs.

- "scriptobject" "shop_item": This tells the object to use the appropiate script - "item" "<itemname>": itemname is the name of the entity you want the player to buy. If you don't know the name, you can look it up in the create entity dialog (an example would be atdm:ammo_waterarrow) - "price" "X": how much this item costs (X is the value) - "amount" "Y": how many items are available for selling. If you don't set this there will be infinite - "text" "your_text_here": if you want a popup-message to appear if the player frobhilights this object, you can put it here (for example "Waterarrow: 50g")

The script automatically uses the loot the player has. If one type of loot has exceeded, another type is used. If the player hasn't enough loot to purchase the item, nothings happen. If the amount of items available has exceeded the object will automatically be removed from game.

--Obsttorte (talk) 11:51, 19 March 2013 (EDT)