Jump to content
  • 0

how to fix Multi-Shop v1.2


Brynner

Question


  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

if you put an egg and buy multiple egg. it will give you only the last egg you but. and also if you buy item and you are overweight. the item will disappear. and also the required item will also disappear.

 

example.

the currency needed is silver coin.

you buy 1 item and your overweight.

your silver coin will be decrease but the item will not appear.


//===== eAthena Script =======================================
//= Custom-Currency Multi-Shop
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.2
//===== Description: =========================================
//= Allows for better organization in a single shop call.
//= Note that there are two configuration areas.
//============================================================

// -------------------- Config 1 --------------------
// For each shop added, copy this MSHOPX dummy data.
// Write your shop names in the select() function.

-	shop	MSHOP1	-1,512:-1
-	shop	MSHOP2	-1,512:-1
-	shop	MSHOP3	-1,512:-1
-	shop	MSHOP4	-1,512:-1
-	shop	MSHOP5	-1,512:-1
-	shop	MSHOP6	-1,512:-1
-	shop	MSHOP7	-1,512:-1
-	shop	MSHOP8	-1,512:-1

prontera,163,174,4	script	A Shop	984,{

	set @s, select("Weapons:Headgears:Armors:Garments:Shoes:Shields:Cards:Misc");

// --------------------------------------------------

	message strcharinfo(0),"This shop only accepts "+getitemname(.Currency[@s])+".";
	dispbottom "You have "+countitem(.Currency[@s])+" "+getitemname(.Currency[@s])+".";
	callshop "MSHOP"+@s,1;
	npcshopattach "MSHOP"+@s;
	end;

OnBuyItem:
	set .@i,0;
	while (.@i < getarraysize(@bought_nameid)) {
		set .@j, 0;
		while (.@j < getarraysize(getd(".Shop"+@s))) {
			if(getd(".Shop"+@s+"["+.@j+"]") == @bought_nameid[.@i]) {
				set @itemcost, (getd(".Shop"+@s+"["+(.@j+1)+"]") * @bought_quantity[.@i]);
				set @totalcost, @totalcost + @itemcost;
				break; }
			set .@j, .@j+2; }
		set .@i, .@i+1; }
	if (@totalcost > countitem(.Currency[@s])) dispbottom "You don't have enough "+getitemname(.Currency[@s])+".";
	else {
		set .@i,0;
		while (.@i < getarraysize(@bought_nameid)) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
			set .@i, .@i+1; }
		delitem .Currency[@s], @totalcost; }
	set @totalcost, 0;
	deletearray @bought_nameid[0], 128;
	deletearray @bought_quantity[0], 128;
	end;

OnInit:

// -------------------- Config 2 --------------------
// Currency:  The ID of each shop currency,
//    in the same order as the shops.
// Shop order follows that of the select() call,
//   and is formatted "ID1,Count1,ID2,Count2,..."

	setarray .Currency[1],513,513,513,513,513,513,513,513;
	setarray .Shop1[0],1202,5,1229,20;
	setarray .Shop2[0],5116,15;
	setarray .Shop3[0],2302,2,2348,30;
	setarray .Shop4[0],2502,2,2513,15,2523,15;
	setarray .Shop5[0],2441,15;
	setarray .Shop6[0],2199,32768;
	setarray .Shop7[0],4051,3,4285,6;
	setarray .Shop8[0],513,1,532,2,634,4;

// --------------------------------------------------

	set .@i,1;
	while (.@i <= getarraysize(.Currency)) {
		set .@j,0;
		while (.@j < getarraysize(getd(".Shop"+.@i))) {
			npcshopdelitem "MSHOP"+.@i,512;
			npcshopadditem "MSHOP"+.@i, getd(".Shop"+.@i+"["+.@j+"]"), getd(".Shop"+.@i+"["+(.@j+1)+"]");
			set .@j, .@j+2; }
		set .@i, .@i+1; }
	end;
}
Edited by Brynner
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@Brynner

Pet Egg required the char-server to save the data each time you gained 1 pet egg.

at any normal circumstance, the getitem cant really work for Pet egg if you are giving out multiple pet egg, this is because char-server need time to save the data.

temporary you can fix it by using this

for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1){
	getitem @bought_nameid[@i],@bought_quantity[@i];
	sleep2 1;   // add this.  increase to longer if needed.
}
add a sleep2 right after the getitem command.

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

how about the weight limit? the gold coin will decrease but the item that you purchase is missing?

up

 

 

@Brynner

Pet Egg required the char-server to save the data each time you gained 1 pet egg.

at any normal circumstance, the getitem cant really work for Pet egg if you are giving out multiple pet egg, this is because char-server need time to save the data.

temporary you can fix it by using this

for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1){
	getitem @bought_nameid[@i],@bought_quantity[@i];
	sleep2 1;   // add this.  increase to longer if needed.
}
add a sleep2 right after the getitem command.

 

 

the script does not match.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

	if (@totalcost > countitem(.Currency[@s])) dispbottom "You don't have enough "+getitemname(.Currency[@s])+".";
	else {
		set .@i,0;
		while (.@i < getarraysize(@bought_nameid)) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
			set .@i, .@i+1; }
		delitem .Currency[@s], @totalcost; }
change into

 

	if (@totalcost > countitem(.Currency[@s])) dispbottom "You don't have enough "+getitemname(.Currency[@s])+".";
	else if ( !checkweight2(@bought_nameid,@bought_quantity) ) {
		dispbottom "You can't make this purchase because you'll be overweight !";
		end;
	}
	else {
		set .@i,0;
		while (.@i < getarraysize(@bought_nameid)) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
			set .@i, .@i+1;
		}
		delitem .Currency[@s], @totalcost;
	}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

	if (@totalcost > countitem(.Currency[@s])) dispbottom "You don't have enough "+getitemname(.Currency[@s])+".";
	else {
		set .@i,0;
		while (.@i < getarraysize(@bought_nameid)) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
			set .@i, .@i+1; }
		delitem .Currency[@s], @totalcost; }
change into

 

	if (@totalcost > countitem(.Currency[@s])) dispbottom "You don't have enough "+getitemname(.Currency[@s])+".";
	else if ( !checkweight2(@bought_nameid,@bought_quantity) ) {
		dispbottom "You can't make this purchase because you'll be overweight !";
		end;
	}
	else {
		set .@i,0;
		while (.@i < getarraysize(@bought_nameid)) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
			set .@i, .@i+1;
		}
		delitem .Currency[@s], @totalcost;
	}

thanks but were should i insert the 

 

sleep2 1;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

update this script

http://www.eathena.ws/board/index.php?s=&showtopic=276405&view=findpost&p=1516212

-    shop    market2#hidden    -1,501:1000
prontera,156,172,5    script    market    100,{
    dispbottom "You currently have "+ countitem(.currency) +" "+ getitemname(.currency);
    callshop .shopname$, 0;
    end;
OnInit:
    function    addshopitem    {
        npcshopdelitem .shopname$, 501;
        .@count = getargcount();
        for ( .@i = 0; .@i < .@count; .@i++ ) {
            if ( .@i % 2 == 0 )
                .itemid[ .@i /2 ] = getarg( .@i );
            else {
                .itemcost[ .@i /2 ] = getarg( .@i );
                npcshopadditem .shopname$, .itemid[ .@i /2 ], getarg( .@i );
            }
        }
        
    }
//    ----- Configuration ------
    .shopname$ = "market2#hidden"; // shop name that match the 1st line in this script
    .currency = 674; // item used for currency
    addshopitem // adds shop items here
        512,10,
        513,20,
        514,30,
        515,40,
        516,50,
        607,1;
//    -------------------------
    .itemsize = getarraysize( .itemid );
    for ( .@i = 0; .@i < .itemsize; .@i++ )
        setd ".item"+ .itemid[.@i] +"cost", .itemcost[.@i];
    npcshopattach .shopname$;
    end;
OnBuyItem:
    if ( !@bought_quantity ) end;
    .@size = getarraysize( @bought_nameid );
    for ( .@i = 0; .@i < .@size; .@i++ )
        .@itemcost = .@itemcost + getd( ".item"+ @bought_nameid[.@i] +"cost" ) * @bought_quantity[.@i];
    if ( .@itemcost > countitem(.currency) ) {
        mes "you don't have enough "+ getitemname(.currency);
        close;
    }
    if ( !checkweight2( @bought_nameid, @bought_quantity ) ) {
        mes "you can't carry all these items !";
        close;
    }
    delitem .currency, .@itemcost;
    for ( .@i = 0; .@i < .@size; .@i++ )
        getitem @bought_nameid[.@i], @bought_quantity[.@i];
    end;
OnSellItem:
    if ( !@sold_quantity ) end;
    .@size = getarraysize( @sold_nameid );
    for ( .@i = 0; .@i < .@size; .@i++ )
        .@itemgain = .@itemgain + getd( ".item"+ @sold_nameid[.@i] +"cost" ) * @sold_quantity[.@i];
    if ( !checkweight( .currency, .@itemgain ) ) {
        mes "you can't carry all these items !";
        close;
    }
    for ( .@i = 0; .@i < .@size; .@i++ )
        if ( getd( ".item"+ @sold_nameid[.@i] +"cost" ) )
            delitem @sold_nameid[.@i], @sold_quantity[.@i];
    getitem .currency, .@itemgain;
    end;
}

 

hmm ... didn't know rathena has updated a bit ... much ...

 

-    shop    market2#hidden    -1,501:1000
prontera,156,172,5    script    market    100,{
    dispbottom "You currently have "+ countitem(.currency) +" "+ getitemname(.currency);
    callshop .shopname$, 1;
    end;
OnInit:
    function    addshopitem    {
        npcshopdelitem .shopname$, 501;
        .@count = getargcount();
        for ( .@i = 0; .@i < .@count; .@i++ ) {
            if ( .@i % 2 == 0 )
                .itemid[ .@i /2 ] = getarg( .@i );
            else {
                .itemcost[ .@i /2 ] = getarg( .@i );
                npcshopadditem .shopname$, .itemid[ .@i /2 ], getarg( .@i );
            }
        }
        
    }
//    ----- Configuration ------
    .shopname$ = "market2#hidden"; // shop name that match the 1st line in this script
    .currency = 675; // item used for currency
    addshopitem // adds shop items here
        9001,10,
        9002,20,
        9003,30,
        9004,40,
        9005,50;
//    -------------------------
    .itemsize = getarraysize( .itemid );
    for ( .@i = 0; .@i < .itemsize; .@i++ )
        setd ".item"+ .itemid[.@i] +"cost", .itemcost[.@i];
    npcshopattach .shopname$;
    end;
OnBuyItem:
    if ( !@bought_quantity ) end;
    .@size = getarraysize( @bought_nameid );
    for ( .@i = 0; .@i < .@size; .@i++ )
        .@itemcost = .@itemcost + getd( ".item"+ @bought_nameid[.@i] +"cost" );
    if ( .@itemcost > countitem(.currency) ) {
        mes "you don't have enough "+ getitemname(.currency);
        close;
    }
    cleararray @bought_quantity[0],1, getarraysize( @bought_quantity );
    if ( !checkweight2( @bought_nameid, @bought_quantity ) ) {
        mes "you can't carry all these items !";
        close;
    }
    delitem .currency, .@itemcost;
    for ( .@i = 0; .@i < .@size; .@i++ ) {
        getitem @bought_nameid[.@i], 1;
        sleep2 1;
    }
    end;
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...