Jump to content
  • 0

Emistry Multi currency shop x2


Shakto

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  402
  • Reputation:   89
  • Joined:  02/07/13
  • Last Seen:  

Hi,

 

I tried to use the multi currency shop for 2 differents shop.

But the first shop is empty in game (worked when the 2nd wasn't load)

 

I tried to change the name of function and variable but it seems to not change anything.

My both npc here :

 

// 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	Cloud_Machine	-1,512:100


gonryun,159,109,0	script	Cloud Machine	685,{
function ShopSettingscloud;
function ValidateCostcloud;
function CurrencyInfocloud;
function ClearDatacloud;
function ValueConvertcloud;
function ErrorNoticecloud;

mes "Ce magasin utilise la monnaie ^FF0000Clouds^000000.";
mes "^00FF00____________________________^000000";
mes "Choisissez le type d'item que vous voulez";
next;
// Menu Selection
select("Equipement Box","Upper Head","Middle Head","Lower Head","Costumes","Consommables","Autres");

ClearDatacloud();
ShopSettingscloud( @menu );
npcshopitem "Cloud_Machine",512,100;
npcshopdelitem "Cloud_Machine",512;
for(set .@i,0; .@i < getarraysize( @ItemListscloud ); set .@i,.@i+1)
	npcshopadditem "Emistry_Shop",@ItemListscloud[.@i],@ItemCostcloud[.@i];
mes "Ok...attendez un instant";
mes "^00FF00____________________________^000000";
CurrencyInfocloud( @Currencycloud$ );
mes "^00FF00____________________________^000000";
callshop "Cloud_Machine",1;
npcshopattach "Cloud_Machine";
end;


function	ShopSettingscloud	{
	switch( getarg(0) ){
		Case 1:
			// Equipement Box [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],12107,12106,12186;
			// Item Price
			setarray @ItemCostcloud[0],30,40,50;
			break;
		Case 2:
			// Upper Head [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],5531,5338;
			// Item Price
			setarray @ItemCostcloud[0],35,10;
			break;
		Case 3:
			// Middle Head [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],5786,5389,5288,2202,18607,5664,5471,5793,5592;
			// Item Price
			setarray @ItemCostcloud[0],25,100,50,175,175,80,60,70,50;
			break;
		Case 4:
			// Lower Head [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],5597,5596,5445,5775,5594,5377,5463;
			// Item Price
			setarray @ItemCostcloud[0],150,150,15,50,40,100,50;
			break;
		Case 5:
			// Costumes [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],19529,19528,19525,19530;
			// Item Price
			setarray @ItemCostcloud[0],50,50,75,75;
			break;
		Case 6:
			// Consommable [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],12915,12916,14208,12902;
			// Item Price
			setarray @ItemCostcloud[0],10,10,20,50;
			break;
		Case 7:
			// Autres [ Item ID / Variable Name ]
			set @Currencycloud$,"30000";
			// Item ID Lists
			setarray @ItemListscloud[0],12920,12921,6241,6240,6225,6226,12622;
			// Item Price
			setarray @ItemCostcloud[0],40,40,6,6,10,10,200;
			break;
		// Case 4,5,6.....etc...
		default:
			ErrorNoticecloud( "Sélection du menu invalide : "+@menu+"." );
			close;
	}
	
	
if( @Currencycloud$ == "" )
	ErrorNoticecloud( "Invalid Currency Setting in Menu "+@menu+" ." );
if( getarraysize( @ItemCostcloud ) != getarraysize( @ItemListscloud ) || getarraysize( @ItemListscloud ) != getarraysize( @ItemCostcloud ) )
	ErrorNoticecloud( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
return;
}

function	ErrorNoticecloud	{
	mes "^FF0000ERROR^000000 - "+getarg(0);
	mes "^00FF00____________________________^000000";
	mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
	close;
}

function	CurrencyInfocloud	{
	if( getitemname( atoi( getarg(0) ) ) != "null" ){
		mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
		mes "Available Amount : ^0000FF"+ValueConvertcloud( countitem( atoi( getarg(0) ) ) )+"^000000";
	}else if( getitemname( atoi( getarg(0) ) ) == "null" ){
		mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
		mes "Available Amount : ^0000FF"+ValueConvertcloud( getd( getarg(0) ) )+"^000000";
	}
return;
}

function	ValidateCostcloud	{
	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 ClearDatacloud	{
	set @Currencycloud$,"";
	set @TotalCostcloud,0;
	deletearray @bought_nameidcloud[0],getarraysize( @bought_nameidcloud );
	deletearray @bought_quantitycloud[0],getarraysize( @bought_quantitycloud );
	deletearray @ItemListscloud[0],getarraysize( @ItemListscloud );
	deletearray @ItemCostcloud[0],getarraysize( @ItemCostcloud );
return;
}

function	ValueConvertcloud	{
	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:
	ShopSettingscloud( @menu );
	for(set @i,0; @i < getarraysize( @bought_nameidcloud ); set @i,@i+1)
		for(set @j,0; @j < getarraysize( @ItemListscloud ); set @j,@j+1)
			if( @ItemListscloud[@j] == @bought_nameidcloud[@i] )
			set @TotalCostcloud,@TotalCostcloud + ( @ItemCostcloud[@j] * @bought_quantitycloud[@i] );
	mes "^FF0000       BILLING LIST^000000";
	mes "^00FF00____________________________^000000";
	for( set @i,0; @i < getarraysize( @bought_nameidcloud ); set @i,@i+1 )
			mes "^FF0000"+@bought_quantitycloud[@i]+" x ^0000FF"+getitemname( @bought_nameidcloud[@i] )+"^000000";
	mes "^00FF00____________________________^000000";

	if( getitemname( atoi( @Currencycloud$ ) ) != "null" )
		mes "Total Cost : ^0000FF"+ValueConvertcloud( @TotalCostcloud )+" x "+getitemname( atoi( @Currencycloud$ ) )+"^000000";
	else if( getitemname( atoi( @Currencycloud$ ) ) == "null" ){
		mes "Total Cost : ^0000FF"+ValueConvertcloud( @TotalCostcloud )+" "+@Currencycloud$+"^000000";
	}
	
	mes "^00FF00____________________________^000000";
	if( ValidateCostcloud( @Currencycloud$,@TotalCostcloud ) ){
		if( getitemname( atoi( @Currencycloud$ ) ) != "null" )
			mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currencycloud$ ) )+"^000000";
		else{
			mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currencycloud$+"^000000";
		}
	}else{
		if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
			if( getitemname( atoi( @Currencycloud$ ) ) != "null" )
				delitem atoi( @Currencycloud$ ),@TotalCostcloud;
			else{
				set getd( @Currencycloud$ ),getd( @Currencycloud$ ) - @TotalCostcloud;
			}
			for(set @i,0; @i < getarraysize( @bought_nameidcloud ); set @i,@i+1)
				getitem @bought_nameidcloud[@i],@bought_quantitycloud[@i];
			message strcharinfo(0),"Purchased "+getarraysize( @bought_nameidcloud )+" Items.";
			mes "Thank you for shopping.";
		}
	}
ClearDatacloud();
close;

}

 

 

// Badges Exchange
//============================================================

-	shop	BG_shop	-1,512:100

bat_room,160,150,3	script	Erundek	109,{
	function ShopSettings;
	function ValidateCost;
	function CurrencyInfo;
	function ClearData;
	function ValueConvert;
	function ErrorNotice;
	
	if (checkweight(1201,1) == 0) {
		mes "- Attendez une minute !! -";
		mes "- Vous portez trop d'objets -";
		mes "- Revenez après vous -";
		mes "- être vidé un peu de votre poid. -";
		close;
	}
	
	mes "Ce magasin utilise des ^FF0000Bravery Badges et Valor Badges^000000.";
	mes "^00FF00____________________________^000000";
	mes "Choisissez le type d'item que vous voulez";
	next;
	
	// Menu Selection
	select("Armes Bravery Badges","Armes Valor Badges","Armures Bravery Badges","Armures Valor Badges","Consommables Bravery Badges","Consommables Valor Badges");

	ClearData();
	ShopSettings( @menu );
	npcshopitem "BG_shop",512,100;
	npcshopdelitem "BG_shop",512;
	for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
		npcshopadditem "BG_shop",@ItemLists[.@i],@ItemCost[.@i];
	mes "Ok...attendez un instant";
	mes "^00FF00____________________________^000000";
	CurrencyInfo( @Currency$ );
	mes "^00FF00____________________________^000000";
	callshop "BG_shop",1;
	npcshopattach "BG_shop";
	end;
	
function	ShopSettings	{
	switch( getarg(0) ){
		Case 1:
			// Armes Bravery [ Item ID / Variable Name ]
			set @Currency$,"7828";
			// Item ID Lists
			setarray @ItemLists[0],13036,13042,13411,13417,1183,1187,1425,1486,1632,1634,1640,1543,1546,1380,1382,13305,1739,1743,1279,1282,1924,1978,1981,1574,1576,1824,1826,13108,13178,13172,13176;
			// Item Price
			setarray @ItemCost[0],1000,2000,1000,2000,1000,2000,1000,2000,1000,1000,2000,1000,2000,1000,2000,1000,1000,2000,1000,2000,1000,1000,2000,1000,2000,1000,2000,1000,2000,1000,2000;
			break;
		Case 2:
			// Armes Valor [ Item ID / Variable Name ]
			set @Currency$,"7829";
			// Item ID Lists
			setarray @ItemLists[0],13037,13410,13418,1184,13416,1482,1426,1633,2002,1635,1641,1542,1379,1310,13306,13307,1738,1280,1281,1923,1927,1977,1575,1577,13171,13179,13173,13177,13174,13110;
			// Item Price
			setarray @ItemCost[0],1000,1000,2000,1000,2000,1000,2000,1000,2000,1000,2000,1000,2000,1000,1000,2000,1000,1000,2000,1000,2000,1000,1000,2000,1000,2000,1000,2000,1000,2000;
			break;
		Case 3:
			// Armures Bravery [ Item ID / Variable Name ]
			set @Currency$,"7828";
			// Item ID Lists
			setarray @ItemLists[0],2538,2539,2540,2435,2436,2437,2376,2377,2378,2379,2380,2381,2382,2733,2720,2721,2722,2723,2724,2725,2394,2444,2395,2773,2446;
			// Item Price
			setarray @ItemCost[0],800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,1000,1000,200,300,200;
			break;
		Case 4:
			// Armures Valor [ Item ID / Variable Name ]
			set @Currency$,"7829";
			// Item ID Lists
			setarray @ItemLists[0],2538,2539,2540,2435,2436,2437,2376,2377,2378,2379,2380,2381,2382,2733,2720,2721,2722,2723,2724,2725,2549,2772,2445,2396,2774;
			// Item Price
			setarray @ItemCost[0],800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,1000,2000,300,150,100;
			break;
		Case 5:
			// Consos Bravery [ Item ID / Variable Name ]
			set @Currency$,"7828";
			// Item ID Lists
			setarray @ItemLists[0],12269,12270,12271,12272,12273,11503,11504;
			// Item Price
			setarray @ItemCost[0],40,40,40,40,40,3,3;
			break;
		Case 6:
			// Consos Valor [ Item ID / Variable Name ]
			set @Currency$,"7829";
			// Item ID Lists
			setarray @ItemLists[0],12269,12270,12271,12272,12273,11503,11504;
			// Item Price
			setarray @ItemCost[0],40,40,40,40,40,3,3;
			break;
			// Case 4,5,6.....etc...
		default:
			ErrorNotice( "Sélection du menu invalide : "+@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;

}

 

 

thx by advance

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

First thing I see, you add item to a shop "Emistry_shop", I guess you forget to update the shop name (should be "Cloud_Machine").

	npcshopadditem "Emistry_Shop",@ItemListscloud[.@i],@ItemCostcloud[.@i];
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  402
  • Reputation:   89
  • Joined:  02/07/13
  • Last Seen:  

My god... i'm stupid, didn't see that, i try that. Merci ;)

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