summaryrefslogtreecommitdiff
path: root/npc/commands/rent.txt
blob: 8417a04e4c730e2d982c196488e456120ab6edc6 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// TMW2 Script
//
// @rentitem <item> <time>
// Rents an <item> for <time> seconds
// 1 hour: 3600s
// 1 day: 86400s
// 1 month: 2592000s

-	script	@rentitem	32767,{
    end;

OnCall:
    //.@request$ = "";
	//.@request$ += implode(.@atcmd_parameters$, " ");

    .@item=atoi(.@atcmd_parameters$[0]);
    .@time=atoi(.@atcmd_parameters$[1]);

    if (!.@item || !.@time) {
        dispbottom l("@rentitem <item numeric id> <time in seconds>");
        end;
    }

    // Limiting to 365 days max
    .@time=limit(15, .@time, 31536000);

    rentitem(.@item, .@time);
    end;

OnCraftBypass:
    if (getarraysize(.@atcmd_parameters$) < 8) {
        dispbottom l("Usage: @craft item opt1 val1 opt2 val2 opt3 val3 opt4 val4");
        end;
    }

    .@item=atoi(.@atcmd_parameters$[0]);
    .@opt1=atoi(.@atcmd_parameters$[1]);
    .@val1=atoi(.@atcmd_parameters$[2]);
    .@opt2=atoi(.@atcmd_parameters$[3]);
    .@val2=atoi(.@atcmd_parameters$[4]);
    .@opt3=atoi(.@atcmd_parameters$[5]);
    .@val3=atoi(.@atcmd_parameters$[6]);
    .@opt4=atoi(.@atcmd_parameters$[7]);
    .@val4=atoi(.@atcmd_parameters$[8]);
    CsysNpcCraft(.@item, .@opt1, .@val1, .@opt2, .@val2,
                 .@opt3, .@val3, .@opt4, .@val4);
    end;

OnCraftSuper:
    if (getarraysize(.@atcmd_parameters$) < 8) {
        dispbottom l("Usage: @craft2 item refine opt1 val1 opt2 val2 opt3 val3 opt4 val4 opt5 val5");
        end;
    }
    .@item=atoi(.@atcmd_parameters$[0]);
    .@refi=atoi(.@atcmd_parameters$[1]);
    .@crd1=atoi(.@atcmd_parameters$[2]);
    .@crd2=atoi(.@atcmd_parameters$[3]);
    .@crd3=atoi(.@atcmd_parameters$[4]);
    .@crd4=atoi(.@atcmd_parameters$[5]);
    .@opt1=atoi(.@atcmd_parameters$[6]);
    .@val1=atoi(.@atcmd_parameters$[7]);
    .@opt2=atoi(.@atcmd_parameters$[8]);
    .@val2=atoi(.@atcmd_parameters$[9]);
    .@opt3=atoi(.@atcmd_parameters$[10]);
    .@val3=atoi(.@atcmd_parameters$[11]);
    .@opt4=atoi(.@atcmd_parameters$[12]);
    .@val4=atoi(.@atcmd_parameters$[13]);
    .@opt5=atoi(.@atcmd_parameters$[14]);
    .@val5=atoi(.@atcmd_parameters$[15]);
    getitem(.@item, 1, 1, .@refi, 0, .@crd1, .@crd2, .@crd3, .@crd4);
    delinventorylist(); // Needed, because we'll rely on rfind()
    getinventorylist();
    .@index=array_rfind(@inventorylist_id, .@item);

    // Apply the bonuses if needed
    if (.@opt1)
        setitemoptionbyindex(.@index, 0, .@opt1, .@val1);
    if (.@opt2)
        setitemoptionbyindex(.@index, 1, .@opt2, .@val2);
    if (.@opt3)
        setitemoptionbyindex(.@index, 2, .@opt3, .@val3);
    if (.@opt4)
        setitemoptionbyindex(.@index, 3, .@opt4, .@val4);
    if (.@opt5)
        setitemoptionbyindex(.@index, 4, .@opt5, .@val5);
    end;

OnInit:
    bindatcmd "rentitem", "@rentitem::OnCall", 80, 99, 1;
    bindatcmd "craft", "@rentitem::OnCraftBypass", 99, 99, 1;
    bindatcmd "craft2", "@rentitem::OnCraftSuper", 99, 99, 1;
    end;
}