Jump to content
  • 0

help setting one price for shop npc


bublequando

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/26/13
  • Last Seen:  

as the title say, what script could i use to set one price for all items npc has? , thank you

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  387
  • Reputation:   60
  • Joined:  10/08/13
  • Last Seen:  

//	-	Shop Currency can be either ItemID or Variable Name, but must write within Quotation Marks ( "" )
//			Ex. of Variable.	->	Zeny , #CASHPOINTS , #KAFRAPOINTS , CustomVariable , #CustomVariable

        Case 1:

            // Currency [ Item ID / Variable Name ]

            set @Currency$,"Zeny";

            // Item ID Lists

            setarray @ItemLists[0],6153,7227;

            // Item Price

            setarray @ItemCost[0],100,1;

            break;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  387
  • Reputation:   60
  • Joined:  10/08/13
  • Last Seen:  

can u elaborate more? what kind of NPC did u want? any example?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/26/13
  • Last Seen:  

it's like this elsa,
 

prontera,163,187,4    shop    Tool Dealer#prt1    465,2601:-1,2602:-1,2603:-1,2604:-1,2605:-1,2606:-1,2607:-1,2608:-1,2609:-1,2610:-1,2611:-1,2612:-1,2613:-1,2614:-1,2615:-1,2616:-1,2617:-1,2618:-1,2619:-1,2620:-1,2621:-1,2622:-1,2623:-1,2624:-1,2625:-1,2626:-1,2627:-1,2628:-1,2629:-1,2630:-1,2631:-1,2632:-1,2633:-1,2634:-1,2635:-1,2636:-1,2637:-1,2638:-1,2639:-1,2640:-1,2641:-1,2642:-1,2643:-1,2644:-1,2645:-1,2646:-1,2647:-1,2648:-1,2649:-1,2650:-1,2651:-1,2652:-1,2653:-1,2654:-1,2655:-1,2656:-1,2657:-1,2658:-1,2659:-1,2660:-1,2661:-1,2662:-1,2663:-1,2664:-1,2665:-1,2666:-1,2667:-1,2668:-1,2669:-1,2670:-1,2671:-1,2672:-1,2673:-1,2674:-1,2675:-1,2676:-1,2677:-1,2678:-1,2679:-1,2680:-1,2681:-1,2682:-1,2683:-1,2684:-1,2685:-1,2686:-1,2687:-1,2688:-1,2689:-1,2690:-1,2691:-1,2692:-1,2693:-1,2694:-1,2695:-1,2696:-1,2697:-1,2698:-1,2699:-1,2700:-1,2701:-1,2702:-1,2703:-1,2704:-1,2705:-1,2706:-1,2707:-1,2708:-1,2709:-1,2710:-1,2711:-1,2712:-1,2713:-1,2714:-1,2715:-1,2716:-1,2717:-1,2718:-1,2719:-1,2720:-1,2721:-1,2722:-1,2723:-1,2724:-1,2725:-1,2726:-1,2727:-1,2728:-1,2729:-1,2730:-1,2731:-1,2732:-1,2733:-1,2734:-1,2735:-1,2736:-1,2737:-1,2738:-1,2739:-1,2740:-1,2741:-1,2742:-1,2743:-1,2744:-1,2745:-1,2746:-1,2747:-1,2748:-1,2749:-1,2750:-1,2751:-1,2752:-1,2753:-1,2754:-1, 

i want to set price for above npc to 100M for all items, how do i do that without fill 100M to every item?, thank you for replying

Edited by Emistry
Codebox.
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  387
  • Reputation:   60
  • Joined:  10/08/13
  • Last Seen:  

edit all item that you want to sell at item_db.txt. Change all the default price to what ever price you want. This case if you want to use NPC like your code above.

 

// Structure of Database:
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK[:MATK],DEF,Range,Slots,Job,Class,Gender,Loc,wLV,eLV[:maxLevel],Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }

 

 

or use this script but it not a shop npc like your code above.

 

Emistry script :

// 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


prontera,155,181,5	script	Sample	757,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;

mes "Each Shop from the Menu may purchase using ^FF0000Different Currency^000000.";
mes "^00FF00____________________________^000000";
mes "So,Which shop you would like to look at it";
next;
// Menu Selection
select("Shop 1","Shop 2","Shop 3");

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 "Okay...wait awhile";
mes "^00FF00____________________________^000000";
CurrencyInfo( @Currency$ );
mes "^00FF00____________________________^000000";
callshop "Emistry_Shop",1;
npcshopattach "Emistry_Shop";
end;


function	ShopSettings	{
	switch( getarg(0) ){
		Case 1:
			// Currency [ Item ID / Variable Name ]
			set @Currency$,"7179";
			// Item ID Lists
			setarray @ItemLists[0],6153,7227;
			// Item Price
			setarray @ItemCost[0],100,1;
			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 "^00FF00____________________________^000000";
	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 "^FF0000       BILLING LIST^000000";
	mes "^00FF00____________________________^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";
	mes "^00FF00____________________________^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";
	}
	
	mes "^00FF00____________________________^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;

}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/26/13
  • Last Seen:  

woah, that script that you gave me really advanced and for server that provide donation service.The first solution that you gave, item would be sold for 50% value and more via overcharge, could you simplify your script below :
// 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;

 

using zeny currency, so it's easier to fill list of item and list of price using only copy and paste, thank you so much, i've learn a lot

Edited by bublequando
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/26/13
  • Last Seen:  

lol, i fail to see zeny text at the script, too sleepy, it's 3AM here , terima kasih suster, it's solved

Edited by bublequando
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  387
  • Reputation:   60
  • Joined:  10/08/13
  • Last Seen:  

sama-sama...  /no1

Link to comment
Share on other sites


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

doc/script_commands.txt#L271

** Define a shop/cashshop/itemshop/pointshop NPC.

-%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
<map name>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}

-%TAB%cashshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
<map name>,<x>,<y>,<facing>%TAB%cashshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}

-%TAB%itemshop%TAB%<NPC Name>%TAB%<sprite id>,<costitemid>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
<map name>,<x>,<y>,<facing>%TAB%itemshop%TAB%<NPC Name>%TAB%<sprite id>,<costitemid>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}

-%TAB%pointshop%TAB%<NPC Name>%TAB%<sprite id>,<costvariable>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
<map name>,<x>,<y>,<facing>%TAB%pointshop%TAB%<NPC Name>%TAB%<sprite id>,<costvariable>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}

<map name>,<x>,<y>,<facing>%TAB%marketshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>:<quantity>{,<itemid>:<price>:<quantity>...}

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...