1 | - shop dyn_shop1 -1,501:50 |
---|
2 | |
---|
3 | prontera,181,200,4 script Dynamic Shop 123,{ |
---|
4 | callshop "dyn_shop1",0; |
---|
5 | npcshopattach "dyn_shop1"; |
---|
6 | end; |
---|
7 | |
---|
8 | OnSellItem: |
---|
9 | for(set @i, 0; @i < getarraysize(@sold_nameid); set @i, @i + 1){ |
---|
10 | if(countitem(@sold_nameid[@i]) < @sold_quantity[@i] && @sold_quantity[@i] <= 0){ |
---|
11 | mes "omgh4x!"; |
---|
12 | close; |
---|
13 | } |
---|
14 | if(@sold_nameid[@i] == 501){ |
---|
15 | set $@rpotsleft, $@rpotsleft + @sold_quantity[@i]; |
---|
16 | set Zeny, Zeny + @sold_quantity[@i]*20; |
---|
17 | delitem 501, @sold_quantity[@i]; |
---|
18 | } else { |
---|
19 | if(@sold_nameid[@i] == 502){ |
---|
20 | set $@opotsleft, $@opotsleft + @sold_quantity[@i]; |
---|
21 | set Zeny, Zeny + @sold_quantity[@i]*100; |
---|
22 | delitem 502, @sold_quantity[@i]; |
---|
23 | } else { |
---|
24 | mes "Sorry, I don't need your items."; |
---|
25 | } |
---|
26 | } |
---|
27 | } |
---|
28 | deletearray @sold_quantity, getarraysize(@sold_quantity); |
---|
29 | deletearray @sold_nameid, getarraysize(@sold_nameid); |
---|
30 | mes "Deal completed."; |
---|
31 | close; |
---|
32 | |
---|
33 | OnBuyItem: |
---|
34 | for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){ |
---|
35 | if(@bought_quantity[@i] <= 0){ |
---|
36 | mes "omgh4x!"; |
---|
37 | end; |
---|
38 | } |
---|
39 | if(@bought_nameid[@i] == 501){ |
---|
40 | if(@bought_quantity[@i] > $@rpotsleft){ |
---|
41 | if($@rpotsleft > 0){ |
---|
42 | set @bought_quantity[@i], $@rpotsleft; |
---|
43 | } else { |
---|
44 | mes "We are out of red potions!"; |
---|
45 | close; |
---|
46 | } |
---|
47 | } |
---|
48 | if(Zeny >= 40*@bought_quantity[@i]){ |
---|
49 | set Zeny, Zeny - 40*@bought_quantity[@i]; |
---|
50 | getitem 501, @bought_quantity[@i]; |
---|
51 | set $@rpotsleft, $@rpotsleft - @bought_quantity[@i]; |
---|
52 | } else { |
---|
53 | mes "You have insufficient cash."; |
---|
54 | close; |
---|
55 | } |
---|
56 | } else { |
---|
57 | if(@bought_quantity[@i] > $@opotsleft){ |
---|
58 | if($@opotsleft > 0){ |
---|
59 | set @bought_quantity[@i], $@opotsleft; |
---|
60 | } else { |
---|
61 | mes "We are out of orange potions!"; |
---|
62 | close; |
---|
63 | } |
---|
64 | } |
---|
65 | if(Zeny >= 200*@bought_quantity[@i]){ |
---|
66 | set Zeny, Zeny - 200*@bought_quantity[@i]; |
---|
67 | getitem 502, @bought_quantity[@i]; |
---|
68 | set $@opotsleft, $@opotsleft - @bought_quantity[@i]; |
---|
69 | } else { |
---|
70 | mes "You have insufficient cash."; |
---|
71 | close; |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | deletearray @bought_quantity, getarraysize(@bought_quantity); |
---|
76 | deletearray @bought_nameid, getarraysize(@bought_nameid); |
---|
77 | mes "Trade done."; |
---|
78 | close; |
---|
79 | |
---|
80 | OnInit: |
---|
81 | npcshopitem "dyn_shop1", 501,40,502,200; |
---|
82 | set $@rpotsleft, 10; |
---|
83 | set $@opotsleft, 10; |
---|
84 | end; |
---|
85 | } |
---|