Buy

Category: Objects / Creation
Since engine version: 1.0 OC

Description

Buys an object for for_plr, deducting the wealth of pay_player. The function will fail if the paying player does not have enough money or the object is currently not available in the home base material.

Syntax

object Buy(id buy_object, int for_player, int pay_player, object to_base, bool show_errors);

Parameters

buy_object:
Type of object to be bought.
for_player:
Owner (player number) of the new object.
pay_player:
Number of the player who pays for the object.
to_base:
[opt] Target object in which the new object is placed. This parameter can be left out if the calling object is the base.
show_errors:
[opt] If specified and not false, failure messages such as "Buying not possible" are displayed, e.g. if there is not enough money.

Example

Buy(Rock, 0, 0, FindBase(0), true);
Buys a rock at the base of the first player.
See also: FindBase, GetWealth, Sell
Sven2, 2001-11