summaryrefslogtreecommitdiff
path: root/npc/boss/manamarket.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/boss/manamarket.txt')
-rw-r--r--npc/boss/manamarket.txt107
1 files changed, 107 insertions, 0 deletions
diff --git a/npc/boss/manamarket.txt b/npc/boss/manamarket.txt
new file mode 100644
index 000000000..6f9f3a940
--- /dev/null
+++ b/npc/boss/manamarket.txt
@@ -0,0 +1,107 @@
+// TMW2 Scripts.
+// Author:
+// Jesusalva
+// Description:
+// ManaMarket sketch
+
+boss,41,41,0 script ManaMarket NPC_TEDDYGIRL,{
+ function MMCooldown;
+ function MMBuy;
+ function MMBuyMenu;
+
+ if (!is_staff()) end;
+ mesn;
+ mesq l("Hello! How can I help you?");
+ if (MM_DELAY > gettimetick(2)) close;
+ next;
+ select
+ l("Buy"),
+ l("Sell"),
+ l("Nothing");
+ mes "";
+ if (@menu == 1)
+ MMBuy();
+ close;
+
+
+// Set the cooldown value to the same as interserver value
+function MMCooldown {
+ MM_DELAY=gettimetick(2)+300;
+ return;
+}
+
+// MMBuy(page=0)
+function MMBuy {
+ .@p=getarg(0,0);
+ .@v=MMBuyMenu(.@p);
+
+ // Special results
+ switch (.@v) {
+ case -1:
+ return;
+ case -2:
+ // FIXME
+ MMBuy(.@p+1);
+ break;
+ default:
+ break;
+ }
+
+ .@it=$@MM_nameid[.@v];
+ // Can't buy stuff you already have
+ if (countitem(.@it)) {
+ mesn;
+ mesq l("You already have this.");
+ return;
+ }
+
+
+ // Report
+ mesn;
+ mesq l("Purchase %02d %s for %d GP?",
+ $@MM_amount[.@v], getitemlink(.@it), $@MM_price[.@v]);
+ next;
+ if (askyesno() == ASK_YES) {
+ // TODO: Check if still in stock
+ mesn;
+ mesq l("Sorry. The arrays can't have zeros.");
+ // getitem2
+ }
+ return;
+}
+
+// MMBuyMenu ( page=0 )
+function MMBuyMenu {
+ deletearray @mm_menu$;
+ setarray @mm_menu$, l("Cancel"), -1;
+ .@pg=getarg(0, 0);
+ .@limit=min(getarraysize($@MM_id), (.@pg+1)*20);
+
+ // Prepare the information array
+ for (.@i=.@pg*20; .@i < .@limit; .@i++) {
+ //@mm_menu$+=getitemname($@MM_nameid[.@i])+":";
+ array_push(@mm_menu$, getitemname($@MM_nameid[.@i]));
+ array_push(@mm_menu$, str(.@i));
+ }
+
+ // Still more pages
+ if (.@limit < getarraysize($@MM_id)) {
+ array_push(@mm_menu$, "Next Page >>");
+ array_push(@mm_menu$, -2);
+ }
+
+ // Handle input
+ menuint2("@mm_menu$");
+ deletearray @mm_menu$;
+ return @menuret;
+}
+
+OnInit:
+ .distance=6;
+ .sex = G_FEMALE;
+
+ // Load ManaMarket (max 100 entries)
+ .@nb = query_sql("SELECT `id`, `account_id`, `price`, `expire_time`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `opt_idx0`, `opt_val0`, `opt_idx1`, `opt_val1`, `opt_idx2`, `opt_val2`, `opt_idx3`, `opt_val3`, `opt_idx4`, `opt_val4` FROM `manamarket` ORDER BY `id` DESC LIMIT 100", $@MM_id, $@MM_account_id, $@MM_price, $@MM_expire_time, $@MM_nameid, $@MM_amount, $@MM_equip, $@MM_identify, $@MM_refine, $@MM_attribute, $@MM_card0, $@MM_card1, $@MM_card2, $@MM_card3, $@MM_opt_idx0, $@MM_opt_val0, $@MM_opt_idx1, $@MM_opt_val1, $@MM_opt_idx2, $@MM_opt_val2, $@MM_opt_idx3, $@MM_opt_val3, $@MM_opt_idx4, $@MM_opt_val4);
+ end;
+}
+