Jump to content
  • 0

Help Dynamic Shop


Hidan

Question


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   2
  • Joined:  04/03/14
  • Last Seen:  

I have this npc, but it does not buy, nor does it sell, nor does it count the rate

Spoiler

//============================================================

// shop to insert items into:
-    shop    dyn_shop1    -1,501:50.

prontera,181,200,4    script    Dynamic Shop    123,{
    callshop "dyn_shop1",0;
    npcshopattach "dyn_shop1";
    end;

OnSellItem:
    // Stores the amount of tax the clan can withdraw.
    set $taxes1, $taxes1+@price*10;
    mes "Imposto Coletado.";
    end;

OnBuyItem:
    // Stores the amount of tax the clan can withdraw.
    set $taxes1, $taxes1+@price*10;
    //mes "Tax collected successfully!";
    dispbottom "Tax "+$taxes1+",";
    end;

OnInit:
    //npcshopitem "dyn_shop1", 501,40,502,200;
    npcshopitem "dyn_shop1", 611,40,1750,1,501,50,502,200,503,550,504,1200,506,40,645,800,656,1500,601,60,602,300,1065,100,2239,10000;
    $@rpotsleft = 10;
    $@opotsleft = 10;
    end;
}

prontera,181,198,6    script    tax collector#1    952,{
    
    mes "[taxes]";
    mes "You have: "+$taxes1+" Zenys to collect";
    next;
    mes "Would you like to collect this money now?";
    if(select("Coletar","Não") == 2) close;
    mes "Tax collected successfully";
    set Zeny, Zeny+$taxes1;
    set $taxes1, 0;
    close;
}

 

I want the npc to be equal to 1 normal npc shop, the difference is that it collects 10% of the value of each purchase, and saves so that the leader of the cl, retire and m seven in seven days value.

Grateful to anyone who can help me.

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

-	shop	tax10	-1,501:10000

prontera,255,55,4	script	Dealer#tax10	123,{	
set .@GM,80;
	if (getgmlevel() >= .@GM) {
	mes "Hi, Tax Collector How can i help you today?";
	mes "You're not excluded from the tax though";
	next;
	switch(select("Open Buying Shop:Open Selling Shop:View Tax Earned:Collect Tax")){
		case 1:
			callshop "tax10",1;
			npcshopattach "tax10";
			end;
		case 2:
			callshop "tax10",2;
			npcshopattach "tax10";
			end;
		case 3:
			mes "Your shop have now earned a total of ^ff0000"+ $collectedtax +"^000000.";
			close;
		case 4:
			if($collectedtax <= 0){
				mes "Are you crazy you have nothing to collect!";
				close;
				} else {
					set .@TotalCollected,.@TotalCollected + $collectedtax;
						set Zeny,Zeny + .@TotalCollected;
						dispbottom "You have collected a total of "+.@TotalCollected+"z Taxes";
						set $collectedtax,0;
						close;
						}		
					}
				}
	mes "Hi, Im a traveling merchant I sell everything as cheap as it can be and buy everything as high as I can be";
	mes "But every purchase/sold will have an additional 10% tax";
	next;
	switch(select("Open Buying Shop:Open Selling Shop:Nothing")){
		case 1:
			callshop "tax10",1;
			npcshopattach "tax10";
			end;
		case 2:
			callshop "tax10",2;
			npcshopattach "tax10";
			end;
		case 3:
			mes "Stop wasting my time!";
			close;
			}
OnBuyItem:
	set .@TotalCost,0;
		for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
			for(set .@j,0; .@j < getarraysize( .item ); set .@j,.@j+1)
				if( .item[.@j] == @bought_nameid[.@i] )
					set .@TotalCost,.@TotalCost + ( .price[.@j] * @bought_quantity[.@i] );
						set .@tax,((.@TotalCost * .rates) / 100);	
							set .@FinalCost,.@FinalCost + (.@TotalCost + .@tax);
							if( Zeny >=	 .@FinalCost ){
								set Zeny,Zeny - .@FinalCost;
								for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
								getitem @bought_nameid[.@i],@bought_quantity[.@i];
								set $collectedtax,$collectedtax + .@tax;
									dispbottom "You have paid an additional "+.@tax+"z for this purchase";
									close;
							} else {
									set .@lack,.@lack + (.@FinalCost - Zeny);
									mes "Your zeny is not enough for this purchase";
									dispbottom "You need "+.@lack+"z more for this purchase";
									close;
									}
OnSellItem:
	set .@TotalEarn,0;	
		for(set .@j,0; .@j < getarraysize( .bitem ); set .@j,.@j+1)
			if( @sold_nameid[.@i] == .bitem[.@j] ) {
				set .@TotalEarn,.@TotalEarn + ( .bprice[.@j] * @sold_quantity[.@i] );
					set .@btax,.@btax + ((.@TotalEarn * .rates) / 100);
						set .@FinalEarn,.@FinalEarn + (.@TotalEarn - .@btax);
							set Zeny,Zeny + .@FinalEarn;
							for(set .@i,0; .@i < getarraysize( @sold_nameid ); set .@i,.@i+1)
							delitem @sold_nameid[.@i],@sold_quantity[.@i];
							set $collectedtax,$collectedtax + .@btax;
								dispbottom "Your Total Earnings is "+.@FinalEarn+".";
								dispbottom "You earnings have been reduced by "+.@tax+"z because of the 10% tax";
								close;
								} else {
									mes "Sorry I dont buy that kind of item";
									close;
									}
								

			
OnInit:
	set .rates,10; //set tax here
	setarray .item[0],501,502,503;
	setarray .price[0],10000,15000,20000;
	
	setarray .bitem[0],748,969;
	setarray .bprice[0],27500,100000;
	
	npcshopitem "tax_Shop",512,1000;
	npcshopdelitem "tax_Shop",512;
	for(set .@i,0; .@i < getarraysize( .item ); set .@i,.@i+1)
	npcshopadditem "tax10",.item[.@i],.price[.@i];
	end;
	}			

test this and give me feedback :)) apparently i cant make all selling items have tax(i cant think of a logic for it) so just add the items you want to be sellable in the shop in
bitem and the bprice for the price of it :))

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

-	shop	tax10	-1,501:10000

prontera,255,55,4	script	Dealer#tax10	123,{
	mes "Hi, Im a traveling merchant I sell everything as cheap as it can be";
	mes "But every purchase will have an additional 10% tax";
	next;
	switch(select("Open Shop:Nothing")){
		case 1:
			callshop "tax10",1;
			npcshopattach "tax10";
			end;
		case 2:
			mes "Stop wasting my time!";
			close;
			}
OnBuyItem:
	set .@TotalCost,0;
		for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
			for(set .@j,0; .@j < getarraysize( .item ); set .@j,.@j+1)
				if( .item[.@j] == @bought_nameid[.@i] )
					set .@TotalCost,.@TotalCost + ( .price[.@j] * @bought_quantity[.@i] );
						set .@tax,((.@TotalCost * .rates) / 100);	
							set .@FinalCost,.@FinalCost + (.@TotalCost + .@tax);
							if( Zeny >= .@FinalCost ){
								set Zeny,Zeny - .@FinalCost;
								for(set .@i,0; .@i < getarraysize( @bought_nameid ); set .@i,.@i+1)
								getitem @bought_nameid[.@i],@bought_quantity[.@i];
									dispbottom "You have paid an additional "+.@tax+"z for this purchase";
									close;
							} else {
									set .@lack,.@lack + (.@FinalCost - Zeny);
									mes "Your zeny is not enough for this purchase";
									dispbottom "You need "+.@lack+"z more for this purchase";
									close;
									}
OnInit:
	set .rates,10; //set tax here
	setarray .item[0],501,502,503;
	setarray .price[0],10000,15000,20000;
	
	npcshopitem "tax_Shop",512,1000;
	npcshopdelitem "tax_Shop",512;
	for(set .@i,0; .@i < getarraysize( .item ); set .@i,.@i+1)
	npcshopadditem "tax10",.item[.@i],.price[.@i];
	end;
	}			

this shop have configurable tax percentage but i dont get the part 
 

Quote

saves so that the leader of the cl, retire and m seven in seven days value.


 

Edited by crazyarashi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   2
  • Joined:  04/03/14
  • Last Seen:  

Hi, thanks a lot, it worked here, would you like to add OnSellItem?

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

39 minutes ago, clold157 said:

Hi, thanks a lot, it worked here, would you like to add OnSellItem?

do you want the tax to be withdrawable and get tax from sell items too? :))

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   2
  • Joined:  04/03/14
  • Last Seen:  

Yes, it is possible? thank you.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   2
  • Joined:  04/03/14
  • Last Seen:  

Very good, it worked here, I only received alert of the incorrect use of the close, but I managed to solve, thank you very much for the attention and understanding, and also for the willpower to help me.

Excuse me where I can give feedback, because I do not know how to give feedback.

Thank you.

Edited by clold157
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...