Esc to clear, Enter to open the best match, click an export to open it in its page
Jobs & Shops

Shops

A shop sells items from a shopkeeper or an object in the world, through a prompt. It's the server's own money sink, or a job's business with unlimited goods or real stock its staff fill.

Three modes

ModeStockPricingRevenue
npcUnlimitedThe shop's catalogNone: a money sink
infiniteUnlimitedThe shop's catalogThe job's business account
stockedA container its staff stock by handOne price per item, set by staffThe job's business account; a shop priced in an item puts that payment in its stock room

Declaring a shop

Declare a shop your resource always has with EnsureShop, in Whip.register: it's made once and found on every start. The other calls are in the Shops API.

Whip.register(function()
    Whip.core:EnsureShop('my_gunshop', {
        name = 'Ammu-Nation', mode = 'npc', npcModel = 's_m_m_ammucountry',
        x = -330.2, y = 6084.3, z = 31.5, heading = 228.0,
        blipSprite = 110,
        catalog = { gunny_pistol = 2500, gunny_mag_pistol = 150 },
    })
end)

-- Hear every sale
AddEventHandler('whip_core:shop:purchased', function(e)
    print(('charId %s bought %d line(s) for $%d'):format(e.charId, #e.items, e.total))
end)

Business shops

infinite and stocked shops link to a job with jobId. The customer pays through ChargePlayer, and the job's business account gets a system deposit (BankSystemDeposit) logging the buyer's charId. A line that can't be handed over is refunded in the currency paid.

No owner, no account. A job's business account exists once it has an owner (/whip → Economy → Jobs). Until then GetJobBankAccounts returns nothing, so a resource paying a job needs a fallback.

For a stocked shop, set containerId to a container. Staff with canManage choose Manage Stock on the prompt, drag items in, and right-click them to Set Price and Mark For Sale. A buyer gets the exact item, metadata and serial number included.

Buying

E on the prompt swaps the inventory for the shop's cards and a basket. The server has the last word on the basket (a shelf ran out, a full basket), and Buy waits for it. Payment is Cash or Bank, or only the item a shop is priced in.

Shop talk#

Everyone nearby sees the shopping: the shopper says each step in a /me bubble, and the shopkeeper answers a moment later; the shop's header shows the conversation too, with faces. Lines and timings are Config.ShopTalk (Configuration).

Every line
  • Opening: "What do you got?" / "Welcome in."
  • Adding: "I'll take x3 Water" / "Coming right up."
  • Changing how many: "Actually, I want x5 Water instead" / "No problem, changed."
  • Taking it out: "I changed my mind on x3 Water" / "No worries."
  • Paying: "Paid $1,170 for x10 Burger and x1 Phone" / "$1,170 received. Enjoy your x10 Burger and x1 Phone!"
  • Can't afford it (once in 8 s): "Uh... can I owe you?" / "Come back when you can afford it, cheapskate."
  • Leaving: "Nevermind, I'll shop elsewhere" / "Suit yourself."

Basket changes are said once it's left alone for a second, each item once. Nothing is said by someone who is down, when a death, logout or walking away shuts the shop, or on reopening it within 15 seconds. A shop with an object has nobody to answer.

Shops in config.lua

WHIP ships with no shops. A shop in Config.Shops is made at start-up whenever no shop has its key, then managed in /whip; deleted there, it comes back at the next restart while it's listed.

Config.Shops = {
    convenience_1 = {
        name = '24/7 Store', mode = 'npc', npcModel = 'mp_m_shopkeep_01',
        pos = vector4(25.7, -1347.3, 29.5, 271.0),
        blipSprite = 52, blipColor = 2,
        catalog = { food = 50, drink = 30, bandage = 100 },
    },
}

In game: /whip → Economy → ShopsServer owners#

+ New Shop walks through the mode (and job), where it stands (walk there, press E), the shopkeeper (an NPC, a prop or nobody), the stock room, goods and prices, and the blip. A shop's page has Change on each part, Teleport there and Delete; nothing is written until Save changes, and removing a stocked shop's item from Prices takes it off sale. Arrange the shelf and tabs in game with Edit Shelf.