viewing paste Unknown #14173 | 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 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
// Settings :
//  -   Only required to edit the ShopSetting() Function
//          Notes : You may also add / remove Menu ( If any ) 
//  -   Shop Currency can be either ItemID or Variable Name, but must write within Quotation Marks ( "" )
//          Ex. of Variable.    ->  Zeny , #CASHPOINTS , #KAFRAPOINTS , CustomVariable , #CustomVariable
//  -   ERROR Message are used to show Invalid Settings in your NPC.
 
 
// Leave this alone...
-   shop    Emistry_Shop    -1,512:100
 
 
quiz_02,355,379,5   script  Ticket Exchanger    757,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;
 
mes "Each Shop from the Menu may purchase using Mithril Coins";
mes "So, which shop you would like to look at it";
next;
// Menu Selection
select("Headgears");
 
ClearData();
ShopSettings( @menu );
npcshopitem "Emistry_Shop",512,100;
npcshopdelitem "Emistry_Shop",512;
for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
    npcshopadditem "Emistry_Shop",@ItemLists[.@i],@ItemCost[.@i];
mes "Please select your headgear";
CurrencyInfo( @Currency$ );
callshop "Emistry_Shop",1;
npcshopattach "Emistry_Shop";
end;
 
 
function    ShopSettings    {
    switch( getarg(0) ){
        Case 1:
            // Currency [ Item ID / Variable Name ]
            set @Currency$,"674";
            // Item ID Lists
            setarray @ItemLists[0],5137,5389,5800,5376,5423,5463,5574,5377,5155,2202,5518,5342;
            // Item Price
            setarray @ItemCost[0],75,75,75,100,125,60,90,90,90,60,120,40;
            break;
        Case 2:
            // Currency [ Item ID / Variable Name ]
            set @Currency$,"7227";
            // Item ID Lists
            setarray @ItemLists[0],2306,2302,2303,2304,2305,2301;
            // Item Price
            setarray @ItemCost[0],2,2,3,4,5,6;
            break;
        Case 3:
            // Currency [ Item ID / Variable Name ]
            set @Currency$,"#CASHPOINTS";
            // Item ID Lists
            setarray @ItemLists[0],2306,2302,2303,2304,2305,2301;
            // Item Price
            setarray @ItemCost[0],20,22,34,445,52,641;
            break;
        // Case 4,5,6.....etc...
        default:
            ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
            close;
    }
    
    
if( @Currency$ == "" )
    ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
    ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
return;
}
 
function    ErrorNotice {
    mes "^FF0000ERROR^000000 - "+getarg(0);
    mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
    close;
}
 
function    CurrencyInfo    {
    if( getitemname( atoi( getarg(0) ) ) != "null" ){
        mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
        mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
    }else if( getitemname( atoi( getarg(0) ) ) == "null" ){
        mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
        mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
    }
return;
}
 
function    ValidateCost    {
    if( getitemname( atoi( getarg(0) ) ) != "null" ){
        if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
    }else{
        if( getd( getarg(0) ) < getarg(1) ) return 1;
    }
return 0;
}
 
function ClearData  {
    set @Currency$,"";
    set @TotalCost,0;
    deletearray @bought_nameid[0],getarraysize( @bought_nameid );
    deletearray @bought_quantity[0],getarraysize( @bought_quantity );
    deletearray @ItemLists[0],getarraysize( @ItemLists );
    deletearray @ItemCost[0],getarraysize( @ItemCost );
return;
}
 
function    ValueConvert    {
    set .@num, atoi(""+getarg(0));
    if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
    set .@l, getstrlen(""+.@num);
    for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
        set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
            if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
    }
    return .@num$;
}
 
OnBuyItem:
    ShopSettings( @menu );
    for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
        for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
            if( @ItemLists[@j] == @bought_nameid[@i] )
            set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
    mes "^FF0000BILLING LIST^000000";
    for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
            mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
 
    if( getitemname( atoi( @Currency$ ) ) != "null" )
        mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
    else if( getitemname( atoi( @Currency$ ) ) == "null" ){
        mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
    }
    
    if( ValidateCost( @Currency$,@TotalCost ) ){
        if( getitemname( atoi( @Currency$ ) ) != "null" )
            mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
        else{
            mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
        }
    }else{
        if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
            if( getitemname( atoi( @Currency$ ) ) != "null" )
                delitem atoi( @Currency$ ),@TotalCost;
            else{
                set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
            }
            for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
                getitem @bought_nameid[@i],@bought_quantity[@i];
            message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
            mes "Thank you for shopping.";
        }
    }
ClearData();
close;
 
}
Viewed 558 times, submitted by Guest.