Emistry icon

[RO] SQL Mall 1.5

Emistry | PRO | 10/22/22 04:13:03 PM UTC | 0 ⭐ | 636 👁️ | Never ⏰ | []
C |

14.19 KB

|

Source Code

|

0 👍

/

0 👎

// https://rathena.org/board/topic/107660-r-sql-mall/
 
-   script  all_in_one_shop_main    -1,{
    
    // Shop NPC Name
    function    func_ShopTypeName   {
        switch (getarg(0, -1)) {
            case IT_HEALING: return "Healing";
            case IT_USABLE: return "";
            case IT_ETC: return "Etc";
            case IT_WEAPON: return "";
            case IT_ARMOR: return "Armor";
            case IT_CARD: return "Card";
            case IT_PETEGG: return "Petegg";
            case IT_PETARMOR: return "Petarmor";
            case IT_AMMO: return "Ammo";
            case IT_DELAYCONSUME: return "Delayconsume";
            case IT_SHADOWGEAR: return "Shadowgear";
            case IT_CASH: return "Cash";
            default: return "Misc";
        }
    }
    
    // Shop NPC Sprite ID
    function    func_ShopClassID    {
        switch (getarg(0, -1)) {
            case IT_HEALING: return -1;
            case IT_USABLE: return 4_F_KAFRA2;
            case IT_ETC: return 4_F_KAFRA3;
            case IT_WEAPON: return 4_F_KAFRA4;
            case IT_ARMOR: return 4_F_KAFRA5;
            case IT_CARD: return 4_F_KAFRA6;
            case IT_PETEGG: return 4_F_KAFRA7;
            case IT_PETARMOR: return 4_F_KAFRA8;
            case IT_AMMO: return 4_F_KAFRA9;
            case IT_DELAYCONSUME: return 4_F_KAFRA2;
            case IT_SHADOWGEAR: return 4_F_KAFRA5;
            case IT_CASH: return -1;
            default: return rand(-1, 4_F_KAFRA9);
        }
    }
    
    OnInit:
        .is_renewal_db = 1;
        .max_shop_item = 100;
        .blacklist_item$ = "5001,5002,5003";
        
        sleep 1000; // delays
        callsub(OnLoad, IT_HEALING);
        callsub(OnLoad, IT_USABLE);
        callsub(OnLoad, IT_ETC);
        callsub(OnLoad, IT_WEAPON);
        callsub(OnLoad, IT_ARMOR);
        callsub(OnLoad, IT_CARD);
        callsub(OnLoad, IT_PETEGG);
        callsub(OnLoad, IT_PETARMOR);
        callsub(OnLoad, IT_AMMO);
        callsub(OnLoad, IT_DELAYCONSUME);
        callsub(OnLoad, IT_SHADOWGEAR);
        callsub(OnLoad, IT_CASH);
        end;
 
    OnLoad:
        .@type = getarg(0, -1);
        .@type_name$ = func_ShopTypeName(.@type);
        
        .@npc = 1;
        .@sql$ = "SELECT `id`, `weight`, `attack`, " + (.is_renewal_db ? "`magic_attack`" : "`attack`") + ", `slots`, `weapon_level`, `defense`, `equip_level_min`, `script`, `equip_script`, `unequip_script` "
            + "FROM `" + (.is_renewal_db ? "item_db_re" : "item_db") + "` "
            + "WHERE `type` = '"+escape_sql(.@type_name$)+"'";
        if (.blacklist_item$ != "")
            .@sql$ = .@sql$ + " AND `id` NOT IN ("+escape_sql(.blacklist_item$)+")";
        .@sql$ = .@sql$ + " ORDER BY `name_english`";
        
        .@size = query_sql(.@sql$, .@id, .@weight, .@atk, .@matk, .@slot, .@weapon_level, .@defense, .@equip_level_min, .@script$, .@equip_script$, .@unequip_script$);
        
        if (.@size > 0) {
            .@npc_count = (.@size / .max_shop_item);
        
            freeloop(1);
            do {
                .@x = 0;
                
                .@npc_shop_name$ = "Shop#t_"+.@type+"_"+.@npc;
                if (getmapxy(.@map$, .@map_x, .@map_y, BL_NPC, .@npc_shop_name$)) {
                    errormes "SQL Mall - NPC not found - " + .@npc_shop_name$;
                }
                else {
                    npcshopdelitem .@npc_shop_name$, 909;
                        
                    do {
                        .@index = (.@npc * .max_shop_item + .@x);
                        .@total_cost = 0;
                        
                        // cost calculations
                        .@total_cost += ((.@weight[.@index] / 10) * 1000);
                        .@total_cost += ((.@atk[.@index] / 100) * 5000);
                        if (.is_renewal_db)
                            .@total_cost += ((.@matk[.@index] / 100) * 5000);
                        .@total_cost += (.@slots[.@index] * 3000);
                        .@total_cost += (.@weapon_level[.@index] * 2000);
                        .@total_cost += ((.@defense[.@index] / 10) * 1000);
                        .@total_cost += ((.@equip_level_min[.@index] / 10) * 10000);
                
                        // effect count.
                        .@total_cost += (countstr(.@script$[.@index], "bonus") * 1000);
                        .@total_cost += (countstr(.@equip_script$[.@index], "bonus") * 1000);
                        .@total_cost += (countstr(.@unequip_script$[.@index], "bonus") * 1000);
                        .@total_cost += (countstr(.@unequip_script$[.@index], "heal") * 100);
                        .@total_cost += (countstr(.@unequip_script$[.@index], "warp") * 1000);
                        
                        if (.@total_cost > 0)
                            npcshopadditem .@npc_shop_name$, .@id[.@index], .@total_cost;
                        .@x++;
                        .@total_item_count++;
                    } while (.@x < .max_shop_item && .@index < .@size);
                    setnpcdisplay(.@npc_shop_name$, .@type_name$+" "+.@npc+"#t_"+.@type+"_"+.@npc, func_ShopClassID(.@type));
                }
                .@npc++;
            } while (.@npc <= .@npc_count);
            freeloop(0);
            
        }
        
        // Remove excessive NPC
        while (!getmapxy(.@map$, .@map_x, .@map_y, BL_NPC, "Shop#t_"+.@type+"_"+.@npc) || .@npc <= .@npc_count) {
            disablenpc "Shop#t_"+.@type+"_"+.@npc;
            .@npc++;
        }
        
        // debugmes "SQL Mall - " + func_ShopTypeName(.@type) + " - Loaded " + F_InsertComma(.@total_item_count) + " Item(s)";
        return;
 
}
 
 
// Add more if needed (follow the name and numbering)
 
prt_fild08,201,40,5 shop    Shop#t_0_1  -1,909:-1
prt_fild08,202,40,5 shop    Shop#t_0_2  -1,909:-1
prt_fild08,203,40,5 shop    Shop#t_0_3  -1,909:-1
prt_fild08,204,40,5 shop    Shop#t_0_4  -1,909:-1
 
prt_fild08,201,42,5 shop    Shop#t_2_1  -1,909:-1
prt_fild08,202,42,5 shop    Shop#t_2_2  -1,909:-1
prt_fild08,203,42,5 shop    Shop#t_2_3  -1,909:-1
prt_fild08,204,42,5 shop    Shop#t_2_4  -1,909:-1
prt_fild08,205,42,5 shop    Shop#t_2_5  -1,909:-1
prt_fild08,206,42,5 shop    Shop#t_2_6  -1,909:-1
prt_fild08,207,42,5 shop    Shop#t_2_7  -1,909:-1
prt_fild08,208,42,5 shop    Shop#t_2_8  -1,909:-1
prt_fild08,209,42,5 shop    Shop#t_2_9  -1,909:-1
prt_fild08,210,42,5 shop    Shop#t_2_10 -1,909:-1
 
prt_fild08,201,44,5 shop    Shop#t_3_1  -1,909:-1
prt_fild08,202,44,5 shop    Shop#t_3_2  -1,909:-1
prt_fild08,203,44,5 shop    Shop#t_3_3  -1,909:-1
prt_fild08,204,44,5 shop    Shop#t_3_4  -1,909:-1
prt_fild08,205,44,5 shop    Shop#t_3_5  -1,909:-1
prt_fild08,206,44,5 shop    Shop#t_3_6  -1,909:-1
prt_fild08,207,44,5 shop    Shop#t_3_7  -1,909:-1
prt_fild08,208,44,5 shop    Shop#t_3_8  -1,909:-1
prt_fild08,209,44,5 shop    Shop#t_3_9  -1,909:-1
prt_fild08,210,44,5 shop    Shop#t_3_10 -1,909:-1
prt_fild08,211,44,5 shop    Shop#t_3_11 -1,909:-1
prt_fild08,212,44,5 shop    Shop#t_3_12 -1,909:-1
prt_fild08,213,44,5 shop    Shop#t_3_13 -1,909:-1
prt_fild08,214,44,5 shop    Shop#t_3_14 -1,909:-1
prt_fild08,215,44,5 shop    Shop#t_3_15 -1,909:-1
prt_fild08,216,44,5 shop    Shop#t_3_16 -1,909:-1
prt_fild08,217,44,5 shop    Shop#t_3_17 -1,909:-1
prt_fild08,218,44,5 shop    Shop#t_3_18 -1,909:-1
prt_fild08,219,44,5 shop    Shop#t_3_19 -1,909:-1
prt_fild08,220,44,5 shop    Shop#t_3_20 -1,909:-1
prt_fild08,221,44,5 shop    Shop#t_3_21 -1,909:-1
prt_fild08,222,44,5 shop    Shop#t_3_22 -1,909:-1
prt_fild08,223,44,5 shop    Shop#t_3_23 -1,909:-1
prt_fild08,224,44,5 shop    Shop#t_3_24 -1,909:-1
prt_fild08,225,44,5 shop    Shop#t_3_25 -1,909:-1
prt_fild08,226,44,5 shop    Shop#t_3_26 -1,909:-1
prt_fild08,227,44,5 shop    Shop#t_3_27 -1,909:-1
prt_fild08,228,44,5 shop    Shop#t_3_28 -1,909:-1
prt_fild08,229,44,5 shop    Shop#t_3_29 -1,909:-1
 
prt_fild08,201,46,5 shop    Shop#t_4_1  -1,909:-1
prt_fild08,202,46,5 shop    Shop#t_4_2  -1,909:-1
prt_fild08,203,46,5 shop    Shop#t_4_3  -1,909:-1
prt_fild08,204,46,5 shop    Shop#t_4_4  -1,909:-1
prt_fild08,205,46,5 shop    Shop#t_4_5  -1,909:-1
prt_fild08,206,46,5 shop    Shop#t_4_6  -1,909:-1
prt_fild08,207,46,5 shop    Shop#t_4_7  -1,909:-1
prt_fild08,208,46,5 shop    Shop#t_4_8  -1,909:-1
prt_fild08,209,46,5 shop    Shop#t_4_9  -1,909:-1
prt_fild08,210,46,5 shop    Shop#t_4_10 -1,909:-1
prt_fild08,211,46,5 shop    Shop#t_4_11 -1,909:-1
prt_fild08,212,46,5 shop    Shop#t_4_12 -1,909:-1
prt_fild08,213,46,5 shop    Shop#t_4_13 -1,909:-1
prt_fild08,214,46,5 shop    Shop#t_4_14 -1,909:-1
prt_fild08,215,46,5 shop    Shop#t_4_15 -1,909:-1
prt_fild08,216,46,5 shop    Shop#t_4_16 -1,909:-1
prt_fild08,217,46,5 shop    Shop#t_4_17 -1,909:-1
prt_fild08,218,46,5 shop    Shop#t_4_18 -1,909:-1
prt_fild08,219,46,5 shop    Shop#t_4_19 -1,909:-1
prt_fild08,220,46,5 shop    Shop#t_4_20 -1,909:-1
prt_fild08,221,46,5 shop    Shop#t_4_21 -1,909:-1
prt_fild08,222,46,5 shop    Shop#t_4_22 -1,909:-1
prt_fild08,223,46,5 shop    Shop#t_4_23 -1,909:-1
prt_fild08,224,46,5 shop    Shop#t_4_24 -1,909:-1
prt_fild08,225,46,5 shop    Shop#t_4_25 -1,909:-1
prt_fild08,226,46,5 shop    Shop#t_4_26 -1,909:-1
prt_fild08,227,46,5 shop    Shop#t_4_27 -1,909:-1
prt_fild08,228,46,5 shop    Shop#t_4_28 -1,909:-1
prt_fild08,229,46,5 shop    Shop#t_4_29 -1,909:-1
prt_fild08,230,46,5 shop    Shop#t_4_30 -1,909:-1
prt_fild08,231,46,5 shop    Shop#t_4_31 -1,909:-1
prt_fild08,232,46,5 shop    Shop#t_4_32 -1,909:-1
prt_fild08,233,46,5 shop    Shop#t_4_33 -1,909:-1
prt_fild08,234,46,5 shop    Shop#t_4_34 -1,909:-1
prt_fild08,235,46,5 shop    Shop#t_4_35 -1,909:-1
prt_fild08,236,46,5 shop    Shop#t_4_36 -1,909:-1
prt_fild08,237,46,5 shop    Shop#t_4_37 -1,909:-1
prt_fild08,238,46,5 shop    Shop#t_4_38 -1,909:-1
prt_fild08,239,46,5 shop    Shop#t_4_39 -1,909:-1
prt_fild08,240,46,5 shop    Shop#t_4_40 -1,909:-1
prt_fild08,241,46,5 shop    Shop#t_4_41 -1,909:-1
prt_fild08,242,46,5 shop    Shop#t_4_42 -1,909:-1
prt_fild08,243,46,5 shop    Shop#t_4_43 -1,909:-1
prt_fild08,244,46,5 shop    Shop#t_4_44 -1,909:-1
prt_fild08,245,46,5 shop    Shop#t_4_45 -1,909:-1
prt_fild08,246,46,5 shop    Shop#t_4_46 -1,909:-1
prt_fild08,247,46,5 shop    Shop#t_4_47 -1,909:-1
prt_fild08,248,46,5 shop    Shop#t_4_48 -1,909:-1
prt_fild08,249,46,5 shop    Shop#t_4_49 -1,909:-1
prt_fild08,240,46,5 shop    Shop#t_4_50 -1,909:-1
prt_fild08,241,46,5 shop    Shop#t_4_51 -1,909:-1
prt_fild08,242,46,5 shop    Shop#t_4_52 -1,909:-1
prt_fild08,243,46,5 shop    Shop#t_4_53 -1,909:-1
prt_fild08,244,46,5 shop    Shop#t_4_54 -1,909:-1
prt_fild08,245,46,5 shop    Shop#t_4_55 -1,909:-1
prt_fild08,246,46,5 shop    Shop#t_4_56 -1,909:-1
prt_fild08,247,46,5 shop    Shop#t_4_57 -1,909:-1
prt_fild08,248,46,5 shop    Shop#t_4_58 -1,909:-1
prt_fild08,249,46,5 shop    Shop#t_4_59 -1,909:-1
 
 
prt_fild08,201,48,5 shop    Shop#t_5_1  -1,909:-1
prt_fild08,202,48,5 shop    Shop#t_5_2  -1,909:-1
prt_fild08,203,48,5 shop    Shop#t_5_3  -1,909:-1
prt_fild08,204,48,5 shop    Shop#t_5_4  -1,909:-1
prt_fild08,205,48,5 shop    Shop#t_5_5  -1,909:-1
prt_fild08,206,48,5 shop    Shop#t_5_6  -1,909:-1
prt_fild08,207,48,5 shop    Shop#t_5_7  -1,909:-1
prt_fild08,208,48,5 shop    Shop#t_5_8  -1,909:-1
prt_fild08,209,48,5 shop    Shop#t_5_9  -1,909:-1
prt_fild08,210,48,5 shop    Shop#t_5_10 -1,909:-1
prt_fild08,211,48,5 shop    Shop#t_5_11 -1,909:-1
prt_fild08,212,48,5 shop    Shop#t_5_12 -1,909:-1
prt_fild08,213,48,5 shop    Shop#t_5_13 -1,909:-1
prt_fild08,214,48,5 shop    Shop#t_5_14 -1,909:-1
prt_fild08,215,48,5 shop    Shop#t_5_15 -1,909:-1
prt_fild08,216,48,5 shop    Shop#t_5_16 -1,909:-1
prt_fild08,217,48,5 shop    Shop#t_5_17 -1,909:-1
prt_fild08,218,48,5 shop    Shop#t_5_18 -1,909:-1
prt_fild08,219,48,5 shop    Shop#t_5_19 -1,909:-1
prt_fild08,220,48,5 shop    Shop#t_5_20 -1,909:-1
prt_fild08,221,48,5 shop    Shop#t_5_21 -1,909:-1
prt_fild08,222,48,5 shop    Shop#t_5_22 -1,909:-1
prt_fild08,223,48,5 shop    Shop#t_5_23 -1,909:-1
prt_fild08,224,48,5 shop    Shop#t_5_24 -1,909:-1
prt_fild08,225,48,5 shop    Shop#t_5_25 -1,909:-1
prt_fild08,226,48,5 shop    Shop#t_5_26 -1,909:-1
prt_fild08,227,48,5 shop    Shop#t_5_27 -1,909:-1
prt_fild08,228,48,5 shop    Shop#t_5_28 -1,909:-1
prt_fild08,229,48,5 shop    Shop#t_5_29 -1,909:-1
prt_fild08,230,48,5 shop    Shop#t_5_30 -1,909:-1
prt_fild08,231,48,5 shop    Shop#t_5_31 -1,909:-1
prt_fild08,232,48,5 shop    Shop#t_5_32 -1,909:-1
prt_fild08,233,48,5 shop    Shop#t_5_33 -1,909:-1
prt_fild08,234,48,5 shop    Shop#t_5_34 -1,909:-1
prt_fild08,235,48,5 shop    Shop#t_5_35 -1,909:-1
prt_fild08,236,48,5 shop    Shop#t_5_36 -1,909:-1
prt_fild08,237,48,5 shop    Shop#t_5_37 -1,909:-1
prt_fild08,238,48,5 shop    Shop#t_5_38 -1,909:-1
prt_fild08,239,48,5 shop    Shop#t_5_39 -1,909:-1
 
prt_fild08,201,50,5 shop    Shop#t_6_1  -1,909:-1
prt_fild08,202,50,5 shop    Shop#t_6_2  -1,909:-1
prt_fild08,203,50,5 shop    Shop#t_6_3  -1,909:-1
prt_fild08,204,50,5 shop    Shop#t_6_4  -1,909:-1
prt_fild08,205,50,5 shop    Shop#t_6_5  -1,909:-1
prt_fild08,206,50,5 shop    Shop#t_6_6  -1,909:-1
prt_fild08,207,50,5 shop    Shop#t_6_7  -1,909:-1
prt_fild08,208,50,5 shop    Shop#t_6_8  -1,909:-1
prt_fild08,209,50,5 shop    Shop#t_6_9  -1,909:-1
prt_fild08,210,50,5 shop    Shop#t_6_10 -1,909:-1
prt_fild08,211,50,5 shop    Shop#t_6_11 -1,909:-1
prt_fild08,212,50,5 shop    Shop#t_6_12 -1,909:-1
prt_fild08,213,50,5 shop    Shop#t_6_13 -1,909:-1
prt_fild08,214,50,5 shop    Shop#t_6_14 -1,909:-1
prt_fild08,215,50,5 shop    Shop#t_6_15 -1,909:-1
prt_fild08,216,50,5 shop    Shop#t_6_16 -1,909:-1
prt_fild08,217,50,5 shop    Shop#t_6_17 -1,909:-1
prt_fild08,218,50,5 shop    Shop#t_6_18 -1,909:-1
prt_fild08,219,50,5 shop    Shop#t_6_19 -1,909:-1
prt_fild08,220,50,5 shop    Shop#t_6_20 -1,909:-1
prt_fild08,221,50,5 shop    Shop#t_6_21 -1,909:-1
prt_fild08,222,50,5 shop    Shop#t_6_22 -1,909:-1
prt_fild08,223,50,5 shop    Shop#t_6_23 -1,909:-1
prt_fild08,224,50,5 shop    Shop#t_6_24 -1,909:-1
prt_fild08,225,50,5 shop    Shop#t_6_25 -1,909:-1
prt_fild08,226,50,5 shop    Shop#t_6_26 -1,909:-1
prt_fild08,227,50,5 shop    Shop#t_6_27 -1,909:-1
prt_fild08,228,50,5 shop    Shop#t_6_28 -1,909:-1
prt_fild08,229,50,5 shop    Shop#t_6_29 -1,909:-1
 
prt_fild08,201,52,5 shop    Shop#t_7_1  -1,909:-1
 
prt_fild08,201,54,5 shop    Shop#t_8_1  -1,909:-1
 
prt_fild08,201,56,5 shop    Shop#t_10_1 -1,909:-1
prt_fild08,202,56,5 shop    Shop#t_10_2 -1,909:-1
 
prt_fild08,201,58,5 shop    Shop#t_11_1 -1,909:-1
prt_fild08,202,58,5 shop    Shop#t_11_2 -1,909:-1
prt_fild08,203,58,5 shop    Shop#t_11_3 -1,909:-1
prt_fild08,204,58,5 shop    Shop#t_11_4 -1,909:-1
 
prt_fild08,201,60,5 shop    Shop#t_12_1 -1,909:-1
prt_fild08,202,60,5 shop    Shop#t_12_2 -1,909:-1
prt_fild08,203,60,5 shop    Shop#t_12_3 -1,909:-1
prt_fild08,204,60,5 shop    Shop#t_12_4 -1,909:-1
prt_fild08,205,60,5 shop    Shop#t_12_5 -1,909:-1
prt_fild08,206,60,5 shop    Shop#t_12_6 -1,909:-1
prt_fild08,207,60,5 shop    Shop#t_12_7 -1,909:-1
prt_fild08,208,60,5 shop    Shop#t_12_8 -1,909:-1
prt_fild08,209,60,5 shop    Shop#t_12_9 -1,909:-1
 
prt_fild08,201,62,5 shop    Shop#t_18_1 -1,909:-1
prt_fild08,202,62,5 shop    Shop#t_18_2 -1,909:-1
prt_fild08,203,62,5 shop    Shop#t_18_3 -1,909:-1
prt_fild08,204,62,5 shop    Shop#t_18_4 -1,909:-1
prt_fild08,205,62,5 shop    Shop#t_18_5 -1,909:-1
prt_fild08,206,62,5 shop    Shop#t_18_6 -1,909:-1
prt_fild08,207,62,5 shop    Shop#t_18_7 -1,909:-1
prt_fild08,208,62,5 shop    Shop#t_18_8 -1,909:-1
prt_fild08,209,62,5 shop    Shop#t_18_9 -1,909:-1
prt_fild08,210,62,5 shop    Shop#t_18_10    -1,909:-1
prt_fild08,211,62,5 shop    Shop#t_18_11    -1,909:-1
prt_fild08,212,62,5 shop    Shop#t_18_12    -1,909:-1
prt_fild08,213,62,5 shop    Shop#t_18_13    -1,909:-1
prt_fild08,214,62,5 shop    Shop#t_18_14    -1,909:-1
prt_fild08,215,62,5 shop    Shop#t_18_15    -1,909:-1
prt_fild08,216,62,5 shop    Shop#t_18_16    -1,909:-1
prt_fild08,217,62,5 shop    Shop#t_18_17    -1,909:-1
prt_fild08,218,62,5 shop    Shop#t_18_18    -1,909:-1
prt_fild08,219,62,5 shop    Shop#t_18_19    -1,909:-1
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎