viewing paste Rentals Shop | Athena

Posted on the
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
-   shop    rental_shop -1,501:50
 
prontera,150,150,4  script  Rentals Shop    100,{
 
    callshop "rental_shop", 1;
    npcshopattach "rental_shop";
    end;
 
OnBuyItem:
    dispbottom "Rentals Shop: You can only buy one item at once.";
    setarray .@q[0], @bought_nameid[0], @bought_quantity[0];
    for (.@i = 0; .@i < getarraysize(.items_list); .@i++) {
        if (.@q[0] == .items_list[.@i]) {
            .@q[2] = .price_list[.@i];
        }
    }
    mes .@npc_name$ = "[Rentals Shop]";
    mes "Rental Item: "+getitemname(.@q[0]);
    mes "Rental Cost: "+.@q[2]+"x "+getitemname(.currency)+" for one day.";
    mes " ";
    mes "How many days do you want to rent it ?";
    next;
    if (input(.@day, 1, 365)) {
        mes .@npc_name$;
        mes "Invalid input days..";
        callsub ClearBought;
        close;
    }
    .@q[3] = .@day * .@q[2];
    mes .@npc_name$;
    mes "Rental Item: "+getitemname(.@q[0]);
    mes "Rental Cost: "+.@q[3]+"x "+getitemname(.currency)+" for "+.@day+" day"+((.@day > 1) ? "s" : "")+".";
    mes " ";
    mes "Still want to make the rent ?";
    next;
    if (select("Yes:No") == 2) {
        mes .@npc_name$;
        mes "All right, "+callfunc("F_Bye");
        callsub ClearBought;
        close;
    }
    if (countitem(.currency) < .@q[3]) {
        mes .@npc_name$;
        mes "I'm sorry, you haven't enought "+getitemname(.currency)+" to pay the rental";
        callsub ClearBought;
        close;
    }
    if (!checkweight(.@q[0], .@q[1])) {
        mes .@npc_name$;
        mes "You need more space in your inventory.";
        callsub ClearBought;
        close;
    }
    delitem .currency, .@q[3]; // delete items
    rentitem .@q[0], .@day * 86400; // rent an items. 86400 = 1 day in seconds
    callsub ClearBought;
    end;
    
ClearBought:
    deletearray @bought_quantity, getarraysize(@bought_quantity);
    deletearray @bought_nameid, getarraysize(@bought_nameid);
    return;
 
OnInit:
    // Configuration
    setarray .items_list, 1201, 1201, 1201; // items list that you want to sell.
    setarray .price_list,  100,  200,  300; // itens price that item you sell in the shop.
    .currency = 7227; // items that will be used as exchange currency
    
    // do not touch from here!!
    npcshopdelitem "rental_shop", 501;
    for (.@i = 0; .@i < getarraysize(.items_list); .@i++)
        npcshopadditem "rental_shop", .items_list[.@i], .price_list[.@i];
    end;
 
}
 
Viewed 1366 times, submitted by Guest.