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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
function script PCtoNPCRange {
@npc_check = 0;
if(!@npc_distance) set @npc_distance, getarg(0, 4); // <== default distance
if(@npc_distance < 0) set @npc_distance, readparam2(UDT_ATKRANGE);
.@x=getvariableofnpc(.x, strnpcinfo(0));
.@y=getvariableofnpc(.y, strnpcinfo(0));
if (isin(getmap(), .@x, .@y, @npc_distance))
goto L_Return;
@npc_check = 1;
@dnpc_name$ = strnpcinfo(1);
if(@dnpc_name$ != "") goto L_Named;
message strcharinfo(0), "Server : ##BYou need to move closer to interact with this npc.";
goto L_Return;
L_Named:
npctalk3 l(b("Please move closer."));
goto L_Return;
L_Return:
@dnpc_name$ = "";
@npc_distance = 0;
if (@npc_check) {
@npc_check = 0;
end;
}
return;
}
function script CheckInventory {
@del_loop = 0;
@get_loop = 0;
@delitem_loop = 0;
@getitem_loop = 0;
@check_fail = 0;
@msg_loop = 0;
if (getarraysize(@delitem_ids))
goto L_DelItemsLoop;
goto L_CheckGet;
L_DelItemsLoop:
if(countitem(@delitem_ids[@delitem_loop]) >= @delitem_counts[@delitem_loop])
goto L_DelLoopAgain;
goto L_ReturnMissing;
L_DelLoopAgain:
@delitem_loop = (@delitem_loop + 1);
if(@delitem_loop == getarraysize(@delitem_ids))
goto L_CheckGet;
goto L_DelItemsLoop;
L_CheckGet:
if (getarraysize(@getitem_ids))
goto L_CheckWeight;
goto L_DelCheck;
L_CheckWeight:
getinventorylist;
if (100 < (@inventorylist_count + getarraysize(@getitem_ids)))
goto L_ReturnSpace;
goto L_GetItemsLoop;
L_GetItemsLoop:
if (checkweight(@getitem_ids[@getitem_loop], @getitem_counts[@getitem_loop]))
goto L_GetLoopAgain;
goto L_ReturnWeight;
L_GetLoopAgain:
@getitem_loop = (@getitem_loop + 1);
if(@getitem_loop == getarraysize(@getitem_ids))
goto L_DelCheck;
goto L_GetItemsLoop;
L_DelCheck:
if (getarraysize(@delitem_ids))
goto L_DelLoop;
goto L_CheckGet2;
L_DelLoop:
delitem @delitem_ids[@del_loop], @delitem_counts[@del_loop];
goto L_DelAgain;
L_DelAgain:
@del_loop = (@del_loop + 1);
if(@del_loop == getarraysize(@delitem_ids))
goto L_GetLoop;
goto L_DelLoop;
L_CheckGet2:
if (getarraysize(@getitem_ids))
goto L_GetLoop;
goto L_Return;
L_GetLoop:
misceffect FX_GETITEM, strcharinfo(0);
getitem @getitem_ids[@get_loop], @getitem_counts[@get_loop];
goto L_GetAgain;
L_GetAgain:
@get_loop = (@get_loop + 1);
if(@get_loop == getarraysize(@getitem_ids))
goto L_Return;
goto L_GetLoop;
L_ReturnMissing:
@check_fail = 1;
mesq l("You are missing required items.");
goto L_MissingMsg;
L_MissingMsg:
mes "[@@"+@delitem_ids[@msg_loop]+"|"+getitemlink(@delitem_ids[@msg_loop])+"@@] "+countitem(getitemlink(@delitem_ids[@msg_loop]))+"/"+@delitem_counts[@msg_loop];
goto L_NextMsgCheck;
L_NextMsgCheck:
@msg_loop = (@msg_loop + 1);
if(@msg_loop == getarraysize(@delitem_ids))
goto L_Return;
goto L_MissingMsg;
L_ReturnWeight:
mesq l("You need to be carrying less weight.");
next;
@check_fail = 1;
goto L_Return;
L_ReturnSpace:
mesq l("You need more room in your inventory.");
next;
@check_fail = 1;
goto L_Return;
L_Return:
cleararray @delitem_ids, "", getarraysize(@delitem_ids);
cleararray @delitem_counts, "", getarraysize(@delitem_counts);
cleararray @getitem_ids, "", getarraysize(@getitem_ids);
cleararray @getitem_counts, "", getarraysize(@getitem_counts);
return;
}
|