Jump to content
  • 0

R> NPC Mix Cards


wingsofloveza

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   13
  • Joined:  03/20/17
  • Last Seen:  

Mix 5 cards that are not used to randomly receive 1 new card.
With a fee of 100k zeny.

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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

prontera,155,185,5	script	kjsfksdfhj	100,{
	getinventorylist;
	for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
		if ( getiteminfo( @inventorylist_id[.@i], 2 ) == IT_CARD ) {
			.@name$ = getitemname( @inventorylist_id[.@i] );
			if ( substr( .@name$, getstrlen(.@name$) -4, getstrlen(.@name$) -1 ) == "Card" ) {
				.@cardid[.@c] = @inventorylist_id[.@i];
				.@amount[.@c] = @inventorylist_amount[.@i];
				++.@c;
			}
		}
	}
	for ( .@i = 0; .@i < .@c; ++.@i )
		.@total += .@amount[.@i];
	if ( .@total < 5 ) {
		mes "you don't have total of 5 cards";
		close;
	}
	if ( Zeny < 100000 ) {
		mes "You don't have enough Zeny.";
		close;
	}
	for ( .@i = 0; .@i < .@c; ++.@i )
		.@menu$ += .@amount[.@i] +"x "+ getitemname( .@cardid[.@i] ) +":";
	.@menu$ += "[Done]";
	while ( true ) {
		mes "Choose up to 5 cards";
		for ( .@i = 0; .@i < .@choose_total; ++.@i )
			mes .@choose_amount[.@i] +"x "+ getitemname( .@choose_cardid[.@i] );
		next;
		.@s = select( .@menu$ ) -1;
		if ( .@s == .@c ) {
			.@total = 0;
			for ( .@i = 0; .@i < .@choose_total; ++.@i )
				.@total += .@choose_amount[.@i];
			if ( .@total != 5 ) {
				mes "you didn't choose total of 5 cards";
				next;
			}
			else
				break;
		}
		else {
			mes "input the amount to roll";
			if ( input( .@input, 0, .@amount[.@s] ) ) {
				mes "invalid amount";
				next;
			}
			else {
				for ( .@i = 0; .@i < .@choose_total; ++.@i ) {
					if ( .@choose_cardid[.@i] == .@cardid[.@s] ) {
						deletearray .@choose_cardid[.@i], 1;
						deletearray .@choose_amount[.@i], 1;
						--.@i;
						--.@choose_total;
						break;
					}
				}
				if ( .@input ) {
					.@choose_cardid[.@choose_total] = .@cardid[.@s];
					.@choose_amount[.@choose_total] = .@input;
					++.@choose_total;
				}
			}
		}
	}
	mes "Are you sure you want to use";
	for ( .@i = 0; .@i < .@choose_total; ++.@i )
		mes .@choose_amount[.@i] +"x "+ getitemname( .@choose_cardid[.@i] );
	mes "for a random card ?";
	next;
	if ( select ( "Yes", "No" ) == 2 ) close;
	for ( .@i = 0; .@i < .@choose_total; ++.@i ) {
		if ( countitem( .@choose_cardid[.@i] ) < .@choose_amount[.@i] ) {
			mes "Don't try to cheat with me !!";
			close;
		}
	}
	if ( Zeny < 100000 ) {
		mes "You don't have enough Zeny.";
		close;
	}
	if ( !checkweight( 1201, 1 ) ) {
		mes "You don't have enough space";
		close;
	}
	for ( .@i = 0; .@i < .@choose_total; ++.@i )
		delitem .@choose_cardid[.@i], .@choose_amount[.@i];
	Zeny -= 100000;
	getitem .cardid[ rand( .card_total ) ], 1;
	close;
OnInit:
	.card_total = query_sql( "select id from item_db_re where type = "+ IT_CARD +" and name_japanese like '%Card'", .cardid );
	end;
}

I thought this is simple request, but ends up like writing a mini-mission board like script

@wingsofloveza

Edited by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   13
  • Joined:  03/20/17
  • Last Seen:  

Thank you @AnnieRuru it work.

How to edit not use sql ?

Link to comment
Share on other sites

  • 0

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

prontera,155,185,5	script	kjsfksdfhj	1_F_MARIA,{
	getinventorylist;
	for ( .@i = 0; .@i < @inventorylist_count; ++.@i ) {
		if ( getiteminfo( @inventorylist_id[.@i], 2 ) == IT_CARD ) {
			.@name$ = getitemname( @inventorylist_id[.@i] );
			.@strlen = getstrlen(.@name$);
			if ( substr( .@name$, .@strlen -4, .@strlen -1 ) == "Card" ) {
				.@cardid[.@c] = @inventorylist_id[.@i];
				.@amount[.@c] = @inventorylist_amount[.@i];
				++.@c;
			}
		}
	}
	for ( .@i = 0; .@i < .@c; ++.@i )
		.@total += .@amount[.@i];
	if ( .@total < 5 ) {
		mes "you don't have total of 5 cards";
		close;
	}
	if ( Zeny < 100000 ) {
		mes "You don't have enough Zeny.";
		close;
	}
	for ( .@i = 0; .@i < .@c; ++.@i )
		.@menu$ += .@amount[.@i] +"x "+ getitemname( .@cardid[.@i] ) +":";
	.@menu$ += "[Done]";
	while ( true ) {
		mes "Choose up to 5 cards";
		for ( .@i = 0; .@i < .@choose_total; ++.@i )
			mes .@choose_amount[.@i] +"x "+ getitemname( .@choose_cardid[.@i] );
		next;
		.@s = select( .@menu$ ) -1;
		if ( .@s == .@c ) {
			.@total = 0;
			for ( .@i = 0; .@i < .@choose_total; ++.@i )
				.@total += .@choose_amount[.@i];
			if ( .@total != 5 ) {
				mes "you didn't choose total of 5 cards";
				next;
			}
			else
				break;
		}
		else {
			mes "input the amount to roll";
			if ( input( .@input, 0, .@amount[.@s] ) ) {
				mes "invalid amount";
				next;
			}
			else {
				for ( .@i = 0; .@i < .@choose_total; ++.@i ) {
					if ( .@choose_cardid[.@i] == .@cardid[.@s] ) {
						deletearray .@choose_cardid[.@i], 1;
						deletearray .@choose_amount[.@i], 1;
						--.@i;
						--.@choose_total;
						break;
					}
				}
				if ( .@input ) {
					.@choose_cardid[.@choose_total] = .@cardid[.@s];
					.@choose_amount[.@choose_total] = .@input;
					++.@choose_total;
				}
			}
		}
	}
	mes "Are you sure you want to use";
	for ( .@i = 0; .@i < .@choose_total; ++.@i )
		mes .@choose_amount[.@i] +"x "+ getitemname( .@choose_cardid[.@i] );
	mes "for a random card ?";
	next;
	if ( select ( "Yes", "No" ) == 2 ) close;
	for ( .@i = 0; .@i < .@choose_total; ++.@i ) {
		if ( countitem( .@choose_cardid[.@i] ) < .@choose_amount[.@i] ) {
			mes "Don't try to cheat with me !!";
			close;
		}
	}
	if ( Zeny < 100000 ) {
		mes "You don't have enough Zeny.";
		close;
	}
	if ( !checkweight( 1201, 1 ) ) {
		mes "You don't have enough space";
		close;
	}
	for ( .@i = 0; .@i < .@choose_total; ++.@i )
		delitem .@choose_cardid[.@i], .@choose_amount[.@i];
	Zeny -= 100000;
	getitem .cardid[ rand( .card_total ) ], 1;
	close;
OnInit:
	setarray .cardid, 4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4029,4030,4031,4032,4033,4034,4035,4036,4037,4038,4039,4040,4041,4042,4043,4044,4045,4046,4047,4048,4049,4050,4051,4052,4053,4054,4055,4056,4057,4058,4059,4060,4061,4062,4063,4064,4065,4066,4067,4068,4069,4070,4071,4072,4073,4074,4075,4076,4077,4078,4079,4080,4081,4082,4083,4084,4085,4086,4087,4088,4089,4090,4091,4092,4093,4094,4095,4096,4097,4098,4099,4100,4101,4102,4103,4104,4105,4106,4107,4108,4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,4124,4125,4126,4127,4128,4129,4130,4131,4132,4133,4134,4135,4136,4137,4138,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,4151,4152,4153,4154,4155,4156,4157,4158,4159,4160,4161,4162,4163,4164,4165,4166,4167,4168,4169,4170,4171,4172,4173,4174,4175,4176,4177,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4189,4190,4191,4192,4193,4194,4195,4196,4197,4198,4199,4200,4201,4202,4203,4204,4205,4206,4207,4208,4209,4210,4211,4212,4213,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4224,4225,4226,4227,4228,4229,4230,4231,4232,4233,4234,4235,4236,4237,4238,4239,4240,4241,4242,4243,4244,4245,4246,4247,4248,4249,4250,4251,4252,4253,4254,4255,4256,4257,4258,4259,4260,4261,4262,4263,4264,4265,4266,4267,4268,4269,4270,4271,4272,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,4285,4286,4287,4288,4289,4290,4291,4292,4293,4294,4295,4296,4297,4298,4299,4300,4301,4302,4303,4304,4305,4306,4307,4308,4309,4310,4311,4312,4313,4314,4315,4316,4317,4318,4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4330,4331,4332,4333,4334,4335,4336,4337,4338,4339,4340,4341,4342,4343,4344,4345,4346,4347,4348,4349,4350,4351,4352,4353,4354,4355,4356,4357,4358,4359,4360,4361,4362,4363,4364,4365,4366,4367,4368,4369,4370,4371,4372,4373,4374,4375,4376,4377,4378,4379,4380,4381,4382,4383,4384,4385,4386,4387,4388,4389,4390,4391,4392,4393,4394,4395,4396,4397,4398,4399,4400,4401,4402,4403,4404,4405,4406,4407,4408,4409,4410,4411,4412,4413,4414,4415,4416,4417,4418,4419,4420,4421,4422,4423,4424,4425,4426,4427,4428,4429,4430,4431,4432,4433,4434,4435,4436,4437,4438,4439,4440,4441,4442,4443,4444,4445,4446,4447,4448,4449,4450,4451,4452,4453,4454,4455,4456,4457,4458,4459,4460,4461,4462,4463,4464,4465,4466,4467,4468,4469,4470,4471,4472,4473,4474,4475,4476,4477,4478,4479,4480,4481,4482,4483,4484,4485,4486,4487,4488,4489,4490,4491,4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507,4508,4509,4510,4511,4512,4513,4514,4515,4516,4517,4518,4519,4520,4521,4522,4523,4524,4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,4536,4537,4538,4539,4540,4541,4542,4543,4544,4545,4546,4547,4548,4549,4550,4552,4553,4554,4555,4556,4557,4559,4560,4561,4562,4563,4564,4565,4566,4567,4568,4569,4570,4571,4572,4573,4574,4575,4576,4577,4578,4579,4580,4581,4582,4583,4584,4585,4586,4587,4588,4589,4590,4591,4592,4593,4594,4595,4596,4597,4598,4599,4600,4601,4602,4603,4604,4605,4606,4607,4608,4609,4610,4625,4626,4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642,4643,4644,4645,4646,4647,4648,4649,4650,4651,4652,4653,4654,4655,4656,4657,4658,4659,4660,4661,4662,4663,4664,4665,4666,4667,4668,4669,4670,4671,4672,4673,4674,4675,4676,4677,4678,4679,4680,4681,4682,4683,4684,4685,4686,4687,4688,4689,4690,4691,4692,4693,4694,4695,4696,4697,4698,4699,6846,22875,27012,27013,27014,27015,27016,27017,27018,27019,27020,27025,27026,27027,27028,27029,27030,27081,27082,27083,27084,27085,27086,27087,27088,27101,27102,27103,27104,27105,27106,27107,27108,27109,27110,27111,27112,27113,27114,27115,27116,27117,27118,27119,27120,27121,27122,27123,27124,27125,27126,27147,27148,27149,27150,27151,27152,27157,27158,27159,27160,27161,27162,27163,27164,27165,27166,27167,27168,27169,27170,27171,27172,27173,27174,27175,27176,27177,27178,27179,27180,27181,27182,27183,27184,27196,27197,27198,27199,27249,27250,27251,27252,27253,27254,27255,27256,27257,27258,27259,27260,27261,27262,27263,27264,27265,27286,27287,27288,27289,27290,27291,27292,27293,27294,27295,27296,27297,27298,27304,27305,27306,27307,27308,27309,27310,27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27322,27323,27324,27325,27326,27327,27328,27330,27331,27332,27333,27334,27335,27336,27337,27338,27339,27340,27341,27342,27343,31006,31007,31008,31009,31010,31011,31012,31013,31014,31015,31016,31017,31018,31019,31020,31021,31022,31023;
	.card_total = getarraysize( .cardid );
	end;
}

array generated by export result into cvs, then run macro with notepad++

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  228
  • Reputation:   19
  • Joined:  10/27/12
  • Last Seen:  

1

Why not make menu only show card that is applicable for roll only??

thus hiding all those not reach the amount required for a roll.

then only able to choose one option (card) then next; then select to continue or not

 

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