HasGold(int, object)

Determines if a player has more than a certain amount of gold on them.

int HasGold(
    int nAmount,
    object oGoldHolder
);

Parameters

nAmount

The amount of gold to check.

oGoldHolder

The person to check how much gold they carry.


Description

Returns TRUE if oGoldHolder has nAmount or more gold on them, otherwise returns FALSE.



Remarks

This is a wrapper function for GetGold().

Does not remove any gold from the inventory during the check.

This function is also present in the exact same format in both nw_i0_plot and nw_i0_tool. Code duplication verified in version 1.69.


Requirements

#include "nw_i0_plot" or "nw_i0_tool"

Version

1.22

Example

// This example will check the player who is currently speaking to see if they have enough
// gold to purchase something for 250 GP.
#include "nw_i0_plot" 

int StartingConditional()
{
   // Do they have enough gold to buy it?
   if(HasGold(250, GetPCSpeaker()))
   {
      // They have enough money.  Do something here.
      
      // Return success.
      return TRUE;
   }
   else
   {
      // They are poor, make the NPC insult them.
            
      // Return failure.
      return FALSE;
   }
}

See Also

functions: GetGold
categories: Inventory Functions | Money Functions


 author: Tom Cassiotis, editors: Charles Feduke, Mistress, Kolyana, additional contributor: Ivan Hawkes