summaryrefslogtreecommitdiff
path: root/npc/functions/shops.txt
blob: d7886b6a80d4735df0d034c38ee4d9aedd874fdc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Evol functions.
// Author:
//    4144
//    Jesusalva
// Description:
//    Shops utility functions
// Variables:
//    Item ID, Item Price, Item Amount

// restoreshopitem(amount) or restoreshopitem(price, amount)
function	script	restoreshopitem	{
    if (getarg(2, -1337) == -1337) {
        .@amount=getarg(1);
        .@price=-1;
    } else {
        .@amount=getarg(2);
        .@price=getarg(1);
    }

    if (!shopcount(getarg(0)) && .@amount >= 3)
        sellitem getarg(0), .@price, .@amount*4/3;
    else if (shopcount(getarg(0)) < .@amount)
        sellitem getarg(0), .@price, .@amount;
    return;
}


// shop2({NPC Name, {showmenu=true}})
function	script	shop2	{
    npctalk3 any(
        l("The best wares!"),
        l("Buy cheap, sell expensive!")
    );
    .@n$=getarg(0, strnpcinfo(0));

    npcshopattach(.@n$);

    if (getarg(1,true))
        shop .@n$;
    else
        openshop .@n$;

    closeclientdialog;
    return;
}