> For the complete documentation index, see [llms.txt](https://fehdead.gitbook.io/npc-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/subgill.md).

# npc.subgill

```lua
npc.subgill(gil)
```

|                         |                                                                        |
| ----------------------- | ---------------------------------------------------------------------- |
| id                      | `0x02E8`                                                               |
| arguments               | 1: Int                                                                 |
| result                  | int: goes to the very next call, or to `npc.lua(npc.subgill(...), fn)` |
| in NPC Kit              | yes                                                                    |
| measured from a kit NPC | returns                                                                |
| vanilla scripts         | 64 calls in 43 of 1114 scripts                                         |

## What it does

Takes gil from the party (never below 0) and returns the new total. Writes no line in the message log.

## Arguments

### `gil` (Int)

How much.

## Result

The new total.

## Timing

Returns at once.

## In NPC Kit

Check the party has it first ([havegill](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/havegill.md) in `npc.lua`), then take it in a named function with the gil window ([gillwinstart](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/gillwinstart.md)).

## Used with

* [havegill](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/havegill.md), [gillwinstart](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/gillwinstart.md), [addgill](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/addgill.md).

## Example

A paid service: the gil is checked in Lua, taken in a named function while the window counts down.

```lua
local tooPoor = [[
That's %d gil, and I don't give tips on credit.
Come back when your purse feels a bit heavier.
]]

local thanks = [[
Thank you! It's always a pleasure doing business
with someone who pays up without any haggling.
]]

local price = 100

pay = function()
    npc.gillwinopen(npc.havegill());
    npc.gillwinstart(-100);
    npc.gillwinsync();
    npc.subgill(100);
    npc.wait(20);
    npc.gillwinclose();
end,

talk = function()
    talkOpen();
    npc.lua(npc.havegill(), function(handle, gil)
        if gil < price then
            say(handle, tooPoor:format(price))
            return
        end
        handle.run("pay", function() say(handle, thanks) end)
    end);
    talkClose();
end,
```

## Pitfalls

* Check with `havegill` first: whether `subgill` with too little gil stops at 0 is not confirmed here.
