Jump to content
  • 0

NPC script Question: setarray with too many value, the npc script wont run ?


6ttctt9

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  04/28/21
  • Last Seen:  

Why setarray with too many value, the npc script wont run ?
This is NPC script, who will buy card from player with different price depend what is that card, like MVP card price 1 billion zeny and other is 100k or millions zeny.
with setarray just 1 or 2,3 value, the script run fine. but with many value each setarray, it wont run.
Example:
setarray .card100k,4032;//,4013,4023,4009,4004,4002,4026,4019,4006,4050,4008,4011,4001,4021,4022,4028,4016,4051; = it run
setarray .card100k,4032,4013,4023,4009,4004,4002,4026,4019,4006,4050,4008,4011,4001,4021,4022,4028,4016,4051; = it wont run.

prontera,181,204,4	script	Card Buyer	  658,{

mes "[Card Buyer]";
mes "You have any card to sell ? <3";
next;
		
getinventorylist;
for (; .@i < @inventorylist_count; .@i++) {
	if(getiteminfo(@inventorylist_id[.@i],2) == 6){
		.@items[.@count] = @inventorylist_id[.@i];
		.el = 0;
		for ( .@i2 = 0; .@i2 < getarraysize(.card100k); .@i2++ ) {
		   if(@inventorylist_id[.@i] == .card100k[.@i2]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^00FF00100K Zeny^000000:";
		   .el = 1;
		   }
		}
		for ( .@i3 = 0; .@i3 < getarraysize(.card500k); .@i3++ ) {
		   if(@inventorylist_id[.@i] == .card500k[.@i3]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^00FF00500K Zeny^000000:";
		    .el = 1;
		  }
		}
		for ( .@i4 = 0; .@i4 < getarraysize(.card5m); .@i4++ ) {
		   if(@inventorylist_id[.@i] == .card5m[.@i4]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^0000FF5M Zeny^000000:";
		    .el = 1;
		  }
		}
		for ( .@i5 = 0; .@i5 < getarraysize(.card10m); .@i5++ ) {
		   if(@inventorylist_id[.@i] == .card10m[.@i5]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^0000FF10M Zeny^000000:";
		    .el = 1;
		  }
		}
		for ( .@i6 = 0; .@i6 < getarraysize(.card50m); .@i6++ ) {
		   if(@inventorylist_id[.@i] == .card50m[.@i6]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^0000FF50M Zeny^000000:";
		    .el = 1;
		  }
		}
		for ( .@i7 = 0; .@i7 < getarraysize(.card100m); .@i7++ ) {
		   if(@inventorylist_id[.@i] == .card100m[.@i7]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF0000100M Zeny^000000:";
		   .el = 1;
		   }
		}
		for ( .@i8 = 0; .@i8 < getarraysize(.card500m); .@i8++ ) {
		   if(@inventorylist_id[.@i] == .card500m[.@i8]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF0000500M Zeny^000000:";
		    .el = 1;
		  }
		}
		for ( .@i9 = 0; .@i9 < getarraysize(.card1b); .@i9++ ) {
		   if(@inventorylist_id[.@i] == .card1b[.@i9]) {
		    .@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF00001B Zeny^000000:";
		    .el = 1;
		  }
		}
		if(.el == 0) {
		.@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^00FF001M Zeny^000000:";
		}
		.@count++;
	}
}

.@select = select(.@menu$) - 1;

delitem .@items[.@select],1;
		.el = 0;
		for ( .@i2 = 0; .@i2 < getarraysize(.card100k); .@i2++ ) {
		   if(.@items[.@select] == .card100k[.@i2]) {
		    set Zeny, Zeny + 100000;
		   .el = 1;
		   }
		}
		for ( .@i3 = 0; .@i3 < getarraysize(.card500k); .@i3++ ) {
		   if(.@items[.@select] == .card500k[.@i3]) {
		    set Zeny, Zeny + 500000;
		    .el = 1;
		  }
		}
		for ( .@i4 = 0; .@i4 < getarraysize(.card5m); .@i4++ ) {
		   if(.@items[.@select] == .card5m[.@i4]) {
		    set Zeny, Zeny + 5000000;
		    .el = 1;
		  }
		}
		for ( .@i5 = 0; .@i5 < getarraysize(.card10m); .@i5++ ) {
		   if(.@items[.@select] == .card10m[.@i5]) {
		    set Zeny, Zeny + 10000000;
		    .el = 1;
		  }
		}
		for ( .@i6 = 0; .@i6 < getarraysize(.card50m); .@i6++ ) {
		   if(.@items[.@select] == .card50m[.@i6]) {
		    set Zeny, Zeny + 50000000;
		    .el = 1;
		  }
		}
		for ( .@i7 = 0; .@i7 < getarraysize(.card100m); .@i7++ ) {
		   if(.@items[.@select] == .card100m[.@i7]) {
		    set Zeny, Zeny + 100000000;
		   .el = 1;
		   }
		}
		for ( .@i8 = 0; .@i8 < getarraysize(.card500m); .@i8++ ) {
		   if(.@items[.@select] == .card500m[.@i8]) {
		    set Zeny, Zeny + 500000000;
		    .el = 1;
		  }
		}
		for ( .@i9 = 0; .@i9 < getarraysize(.card1b); .@i9++ ) {
		   if(.@items[.@select] == .card1b[.@i9]) {
		    set Zeny, Zeny + 1000000000;
		    .el = 1;
		  }
		}
		if(.el == 0) {
		set Zeny, Zeny + 1000000;
		}
end;

OnInit:
	//Ambernite,Andre Egg,Baby Desert Wolf,Chonchon,Drops,Fabre,Female Thief Bug,Hornet,Lunatic,Male Thief Bug,Picky,Picky Egg,Poring,Rocker,Spore,Tarou,Thief Bug,Yoyo
	setarray .card100k,4032;//,4013,4023,4009,4004,4002,4026,4019,4006,4050,4008,4011,4001,4021,4022,4028,4016,4051;
    //Andre,Condor,Elder Willow,Kukre,Pupa,Roda Frog,Thief Bug Egg,Willow,Wormtail
	setarray .card500k,4043;//,4015,4052,4027,4003,4014,4012,4010,4034;
    //Anubis,Beholder,Bigfoot,Bloody Butterfly,Bloody Knight,Cecil Damon,Creamy,Deviruchi,Dimik,Dragon Fly,Drosera,Eclipse,Egnigem Cenia,Eremes Guile,Enchanted Peach Tree,Executioner,Frilldora,Giant Whisper,Giearth,Goblin Leader,Gryphon,Horn,Horong,Howard Alt-Eisen,Joker,Kathryne Keyron,Khalitzburg,Kobold Leader,Loli Ruri,Marc,Marduk,Margaretha Sorin,Marine Sphere,Mastering,Medusa,Mutant Dragonoid,Mysteltainn,Nightmare,Obeaune,Ogretooth,Orc Warrior,Penomena,Phen,Pirate Skeleton,Poison Spore,Poporing,Rafflesia,Raydric,Seeker,Seyren Windsor,Sky Petite,Smokie,Soldier Andre,Stapo,Teddy Bear,Thara Frog,Toad,Ungoliant,Vagabond Wolf,Vitata,Vocal,Whisper,Zealotus
	setarray .card5m,4138,4356;//,4074,4327,4320,4368,4040,4122,4370,4179,4421,4266,4346,4360,4217,4250,4088,4303,4087,4155,4163,4045,4103,4362,4139,4366,4136,4291,4191,4105,4112,4364,4084,4197,4124,4203,4207,4127,4093,4254,4066,4314,4077,4073,4048,4033,4083,4133,4414,4358,4120,4044,4059,4424,4340,4058,4306,4336,4183,4053,4211,4102,4277;
    //Argiope,Banshee,Bathory,Bow Guardian,Despero of Thanatos,Dokebi,Dolor of Thanatos,Evil Druid,Hydrolancer,Imp,Kasa,Maero of Thanatos,Odium of Thanatos,Pasana,Salamander,Sandman,Siroma,Sword Guardian,Swordfish,Zerom
	setarray .card10m,4114;//,4438,4119,4428,4397,4098,4398,4141,4384,4433,4431,4395,4396,4099,4429,4101,4416,4427,4089,4064;
    //Abysmal Knight,Alice,Elder,Maya Purple
	setarray .card50m,4140;//,4253,4251,4198;
    //Angeling,Arc Angeling,Dark Illusion,Deviling,Ghostring
	setarray .card100m,4054;//,4241,4169,4174,4047;
    //Amon Ra,Atroce,Baphomet,Dark Lord,Detardeurus,Doppelganger,Dracula,Drake,Eddga,Evil Snake Lord,Fallen Bishop Hibram,General Egnigem Cenia,Gloom Under Night,Golden Thief Bug,Hatii,Kiel-D-01,Lady Tanee,Lord of The Dead,Maya,Mistress,Moonlight Flower,Orc Hero,Orc Lord,Osiris,Pharaoh,Phreeoni,RSX-0806,Samurai Spector,Stormy Knight,Tao Gunka,Turtle General,Vesper,White Lady
	setarray .card500m,4236,4425;//,4147,4168,4386,4142,4134,4137,4123,4330,4441,4352,4408,4128,4324,4403,4376,4276,4146,4132,4131,4143,4135,4144,4148,4121,4342,4263,4318,4302,4305,4374,4372;
    //Assassin Cross,Berzebub,Entweihen Crothen,High Priest,High Wizard,Ifrit,Ktullanux,Lord Knight,MasterSmith,Memory of Thanatos,Randgris,Sniper
	setarray .card1b,4359;//,4145,4451,4363,4365,4430,4419,4357,4361,4399,4407,4367;
	//All else : 1m
	end;
}

 

Edited by 6ttctt9
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

too many loop, simplify your script

prontera,181,204,4	script	Card Buyer	658,{
	mes "[Card Buyer]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++)
	{
		.@card_id = @inventorylist_id[.@i];
		.@card_qt = @inventorylist_amount[.@i];

		if (getiteminfo(.@card_id, 2) != 6)
			continue; // skip not card

		// find if this card can be sold to this npc
		.@f = inarray(.card_list, .@card_id);

		// not in list card that can be sold, skip!
		if (.@f == -1)
			continue;

		.@menu$[.@n]     = getitemname(.@card_id) + callfunc("F_InsertComma", .card_price[.@card_id]);
		.@card_ids[.@n] = .@card_id;
		.@card_qts[.@n] = .@card_qt;
		.@n++;
	}
	.@s = select(implode(.@menu$, ":")) -1;
	mes "[Card Buyer]";
	.@card_id = .@card_ids[.@s];
	.@card_qt = .@card_qts[.@s];
	mes "You want to sell "+ getitemname(.@card_id) +"?";
	mes "I will pay you "+ callfunc("F_InsertComma", .card_price[.@card_id]) +"z/ea";
	.@total = .card_price[.@card_id] * .@card_qt;
	mes "Total Price: "+ callfunc("F_InsertComma", .@total)+"z.";
	select("Yes");
	delitem .@card_id, .@card_qt;
	Zeny += .@total;
	mes "[Card Buyer]";
	mes "Thank you for your patronage!";
	close;
	
OnInit:
	function AddCard;
	/*
		@param price in zeny
		@param "card id:card id:card id:...."
		
		Sample:
			AddCard(10000, "4001:4002:4003");
	*/
	freeloop(true);

	AddCard(100000, "4032:4013:4023:4009:4004:4002:4026:4019:4006:4050:4008:4011:4001:4021:4022:4028:4016:4051");
	AddCard(500000, "4043:4015:4052:4027:4003:4014:4012:4010:4034");

	freeloop(false);
	end;

function	AddCard	{
	.@price = getarg(0, 0);
	if (.@price < 1)
	{
		debugmes sprintf("[%s] AddCard: buying price is %d, minimum price is 1", strnpcinfo(0), .@price);
		return;
	}
	.@card_list$ = getarg(1, "");
	if (.@card$ == "")
	{
		debugmes sprintf("[%s] AddCard: card list is empty for price %d", strnpcinfo(0), .@price);
		return;
	}
	explode(.@card$, .@card_list$, ":");
	for (.@i = 0; .@i < getarraysize(.@card$); .@i++)
	{
		.@id = atoi(.@card$);
		if (getitemname(.@id) == "null")
		{
			debugmes sprintf("[%s] AddCard: card id %d is not exist price %d", strnpcinfo(0), .@id, .@price);
			continue;
		}
		.@f = inarray(.card_list, .@id);
		if (.@f > -1)
		{
			debugmes sprintf("[%s] AddCard: card id %d duplicate entry, first set price %d", strnpcinfo(0), .@id, .card_price[.@id]);
			continue;
		}
		.card_list[getarraysize(.card_list)] = .@id;
		.card_price[.@id] = .@price;
	}
	return;
}
	
}

writing it with out testing it work or not, you can use this as sample tho.. if you want

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  04/28/21
  • Last Seen:  

On 5/24/2021 at 11:00 PM, Litro Endemic said:

too many loop, simplify your script

i dont know how to simple it, there is about 9 type price, each type price have many cards id in it.
So it need 9 loop for check card id, it is in list of each type or not.

How to check:

if (.@bleble == <mutil value>)
example :
if (.@bleble == 4040,4041,4042,4043,...) ?

 

On 5/24/2021 at 11:38 PM, Litro Endemic said:

prontera,181,204,4	script	Card Buyer	658,{
	mes "[Card Buyer]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++)
	{
		.@card_id = @inventorylist_id[.@i];
		.@card_qt = @inventorylist_amount[.@i];

		if (getiteminfo(.@card_id, 2) != 6)
			continue; // skip not card

		// find if this card can be sold to this npc
		.@f = inarray(.card_list, .@card_id);

		// not in list card that can be sold, skip!
		if (.@f == -1)
			continue;

		.@menu$[.@n]     = getitemname(.@card_id) + callfunc("F_InsertComma", .card_price[.@card_id]);
		.@card_ids[.@n] = .@card_id;
		.@card_qts[.@n] = .@card_qt;
		.@n++;
	}
	.@s = select(implode(.@menu$, ":")) -1;
	mes "[Card Buyer]";
	.@card_id = .@card_ids[.@s];
	.@card_qt = .@card_qts[.@s];
	mes "You want to sell "+ getitemname(.@card_id) +"?";
	mes "I will pay you "+ callfunc("F_InsertComma", .card_price[.@card_id]) +"z/ea";
	.@total = .card_price[.@card_id] * .@card_qt;
	mes "Total Price: "+ callfunc("F_InsertComma", .@total)+"z.";
	select("Yes");
	delitem .@card_id, .@card_qt;
	Zeny += .@total;
	mes "[Card Buyer]";
	mes "Thank you for your patronage!";
	close;
	
OnInit:
	function AddCard;
	/*
		@param price in zeny
		@param "card id:card id:card id:...."
		
		Sample:
			AddCard(10000, "4001:4002:4003");
	*/
	freeloop(true);

	AddCard(100000, "4032:4013:4023:4009:4004:4002:4026:4019:4006:4050:4008:4011:4001:4021:4022:4028:4016:4051");
	AddCard(500000, "4043:4015:4052:4027:4003:4014:4012:4010:4034");

	freeloop(false);
	end;

function	AddCard	{
	.@price = getarg(0, 0);
	if (.@price < 1)
	{
		debugmes sprintf("[%s] AddCard: buying price is %d, minimum price is 1", strnpcinfo(0), .@price);
		return;
	}
	.@card_list$ = getarg(1, "");
	if (.@card$ == "")
	{
		debugmes sprintf("[%s] AddCard: card list is empty for price %d", strnpcinfo(0), .@price);
		return;
	}
	explode(.@card$, .@card_list$, ":");
	for (.@i = 0; .@i < getarraysize(.@card$); .@i++)
	{
		.@id = atoi(.@card$);
		if (getitemname(.@id) == "null")
		{
			debugmes sprintf("[%s] AddCard: card id %d is not exist price %d", strnpcinfo(0), .@id, .@price);
			continue;
		}
		.@f = inarray(.card_list, .@id);
		if (.@f > -1)
		{
			debugmes sprintf("[%s] AddCard: card id %d duplicate entry, first set price %d", strnpcinfo(0), .@id, .card_price[.@id]);
			continue;
		}
		.card_list[getarraysize(.card_list)] = .@id;
		.card_price[.@id] = .@price;
	}
	return;
}
	
}

writing it with out testing it work or not, you can use this as sample tho.. if you want

Thank you for sample!
I test it and it gives me only 1 NULL in list window. and sample is too complex for me to understand.
So I just replace all loop in my script by: if (inarray(.card100k, .@card_id) >= 0) {} then it run good.
Only one problem now is i dont know how to scipt auto close "list of selects" and reopen it again (for load the list after i sell one of them) and not need to talk npc again from begin for sell each card.
 


prontera,181,204,4	script	Card Buyer	  666,{

mes "[Card Buyer]";
mes "You have any card to sell ? <3";
next;

getinventorylist;
for (; .@i < @inventorylist_count; .@i++) {
	if(getiteminfo(@inventorylist_id[.@i],2) == 6){
        .@card_id = @inventorylist_id[.@i];
		.@card_qt = @inventorylist_amount[.@i];
		.@items[.@count] = .@card_id;
		.el = 0;
		   if(inarray(.card100k, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^00FF00100K Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card500k, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^00FF00500K Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card5m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF5M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card10m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF10M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card50m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF50M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card100m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF0000100M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card500m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF0000500M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card1b, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF00001B Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		if(.el == 0) {
		.@menu$ = .@menu$ + getitemname(.@card_id) + " ^00FF001M Zeny^000000 (" + .@card_qt + "):";
		}
		.@count++;
	}
}

.@select = select(.@menu$) - 1;

.@cardselect = .@items[.@select];

delitem .@cardselect,1;
		.el = 0;
		   if(inarray(.card100k, .@cardselect) >= 0) {
		    set Zeny, Zeny + 100000;
		   .el = 1;
		   }
		   if(inarray(.card500k, .@cardselect) >= 0) {
		    set Zeny, Zeny + 500000;
		   .el = 1;
		   }
		   if(inarray(.card5m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 5000000;
		   .el = 1;
		   }
		   if(inarray(.card10m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 10000000;
		   .el = 1;
		   }
		   if(inarray(.card50m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 50000000;
		   .el = 1;
		   }
		   if(inarray(.card100m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 100000000;
		   .el = 1;
		   }
		   if(inarray(.card500m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 500000000;
		   .el = 1;
		   }
		   if(inarray(.card1b, .@cardselect) >= 0) {
		    set Zeny, Zeny + 1000000000;
		   .el = 1;
		   }
		if(.el == 0) {
		set Zeny, Zeny + 1000000;
		}
		
end;

OnInit:
	//Ambernite,Andre Egg,Baby Desert Wolf,Chonchon,Drops,Fabre,Female Thief Bug,Hornet,Lunatic,Male Thief Bug,Picky,Picky Egg,Poring,Rocker,Spore,Tarou,Thief Bug,Yoyo
	setarray .card100k,4032,4013,4023,4009,4004,4002,4026,4019,4006,4050,4008,4011,4001,4021,4022,4028,4016,4051;
    //Andre,Condor,Elder Willow,Kukre,Pupa,Roda Frog,Thief Bug Egg,Willow,Wormtail
	setarray .card500k,4043,4015,4052,4027,4003,4014,4012,4010,4034;
    //Anubis,Beholder,Bigfoot,Bloody Butterfly,Bloody Knight,Cecil Damon,Creamy,Deviruchi,Dimik,Dragon Fly,Drosera,Eclipse,Egnigem Cenia,Eremes Guile,Enchanted Peach Tree,Executioner,Frilldora,Giant Whisper,Giearth,Goblin Leader,Gryphon,Horn,Horong,Howard Alt-Eisen,Joker,Kathryne Keyron,Khalitzburg,Kobold Leader,Loli Ruri,Marc,Marduk,Margaretha Sorin,Marine Sphere,Mastering,Medusa,Mutant Dragonoid,Mysteltainn,Nightmare,Obeaune,Ogretooth,Orc Warrior,Penomena,Phen,Pirate Skeleton,Poison Spore,Poporing,Rafflesia,Raydric,Seeker,Seyren Windsor,Sky Petite,Smokie,Soldier Andre,Stapo,Teddy Bear,Thara Frog,Toad,Ungoliant,Vagabond Wolf,Vitata,Vocal,Whisper,Zealotus
	setarray .card5m,4138,4356,4074,4327,4320,4368,4040,4122,4370,4179,4421,4266,4346,4360,4217,4250,4088,4303,4087,4155,4163,4045,4103,4362,4139,4366,4136,4291,4191,4105,4112,4364,4084,4197,4124,4203,4207,4127,4093,4254,4066,4314,4077,4073,4048,4033,4083,4133,4414,4358,4120,4044,4059,4424,4340,4058,4306,4336,4183,4053,4211,4102,4277;
    //Argiope,Banshee,Bathory,Bow Guardian,Despero of Thanatos,Dokebi,Dolor of Thanatos,Evil Druid,Hydrolancer,Imp,Kasa,Maero of Thanatos,Odium of Thanatos,Pasana,Salamander,Sandman,Siroma,Sword Guardian,Swordfish,Zerom
	setarray .card10m,4114,4438,4119,4428,4397,4098,4398,4141,4384,4433,4431,4395,4396,4099,4429,4101,4416,4427,4089,4064;
    //Abysmal Knight,Alice,Elder,Maya Purple
	setarray .card50m,4140,4253,4251,4198;
    //Angeling,Arc Angeling,Dark Illusion,Deviling,Ghostring
	setarray .card100m,4054,4241,4169,4174,4047;
    //Amon Ra,Atroce,Baphomet,Dark Lord,Detardeurus,Doppelganger,Dracula,Drake,Eddga,Evil Snake Lord,Fallen Bishop Hibram,General Egnigem Cenia,Gloom Under Night,Golden Thief Bug,Hatii,Kiel-D-01,Lady Tanee,Lord of The Dead,Maya,Mistress,Moonlight Flower,Orc Hero,Orc Lord,Osiris,Pharaoh,Phreeoni,RSX-0806,Samurai Spector,Stormy Knight,Tao Gunka,Turtle General,Vesper,White Lady
	setarray .card500m,4236,4425,4147,4168,4386,4142,4134,4137,4123,4330,4441,4352,4408,4128,4324,4403,4376,4276,4146,4132,4131,4143,4135,4144,4148,4121,4342,4263,4318,4302,4305,4374,4372;
    //Assassin Cross,Berzebub,Entweihen Crothen,High Priest,High Wizard,Ifrit,Ktullanux,Lord Knight,MasterSmith,Memory of Thanatos,Randgris,Sniper
	setarray .card1b,4359,4145,4451,4363,4365,4430,4419,4357,4361,4399,4407,4367;
	//All else : 1m
	end;
}

 

Edited by 6ttctt9
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

5 hours ago, 6ttctt9 said:

I test it and it gives me only 1 NULL in list window.

after re-reading the script I see err in my writing..

	.@card_list$ = getarg(1, "");
	if (.@card$ == "")
	{
		debugmes sprintf("[%s] AddCard: card list is empty for price %d", strnpcinfo(0), .@price);
		return;
	}
	explode(.@card$, .@card_list$, ":");
	for (.@i = 0; .@i < getarraysize(.@card$); .@i++)
	{
		.@id = atoi(.@card$);

should be

	.@card_list$ = getarg(1, "");
	if (.@card_list$ == "")
	{
		debugmes sprintf("[%s] AddCard: card list is empty for price %d", strnpcinfo(0), .@price);
		return;
	}
	explode(.@card$, .@card_list$, ":");
	for (.@i = 0; .@i < getarraysize(.@card$); .@i++)
	{
		.@id = atoi(.@card$[.@i]);

here fixed script.

prontera,181,204,4	script	Card Buyer#rAthena	658,{
	mes "[Card Buyer]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++)
	{
		.@card_id = @inventorylist_id[.@i];
		.@card_qt = @inventorylist_amount[.@i];

		if (getiteminfo(.@card_id, 2) != 6)
			continue; // skip not card

		// find if this card can be sold to this npc
		.@f = inarray(.card_list, .@card_id);

		// not in list card that can be sold, skip!
		if (.@f == -1)
			continue;

		.@menu$[.@n]     = getitemname(.@card_id) +" "+ callfunc("F_InsertComma", .card_price[.@card_id]);
		.@card_ids[.@n] = .@card_id;
		.@card_qts[.@n] = .@card_qt;
		.@n++;
	}
	if (!.@n)
	{
		mes "[Card Buyer]";
		mes "You don't have any card huh?";
		close;
	}
	.@s = select(implode(.@menu$, ":")) -1;
	mes "[Card Buyer]";
	.@card_id = .@card_ids[.@s];
	.@card_qt = .@card_qts[.@s];
	mes "You have "+ callfunc("F_InsertComma", .@card_qt) +"x "+ getitemname(.@card_id);
	mes "You want to sell "+ getitemname(.@card_id) +"? I will pay you "+ callfunc("F_InsertComma", .card_price[.@card_id]) +"z/ea";
	.@total = .card_price[.@card_id] * .@card_qt;
	mes "For total: "+ callfunc("F_InsertComma", .@total)+"z.";
	select("Yes");
	delitem .@card_id, .@card_qt;
	Zeny += .@total;
	clear;
	mes "[Card Buyer]";
	mes "Thank you for your patronage!";
	close;
	
OnInit:
	function AddCard;
	/*
		@param price in zeny
		@param "card id:card id:card id:...."
		
		Sample:
			AddCard(10000, "4001:4002:4003");
	*/
	freeloop(true);

	AddCard(100000, "4032:4013:4023:4009:4004:4002:4026:4019:4006:4050:4008:4011:4001:4021:4022:4028:4016:4051");
	AddCard(500000, "4043:4015:4052:4027:4003:4014:4012:4010:4034");

	freeloop(false);
	end;

function	AddCard	{
	.@price = getarg(0, 0);
	if (.@price < 1)
	{
		debugmes sprintf("[%s] AddCard: buying price is %d, minimum price is 1", strnpcinfo(0), .@price);
		return;
	}
	.@card_list$ = getarg(1, "");
	if (.@card_list$ == "")
	{
		debugmes sprintf("[%s] AddCard: card list is empty for price %d", strnpcinfo(0), .@price);
		return;
	}
	explode(.@card$, .@card_list$, ":");
	for (.@i = 0; .@i < getarraysize(.@card$); .@i++)
	{
		.@id = atoi(.@card$[.@i]);
		if (getitemname(.@id) == "null")
		{
			debugmes sprintf("[%s] AddCard: card id %d is not exist price %d", strnpcinfo(0), .@id, .@price);
			continue;
		}
		.@f = inarray(.card_list, .@id);
		if (.@f > -1)
		{
			debugmes sprintf("[%s] AddCard: card id %d duplicate entry, first set price %d", strnpcinfo(0), .@id, .card_price[.@id]);
			continue;
		}
		.card_list[getarraysize(.card_list)] = .@id;
		.card_price[.@id] = .@price;
	}
	return;
}
	
}

 

5 hours ago, 6ttctt9 said:

sample is too complex for me to understand.

just ask... if anyone has time and understand it, maybe there is someone will answer.

  • Love 1
Link to comment
Share on other sites

  • 0

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

there are multiple way to do it ....

 

method 1. by exploit the setd/getd to store the price of each card into a variable, so less looping required.

prontera,155,181,5	script	Card Buyer	757,{
	
	mes "["+strnpcinfo(1)+"]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++) {
		.@price = getd(".card_"+@inventorylist_id[.@i]);
		if (.@price)
			.@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF0000"+F_InsertComma(.@price)+" Zeny^000000";
		.@menu$ = .@menu$ + ":";
	}
	.@i = select(.@menu$) - 1;
	clear;
	.@price = getd(".card_"+@inventorylist_id[.@i]);
	mes "["+strnpcinfo(1)+"]";
	mes "Sell "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000?";
	if (select("Confirm", "Cancel") == 1) {
		delitem @inventorylist_id[.@i], 1;
		Zeny += .@price;
		clear;
		mes "["+strnpcinfo(1)+"]";
		mes "You have sold "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000.";
	}
	close;
	
	function	AddCard	{
		.@price = getarg(0, 0);
		.@getargcount = getargcount();
		
		for (.@i = 1; .@i <= .@getargcount; .@i++)
			setd(".card_"+getarg(.@i, 0), .@price);
		return;
	}
	
	OnInit:
		// AddCard( <zeny>, <card_id>...);
		AddCard( 10000, 4001, 4002, 4003, 4004);
		AddCard(100000, 4011, 4012, 4013, 4014);
		AddCard(500000, 4021, 4022, 4023, 4024, 4025);
		AddCard(999999, 4031, 4032, 4033, 4034, 4035, 4036);
		end;
}

 

method 2. by adjust the buy field in item_db, and set it to the value you want, then have the NPC to check for "Buy" value (why buy and not sell? because we wouldn't want player to exploit overcharge skill and direct sell to NPC)

Example: set the Poring Card's Buy value to 999,999 Zeny

  - Id: 4001
    AegisName: Poring_Card
    Buy: 999999

and have the NPC check and retrieve the Buy field value and use as selling price.

prontera,155,181,5	script	Card Buyer	757,{
	
	mes "["+strnpcinfo(1)+"]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++) {
		.@price = getiteminfo(@inventorylist_id[.@i], ITEMINFO_BUY);
		if (.@price && getiteminfo(@inventorylist_id[.@i], ITEMINFO_TYPE) == IT_CARD)
			.@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF0000"+F_InsertComma(.@price)+" Zeny^000000";
		.@menu$ = .@menu$ + ":";
	}
	.@i = select(.@menu$) - 1;
	clear;
	.@price = getiteminfo(@inventorylist_id[.@i], ITEMINFO_BUY);
	mes "["+strnpcinfo(1)+"]";
	mes "Sell "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000?";
	if (select("Confirm", "Cancel") == 1) {
		delitem @inventorylist_id[.@i], 1;
		Zeny += .@price;
		clear;
		mes "["+strnpcinfo(1)+"]";
		mes "You have sold "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000.";
	}
	close;
}

 

  • Love 1
  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

3 hours ago, Emistry said:

method 1. by exploit the setd/getd to store the price of each card into a variable, so less looping required.

prefer method 1, another note with an array and card id as index and price will get same output.

duh when I said "simplify", my script is too extra haha.. 

Link to comment
Share on other sites

  • 0

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

7 hours ago, Litro Endemic said:

an array and card id as index and price will get same output

true, but its not really an ideal solution.

why? although the emulator is kinda updated but the emulator still assume array value 0 still exists.

.array[4001] = 999999;
debugmes ".array size = " + getarraysize(.array); // output: .array size = 4002

this meant, your current array total size is 4002, which wasted the memory the allocated for the total of 4001 data from index 0 to 4000, and you dont even need it.

dont forgot that card_id could be above 5 digits or even 6 digits ID nowadays, which will end up wasting even more than we expected..

 

Edited by Emistry
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

1 hour ago, Emistry said:

true, but its not really an ideal solution.

why? although the emulator is kinda updated but the emulator still assume array value 0 still exists.


.array[4001] = 999999;
debugmes ".array size = " + getarraysize(.array); // output: .array size = 4002

this meant, your current array total size is 4002, which wasted the memory the allocated for the total of 4001 data from index 0 to 4000, and you dont even need it.

dont forgot that card_id could be above 5 digits or even 6 digits ID nowadays, which will end up wasting even more than we expected..

 

Heya,

I just wanted to add there that this is actually incorrect (unless there was a major update on rAthena I'm not aware of). The script engine does not allocate memory for the 0 to 4000 values in your example. Technically speaking, arrays are emulated and not actually arrays in the source. When you use ".array[4001]", the engine does the following:

  • ".array" is a string that gets indexed. The string is given a unique number, say 9048. From then on, everytime the string ".array" is used, it will be refered to as 9048. This is called the id.
  • 4001 is the index.
  • uid (id and index): Both of the values above combined as one (32bit for the id, 32bit for the index, making up 64bit for the uid).

The uid with its value is then stored in a big collection for the whole NPC script. This big collection also contains the values of other non-array variables such as ".temp = 20;". They are all stored in the same place. If you had written the variable as ".array_4001", it would have created a new unique value for the string such as 9049 and the index would have been 0. As you need to index the string everytime you create a new variable, using setd with a big amount of variables is usually not a good practice. Using .array[4001] is handled better source wise.

Quick note, but this is also why .@var = 5 is identical to .@var[0] = 5 and both would return the same value. They have the same uid.

What rAthena also does when you use an index greater than 0 is that it starts keeping track of the array keys (members). So say you used .array[4001], it will keep track that 4001 is a member of the array for the .array variable.

As for getarraysize(), it should be used very carefully and never in the condition of the for loop. getarraysize() does the following:

  • Checks if the .array value exists in the big collection. If not, adds 0 as a member of the array. (This is more of a hack, as it's impossible to know otherwise if [0] is part of the array or not.)
  • Go through all the members of the array and find the highest key, then does + 1.

So in your case, using getarraysize(.array) would indeed return 4002 as 4001 is the only member of the array. Using arrays instead of getd/setd would be much faster (and cleaner) in your script sample as a result:

prontera,155,181,5	script	Card Buyer	757,{
	mes "["+strnpcinfo(1)+"]";
	mes "You have any card to sell ? <3";
	next;
	getinventorylist;
	for (.@i = 0; .@i < @inventorylist_count; .@i++) {
		.@price = .card[@inventorylist_id[.@i]];
		if (.@price)
			.@menu$ = .@menu$ + getitemname(@inventorylist_id[.@i]) + " ^FF0000"+F_InsertComma(.@price)+" Zeny^000000";
		.@menu$ = .@menu$ + ":";
	}
	.@i = select(.@menu$) - 1;
	clear;
	.@price = .card[@inventorylist_id[.@i]];
	mes "["+strnpcinfo(1)+"]";
	mes "Sell "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000?";
	if (select("Confirm", "Cancel") == 1) {
		delitem @inventorylist_id[.@i], 1;
		Zeny += .@price;
		clear;
		mes "["+strnpcinfo(1)+"]";
		mes "You have sold "+getitemname(@inventorylist_id[.@i])+" for ^FF0000"+F_InsertComma(.@price)+" Zeny^000000.";
	}
	close;
function	AddCard	{
	.@price = getarg(0, 0);
	.@getargcount = getargcount();
	
	for (.@i = 1; .@i <= .@getargcount; .@i++)
		.card[getarg(.@i, 0)] = .@price;
	return;
}

OnInit:
	// AddCard( <zeny>, <card_id>...);
	AddCard( 10000, 4001, 4002, 4003, 4004);
	AddCard(100000, 4011, 4012, 4013, 4014);
	AddCard(500000, 4021, 4022, 4023, 4024, 4025);
	AddCard(999999, 4031, 4032, 4033, 4034, 4035, 4036);
	end;
}

Edit: This of course doesn't hold true if you would start iterating through the whole array with for (.@i = 0; .@i < getarraysize(.array); .@i++). This would give horrendous performance. We use the array there as a dictionary rather than a list.

Edited by Tokei
  • Upvote 3
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  04/28/21
  • Last Seen:  

Worked!!!

NPC buy cards & MPV gears from player script


prontera,181,200,2	script	MVP Equipment Buyer	 664,{

mes "[MVP Equipment Buyer]";
mes "You have any MVP's gear to sell ?";
next;

getinventorylist;
for (; .@i < @inventorylist_count; .@i++) {
 	.@item_id = @inventorylist_id[.@i];
	.equip = 0;
	if(getiteminfo(.@item_id,2) == 4){
	.equip = 1;
	}
	if(getiteminfo(.@item_id,2) == 5){
	.equip = 1;
	}
	if(.equip == 1){
	if(@inventorylist_equip[.@i] == 0) {
		.@items[.@count] = .@item_id;
		.@slots = getitemslots(.@item_id);
		.el = 0;
		   if(inarray(.equip1m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^00FF001M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip5m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^0000FF5M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip10m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^0000FF10M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip50m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^0000FF50M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip100m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^FF0000100M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip500m, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^FF0000500M Zeny^000000:";
		   .el = 1;
		   }
		   if(inarray(.equip1b, .@item_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@item_id) + " [" + .@slots + "] ^FF00001B Zeny^000000:";
		   .el = 1;
		   }
		  if(.el == 1){
		       .@count++;
		  }
		}
	}
}

.@select = select(.@menu$) - 1;

.@equipselect = .@items[.@select];

delitem .@equipselect,1;
		   if(inarray(.equip1m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 1000000;
		   }
		   if(inarray(.equip5m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 5000000;
		   }
		   if(inarray(.equip10m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 10000000;
		   }
		   if(inarray(.equip50m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 50000000;
		   }
		   if(inarray(.equip100m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 100000000;
		   }
		   if(inarray(.equip500m, .@equipselect) >= 0) {
		    set Zeny, Zeny + 500000000;
		   }
		   if(inarray(.equip1b, .@equipselect) >= 0) {
		    set Zeny, Zeny + 1000000000;
		   }

end;


OnInit:

//Golden Gear [0],Katar of Raging Blaze [0],Fortune Sword [0],Katar of Frozen Icicle [0],Hatii Claw [1]
	setarray .equip1m,2246,1258,1223,1256,1815;//easyMVP  >=15% ~5% ~1% ~0.1% ~0.01%
//Golden Mace [1],Fireblend [0],Krierg [3],Spectral Spear [0],Holy Robe [0],Sucsamad [0],Weihna [2],Corsair [0],Ice Falchion [0],Coronet [0],Erde [2],Zephyrus [0],Orcish Sword [0],Crown [0],Sphinx Hat [0],Nagan [0],Schweizersabel [0],Mage Coat [0],Long Horn [1],Hunting Spear [1],Tiara [0],Safety Ring [0],Heavenly Maiden Robe [1],Dark Blinder [0],Tablet [1],Morrigane's Belt [0],Morrigane's Pendant [0],Morpheus's Ring [0],Morpheus's Bracelet [0],Jewel Crown [0],Survivor's Manteau [0],Critical Ring [0],Eagle Wing [1],Morrigane's Manteau [0],Lord's Clothes [1],Legion Plate Armor [1],Greaves [1],Helm [1],Nydhorgg's Shadow Garb [1],Pauldron [1]            
	setarray .equip5m,1524,1133,13046,1477,2327,1236,13047,5019,1131,2249,16000,1468,1124,2235,5053,1130,1167,2334,1420,1422,2234,2615,2513,5104,1552,2650,2651,2648,2649,5002,2509,2616,2515,2519,2318,2342,2412,2229,2554,2514;//mediumMVP
//Moonlight Dagger [0],Long Mace [0],Staff Of Bordeaux [0],Holy Avenger [0],War Axe [1],Pole Axe [1],Holy Guard [0],Sacred Mission [0],Majestic Goat [0],Cutlus [0],Krasnaya [3],Lance [0],Spiky Band [0],Hellfire [0],Gae Bolg [0],Gungnir [0],Red Square Bag [2],Bloody Axe [0],Doom Slayer [1],Grand Circlet [0],Assassin Dagger [0],Chakram [2],Grimtooth [0],Ancient Cape [0],Spiritual Ring [0],Crescent Scythe [0],Dea Staff [1],Atlas Weapon [1],Ulle's Cap [1],Wizardry Staff [0],Ballista [0],Ixion Wings [1],Ice Pick [0],Dagger of Counter [0],Survivor's Rod [1],Solar Sword [0],Bazerald [0],Immaterial Sword [0],Ledger of Death [2],Staff of Destruction [1],Variant Shoes [0],Bison Horn [1],Exorciser [0],Bloody Roar [0],Ginnungagap [0],Quadrille [0],Grand Cross [0],Book of the Apocalypse [0],Sage's Diary [2],Berserk [0],Cursed Dagger [0],Robe of Cast [0],Bloodied Shackle Ball [0],Edge [0],Dragon Slayer [0],Brocca [0],Longinus's Spear [0],Brionac [0],Mysteltainn [0],Byeollungum [0],Great Axe [0],Sabbath [0],Tomahawk [0],Guillotine [0],Combat Knife [0],Rudra Bow [0],Dragon Wing [0],Luna Bow [2],Valkyrian Armor [1],Valkyrian Shoes [1],Valkyrian Manteau [1],Katzbalger [0],Cardo [1]
	setarray .equip10m,1234,1525,1648,1145,1306,1417,2110,2111,2256,1135,1189,1411,2258,1471,1474,1413,16001,1363,1371,5007,1232,1285,1237,2507,2677,1466,2005,1175,5123,1473,1722,1737,1230,1242,1618,1136,1231,1141,1565,2000,2423,2702,1233,1265,13002,1527,1528,1557,1560,1814,1241,2343,2655,1132,1166,1415,1469,1470,1138,1140,1364,1365,1368,1369,1228,1720,1724,1723,2357,2421,2524,1170,1484;//hardMVP
//Azoth [0],Zweihander [0],Light Epsilon [0],Giant Axe [1],Kronos [0],Crescent Scythe [1],Red Silk Seal [0],Hurricane's Fury [1],Iron Driver [0],Vesper Core 01 [0],Vesper Core 02 [0],Vesper Core 03 [0],Vesper Core 04 [0],Lucius's Fierce Armor of Volcano [1],Ring Of Flame Lord [0],Ring Of Resonance [0],Saphien's Armor of Ocean [1],Twin Edge of Naght Sieger [3]x2
	setarray .equip50m,1235,1168,1366,1387,2004,1476,2700,1377,1529,2659,2660,2661,2662,2345,2678,2679,2347,13412,13413;//superhardMVP
//Majestic Goat [1],Wrench [0],Ice Pick [1]
	setarray .equip100m,5160,1531,13017;
//Masamune [0]
	setarray .equip500m,1165;
//Sleipnir [0],Megingjard [0],Brisingamen [0],Mjolnir [0],Asprika [0],Brynhild [0]
	setarray .equip1b,2410,2629,2630,1530,2541,2383;

	end;
}






prontera,179,202,4	script	Coco	  658,{
mes "Yek!";
close;
}






prontera,183,202,4	script	Buyers's Bodyguard	  683,{
mes "[Buyers's Bodyguard]";
mes "Hello! I am just a bodyguard!";
close;
}







prontera,181,204,4	script	Card Buyer	  666,{

mes "[Card Buyer]";
mes "You have any card to sell ? <3";
next;

getinventorylist;
for (; .@i < @inventorylist_count; .@i++) {
	if(getiteminfo(@inventorylist_id[.@i],2) == 6){
        .@card_id = @inventorylist_id[.@i];
		.@card_qt = @inventorylist_amount[.@i];
		.@items[.@count] = .@card_id;
		.el = 0;
		   if(inarray(.card1m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF1M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card5m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF5M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card10m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF10M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card50m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^0000FF50M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card100m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF0000100M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card500m, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF0000500M Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		   if(inarray(.card1b, .@card_id) >= 0) {
		    .@menu$ = .@menu$ + getitemname(.@card_id) + " ^FF00001B Zeny^000000 (" + .@card_qt + "):";
		   .el = 1;
		   }
		if(.el == 0) {
		.@menu$ = .@menu$ + getitemname(.@card_id) + " ^00FF0050K Zeny^000000 (" + .@card_qt + "):";
		}
		.@count++;
	}
}

.@select = select(.@menu$) - 1;

.@cardselect = .@items[.@select];

delitem .@cardselect,1;
		.el = 0;
		   if(inarray(.card1m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 1000000;
		   .el = 1;
		   }
		   if(inarray(.card5m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 5000000;
		   .el = 1;
		   }
		   if(inarray(.card10m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 10000000;
		   .el = 1;
		   }
		   if(inarray(.card50m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 50000000;
		   .el = 1;
		   }
		   if(inarray(.card100m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 100000000;
		   .el = 1;
		   }
		   if(inarray(.card500m, .@cardselect) >= 0) {
		    set Zeny, Zeny + 500000000;
		   .el = 1;
		   }
		   if(inarray(.card1b, .@cardselect) >= 0) {
		    set Zeny, Zeny + 1000000000;
		   .el = 1;
		   }
		if(.el == 0) {
		set Zeny, Zeny + 50000;
		}
		
end;

OnInit:

	//EXPCards4245-4235,GarmentElementalDamageIncrease4432-4422,CriticalCards4246-4176,WeapontoRaceCards4035-4118,WeapontoElementCards4049-4202,WeapontoSizeCards4082-4126,WeaponStatusCards4096-4104,ArmorCastStatus4301-4194,RaceDrainSP:4329-4316,MinibossEasy:4197,4266,4179,4306,4183,Autocast:4244,4400,4248,4234,4243,4320,4212,4284,4299,4217,4439,4418,4280,4161,4283,4381,4323,4343,4268,4191,4193,4199,4341,4420,4175,4313,4294,4230,4172,4209,4210,4332,4264,EnableSkillLow:4356,4103,4139,4093,4048,4033,4414,4044,4424==
	setarray .card1m,4245,4204,4221,4239,4249,4275,4164,4151,4267,4235,4432,4422,4246,4297,4214,4156,4310,4157,4192,4292,4176,4035,4060,4063,4007,4111,4130,4080,4068,4118,4049,4069,4030,4065,4085,4005,4062,4202,4082,4092,4126,4096,4037,4025,4017,4057,4020,4024,4055,4076,4390,4104,4301,4404,4162,4295,4298,4286,4383,4166,4189,4216,4300,4270,4333,4213,4181,4173,4222,4170,4315,4201,4194,4329,4167,4165,4308,4182,4274,4307,4289,4180,4316,4197,4266,4179,4306,4183,4244,4400,4248,4234,4243,4320,4212,4284,4299,4217,4439,4418,4280,4161,4283,4381,4323,4343,4268,4191,4193,4199,4341,4420,4175,4313,4294,4230,4172,4209,4210,4332,4264,4356,4103,4139,4093,4048,4033,4414,4044,4424;
    //ImmuneCards4336-4124,ElementDamageReduce4334-4108,RaceReduceDamage4058-4138,SizeReduceDamage4207-4413,HighUpgradeLevel:4242-4226,LowUpgradeLevel:4379-4378,BioGhost:4346,4348,4347,4349,4351,4350,MagicSkillBuff4388-4380,Food-Drop:4344-4377,Box-Drop:4228-4190,StatSwitchingCards4369-4338,MagicResistCards4278-4200,MinibossMed:4423,4203,4163,4354,4237,4238,4290,4394,EnableSkillHigh:4040,4088,4084,4073,4053==
	setarray .card5m,4336,4122,4087,4105,4112,4127,4124,4334,4325,4133,4109,4095,4056,4081,4116,4071,4113,4108,4058,4066,4074,4314,4136,4340,4083,4059,4120,4138,4207,4254,4250,4413,4242,4288,4160,4319,4159,4375,4226,4379,4378,4346,4348,4347,4349,4351,4350,4388,4345,4335,4380,4344,4391,4355,4385,4377,4228,4187,4262,4224,4265,4149,4256,4190,4369,4387,4392,4393,4338,4278,4150,4240,4287,4200,4423,4203,4163,4354,4237,4238,4290,4394,4040,4088,4084,4073,4053;
    //ArmorElements4114-4119,BioMVPghost:4358,4360,4362,4364,4368,4366,ofThanatos:4397,4398,4395,4396,AddedStatsUpgrade:4370-4373,MinibossHard:4428,4198,4406,4431,4427,4426,4440,4429==
	setarray .card10m,4114,4141,4099,4089,4098,4101,4119,4358,4360,4362,4364,4368,4366,4397,4398,4395,4396,4370,4373,4428,4198,4406,4431,4427,4426,4440,4429;
    //BossEffect:Abysmal Knight,Alice,GuardianEffect:Elder,Mi Gao,MinibossSuperHard:4169,4384,Incubus+Succubus==
	setarray .card50m,4140,4253,4251,4231,4169,4384,4269,4218;
    //MinibossMostValue:Angeling,Deviling,Ghostring,Arc Angeling==
	setarray .card100m,4054,4174,4047,4241;
    //MVPCards:Amon Ra,Atroce,White Lady,Baphomet,Berzebub,Dark Lord,Detardeurus,Doppelganger,Dracula,Drake,Eddga,Evil Snake Lord,Fallen Bishop Hibram,Hatii,Gloom Under Night,Golden Thief Bug,Ifrit,Samurai Spector,Kiel-D-01,Stormy Knight,Ktullanux,Lady Tanee,Lord of The Dead,Maya,Mistress,Moonlight Flower,Orc Hero,Orc Lord,Osiris,Pharaoh,Phreeoni,RSX-0806,Tao Gunka,Turtle General,Randgris,Vesper,General Egnigem Cenia==
	setarray .card500m,4236,4425,4372,4147,4145,4168,4386,4142,4134,4137,4123,4330,4441,4324,4408,4128,4430,4263,4403,4318,4419,4376,4276,4146,4132,4131,4143,4135,4144,4148,4121,4342,4302,4305,4407,4374,4352;
    //6BiolabMVP,Memory of Thanatos==
	setarray .card1b,4359,4363,4365,4357,4367,4361,4399;
	//All else : 50k

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