<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
  SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
  <func>
    <title>Buy</title>
    <category>Objects</category>
    <subcat>Creation</subcat>
    <version>5.1 OC</version>
    <syntax>
      <rtype>object</rtype>
      <params>
        <param>
          <type>id</type>
          <name>buy_object</name>
          <desc>Type of object to be bought.</desc>
        </param>
        <param>
          <type>int</type>
          <name>for_player</name>
          <desc>Owner (player number) of the new object.</desc>
        </param>
        <param>
          <type>int</type>
          <name>pay_player</name>
          <desc>Number of the player who pays for the object.</desc>
        </param>
        <param>
          <type>object</type>
          <name>to_base</name>
          <desc>Target object in which the new object is placed. This parameter can be left out if the calling object is the base.</desc>
          <optional />
        </param>
        <param>
          <type>bool</type>
          <name>show_errors</name>
          <desc>If specified and not <code>false</code>, failure messages such as "Buying not possible" are displayed, e.g. if there is not enough money.</desc>
          <optional />
        </param>
      </params>
    </syntax>
    <desc>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.</desc>
    <examples>
      <example>
        <code>Buy(Rock, 0, 0, <funclink>FindBase</funclink>(0), true);</code>
        <text>Buys a rock at the base of the first player.</text>
      </example>
    </examples>
    <related>
      <funclink>Sell</funclink>
      <funclink>GetWealth</funclink>
      <funclink>FindBase</funclink>
    </related>
  </func>
  <author>Sven2</author><date>2001-11</date>
</funcs>
