Jump to content
  • 0

help with script OnSellItem


LearningRO

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

somebod can help me to change list sell card into sell costume item??

//===== rAthena Script =======================================
//= Card Trader
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.1 
//===== Compatible With: =====================================
//= rAthena SVN
//===== Description: =========================================
//= Exchange cards for points.
//============================================================
 
prontera,195,170,4	script	Costume Trader	10044,{
	mes "[^995050Costume Trader^000000]";
	mes "Hi, "+strcharinfo(0)+"!";
	mes "What can I do for you?";
	next;
	switch(select(" > Information: > Trade in costume: > Point shop (^0055FF"+getd(.Points$)+"^000000): > Leave")) {
	case 1:
		mes "[^995050Card Captor Sakura^000000]";
		mes "Do you find that you've got";
		mes "useless Costume lying around?";
		mes "I'll be glad to take them off";
		mes "your hands!";
		next;
		mes "[^995050Card Captor Sakura^000000]";
		mes "I'll give you";
		mes "^0055FF"+.Points[0]+" Point"+((.Points[0] == 1)?"":"s")+"^000000 for Low Costume.";
		mes "^0055FF"+.Points[1]+" Point"+((.Points[1] == 1)?"":"s")+"^000000 for Low Medium.";
		mes "^0055FF"+.Points[2]+" Point"+((.Points[2] == 1)?"":"s")+"^000000 for Low Rare.";
		mes "^0055FF"+.Points[3]+" Point"+((.Points[3] == 1)?"":"s")+"^000000 for Low Special.";
		mes "You can trade those points";
		mes "for items later on.";
		mes "How does that sound?";
		emotion e_cash;
		close;
	case 2:
		mes "[^995050Card Captor Sakura^000000]";
		mes "Select the cards you";
		mes "want to trade in.";
		if (.Level) {
			mes " ";
			mes "They must be dropped";
			mes "by monsters of level";
			mes .Level+" and above.";
		}
		deletearray @sold_nameid[0],getarraysize(@sold_nameid);
		callshop "card_shop",2;
		npcshopattach "card_shop";
		end;
	case 3:
		mes "[^995050Card Captor Sakura^000000]";
		mes "You have ^0055FF"+getd(.Points$)+"^000000 Point"+((getd(.Points$) == 1)?".":"s.");
		callshop "card_shop",1;
		npcshopattach "card_shop";
		end;
	case 4:
		mes "[^995050Card Captor Sakura^000000]";
		mes "*yawn*";
		mes "See you later!";
		emotion e_yawn;
		close;		
	}
 
OnSellItem:
	mes "Cards to sell:";
	mes "-----------------------------------";
	for(set .@i,0; .@i<getarraysize(@sold_nameid); set .@i,.@i+1)
		if (@sold_nameid[.@i] > 4000 && @sold_nameid[.@i] < 4700) {
			if (.Level) {
				query_sql("SELECT `LV` FROM `mob_db` WHERE `DropCardid` = "+@sold_nameid[.@i],.@lv);
				if (.@lv < .Level) {
					dispbottom getitemname(@sold_nameid[.@i])+" is under the minimum level.";
					continue;
				}
			}
			set .@card_id[getarraysize(.@card_id)], @sold_nameid[.@i];
			set .@card_amt[getarraysize(.@card_amt)], @sold_quantity[.@i];
			set .@class2, compare(.class2$,""+@sold_nameid[.@i]);
			set .@class3, compare(.class3$,""+@sold_nameid[.@i]);
			set .@class4, compare(.class4$,""+@sold_nameid[.@i]);
			mes ((.@class2 || .@class3 || .@class4)?"  ^FF0000":"  ^777777")+@sold_quantity[.@i]+"x "+getitemname(@sold_nameid[.@i])+"^000000";
			if(.@class2) { .@class=1; }
			else if(.@class3) { .@class=2; }
			else if(.@class4) { .@class=3; }
			else { .@class=0; } 
			set .@card_total, .@card_total+ ( @sold_quantity[.@i]* .Points[.@class] );
		}
	deletearray @sold_nameid[0], getarraysize(@sold_nameid);
	deletearray @sold_quantity[0], getarraysize(@sold_quantity);
	if (!.@card_id) {
		mes "  ^777777(none)^000000";
		emotion e_swt;
		close;
	}
	mes " ";
	mes "---------- Total: ^0055FF"+.@card_total+" pt.^000000 -------";
	next;
	if(select(" > ^0055FFComplete trade...^000000: > ^777777Cancel^000000") == 2) {
		mes "[Card Trader]";
		mes "Oh, okay...";
		emotion e_hmm;
		close;
	}
	for(set .@i,0; .@i<getarraysize(.@card_id); set .@i,.@i+1)
		delitem .@card_id[.@i],.@card_amt[.@i];
	setd .Points$, getd(.Points$)+.@card_total;
	mes "[Card Trader]";
	mes "All done!";
	emotion e_ho;
	close;
 
OnBuyItem:
	for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
		for(set .@j,0; .@j<getarraysize(.Shop); set .@j,.@j+2)
			if (@bought_nameid[.@i] == .Shop[.@j]) {
				set .@cost, .@cost+(.Shop[.@j+1]*@bought_quantity[.@i]);
				break;
			}
	if (.@cost > getd(.Points$)) {
		mes "[Card Trader]";
		mes "You don't have enough Points.";
		emotion e_omg;
	}
	else {
		mes "Items purchased:";
		mes "-----------------------------------";
		for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			mes "  ^777777"+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+"^000000";
		}
		mes " ";
		mes "---------- Total: ^0055FF"+.@cost+" pt.^000000 -------";
		setd .Points$, getd(.Points$)-.@cost;
		emotion e_cash;
	}
	deletearray @bought_nameid[0], getarraysize(@bought_nameid);
	deletearray @bought_quantity[0], getarraysize(@bought_quantity);
	close;
 
OnInit:
	set .Level,0;		   // Minimum monster level to trade corresponding cards.
	set .Points$,"#Card_Points";	// Variable to store points.
	setarray .Shop[0],		// Card Shop items: <ID>,<point cost>
	  5027,10, 18505,10, 5176,10, 5305,20;

	//setarray .Points[0],5,100;	// Points per <normal card>,<MVP card>
	setarray .Points[0],1,2,3,4;	// Points per <Class 1>,<Class 2>,<Class 3>,<Class 4>
	set .class1$,
		"501,502";

	set .class2$,	// Class 2 cards | Those not within Class 2 ~4 are all Class 1
		"503,504";
		
	set .class3$,
		"505,506";
		
	set .class4$,			// List of MVP cards. | Previously .MVP$
		"507,508";
	
	npcshopdelitem "card_shop",909;
	for(set .@i,0; .@i<getarraysize(.Shop); set .@i,.@i+2)
		npcshopadditem "card_shop",.Shop[.@i],.Shop[.@i+1];
	end;
}
-	shop	card_shop	-1,909:-1

more info what i want :

how to change this part to read array from class1,class2,class3,class4

OnSellItem:
	mes "Cards to sell:";
	mes "-----------------------------------";
	for(set .@i,0; .@i<getarraysize(@sold_nameid); set .@i,.@i+1)
		if (@sold_nameid[.@i] > 4000 && @sold_nameid[.@i] < 4700) {
			if (.Level) {
				query_sql("SELECT `LV` FROM `mob_db` WHERE `DropCardid` = "+@sold_nameid[.@i],.@lv);
				if (.@lv < .Level) {
					dispbottom getitemname(@sold_nameid[.@i])+" is under the minimum level.";
					continue;
				}
			}
			set .@card_id[getarraysize(.@card_id)], @sold_nameid[.@i];
			set .@card_amt[getarraysize(.@card_amt)], @sold_quantity[.@i];
			set .@class2, compare(.class2$,""+@sold_nameid[.@i]);
			set .@class3, compare(.class3$,""+@sold_nameid[.@i]);
			set .@class4, compare(.class4$,""+@sold_nameid[.@i]);
			mes ((.@class2 || .@class3 || .@class4)?"  ^FF0000":"  ^777777")+@sold_quantity[.@i]+"x "+getitemname(@sold_nameid[.@i])+"^000000";
			if(.@class2) { .@class=1; }
			else if(.@class3) { .@class=2; }
			else if(.@class4) { .@class=3; }
			else { .@class=0; } 
			set .@card_total, .@card_total+ ( @sold_quantity[.@i]* .Points[.@class] );
		}
	deletearray @sold_nameid[0], getarraysize(@sold_nameid);
	deletearray @sold_quantity[0], getarraysize(@sold_quantity);
	if (!.@card_id) {
		mes "  ^777777(none)^000000";
		emotion e_swt;
		close;
	}
	mes " ";
	mes "---------- Total: ^0055FF"+.@card_total+" pt.^000000 -------";
	next;
	if(select(" > ^0055FFComplete trade...^000000: > ^777777Cancel^000000") == 2) {
		mes "[Card Trader]";
		mes "Oh, okay...";
		emotion e_hmm;
		close;
	}
	for(set .@i,0; .@i<getarraysize(.@card_id); set .@i,.@i+1)
		delitem .@card_id[.@i],.@card_amt[.@i];
	setd .Points$, getd(.Points$)+.@card_total;
	mes "[Card Trader]";
	mes "All done!";
	emotion e_ho;
	close;

this array

	//setarray .Points[0],5,100;	// Points per <normal card>,<MVP card>
	setarray .Points[0],1,2,3,4;	// Points per <Class 1>,<Class 2>,<Class 3>,<Class 4>
	set .class1$,
		"501,502";

	set .class2$,	// Class 2 cards | Those not within Class 2 ~4 are all Class 1
		"503,504";
		
	set .class3$,
		"505,506";
		
	set .class4$,			// List of MVP cards. | Previously .MVP$
		"507,508";
	

 

Edited by melv0
Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

There. I've added a code portion to prevent "all items sell", and moved the array of sold items filling so items which doesn't give point won't be deleted.

costumetrader.txt

  • Upvote 2
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

somebody??

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Sorry might be me, but I don't understand what you're trying to change / what you want. Did you allready changed something in the script too?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

13 hours ago, Alayne said:

Sorry might be me, but I don't understand what you're trying to change / what you want. Did you allready changed something in the script too?

im sorry bad english 

what I want is to change this script into an exchange item costume> point not card > point
ex:
low grade costum> 1 point
Med grade costume> 2 point
rare grade costume> 3 point

its can??

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Oh right. I understand now. 

Well anything is possible as long as we take time to do it ^^. I need to look a bit more at the script itself to have more ideas.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Can't test it right now, but this should work (and not only for costume, but for any kind of item).

Just fill the .class1$, .class2$ and so on with right costume ids, and then give it a shot.

costumetrader.txt

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

1 hour ago, Alayne said:

Can't test it right now, but this should work (and not only for costume, but for any kind of item).

Just fill the .class1$, .class2$ and so on with right costume ids, and then give it a shot.

costumetrader.txt

it's work like i want but have a bug 

You can sell all kinds of items even if the item is not in the array list?
should create a new array to list any items that can be exchanged with points?

Edited by melv0
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

yeap, but you can't prevent that. The window doesn't include a check for item type. In better case, we can add a check "at least one point given" and cancel selling if that's not triggering, so people won't sell other items.

But you can't say "allow selling only for costume" (afaik at least)

Edited by Alayne
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

3 minutes ago, Alayne said:

yeap, but you can't prevent that. The window doesn't include a check for item type. In better case, we can add a check "at least one point given" and cancel selling if that's not triggering, so people won't sell other items.

But you can't say "allow selling only for costume" (afaik at least)

yeah how to make the item not on list give 0 points?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

57 minutes ago, Alayne said:

There. I've added a code portion to prevent "all items sell", and moved the array of sold items filling so items which doesn't give point won't be deleted.

costumetrader.txt

fully work right now..

thx man u save my day :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Your welcome ^^

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

hi, @Alayne sorry to bump this topic, but i have serously bug from your script

ex: i set my list costume id into set .class3$,"19537";

player still can sell petfood(with id 537) and get point

how to fix that thxx uu

Edited by melv0
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

that's a logic issue with the compare. send me your script and i'll edit it to fix that.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

5 hours ago, Alayne said:

that's a logic issue with the compare. send me your script and i'll edit it to fix that.

this my script

recycle_costume.txt

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

@Alayne any news about this?

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Sorry I'm currently moving, so i don't have any time for scripting ^^'

Gonna look at it as soon as possible, don't worry.

If you want me to point how to fix it, you'll have to:

-modify the class1$, class2$... variable to include a ',' char as really first and really last char of the string (so for instance:
    set .class1$,        ",20054,19584,19634,19882,19605,31087,20341,20355,20354,20351,20352,20353,20356,20350,32109,32110,32111,32112,32113,32114,32115,32116,32117,32118,32119,32100,32101,32102,32103,32104,32105,32106,32107,32108,20241,20234,19506,20120,19521,19507,";)

-modify the compare to include this char. For instance:
        set .@class1, compare(.class1$,","+@sold_nameid[.@i] + ",");

This way, you're gonna look for ",19537,", and not for "19537" anymore. Same thing, you're gonna look for ",537,", so it won't raise for element id that are contained into another (longer) one.

That's not the proper way to handle it, but without modifying the whole script, that's the easiest one ^^.

If you have issues to understand what i meant, tell me.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

On 28/3/2018 at 3:09 PM, Alayne said:

Sorry I'm currently moving, so i don't have any time for scripting ^^'

Gonna look at it as soon as possible, don't worry.

If you want me to point how to fix it, you'll have to:

-modify the class1$, class2$... variable to include a ',' char as really first and really last char of the string (so for instance:
    set .class1$,        ",20054,19584,19634,19882,19605,31087,20341,20355,20354,20351,20352,20353,20356,20350,32109,32110,32111,32112,32113,32114,32115,32116,32117,32118,32119,32100,32101,32102,32103,32104,32105,32106,32107,32108,20241,20234,19506,20120,19521,19507,";)

-modify the compare to include this char. For instance:
        set .@class1, compare(.class1$,","+@sold_nameid[.@i] + ",");

This way, you're gonna look for ",19537,", and not for "19537" anymore. Same thing, you're gonna look for ",537,", so it won't raise for element id that are contained into another (longer) one.

That's not the proper way to handle it, but without modifying the whole script, that's the easiest one ^^.

If you have issues to understand what i meant, tell me.

hi, @alayne i try your method but it's make all item can be trade into points
 

This is my script On Sell
 

OnSellItem:
	mes "Costume to sell:";
	mes "-----------------------------------";
	for(set .@i,0; .@i<getarraysize(@sold_nameid); set .@i,.@i+1)
	{
		set .@class1, compare(.class1$,","+@sold_nameid[.@i] + ",");
		set .@class2, compare(.class1$,","+@sold_nameid[.@i] + ",");
		set .@class3, compare(.class1$,","+@sold_nameid[.@i] + ",");
		set .@class4, compare(.class1$,","+@sold_nameid[.@i] + ",");
		mes ((.@class2 || .@class3 || .@class4)?"  ^FF0000":"  ^777777")+@sold_quantity[.@i]+"x "+getitemname(@sold_nameid[.@i])+"^000000";
		.@class = -1;
		if(.@class2) { .@class=1; }
		else if(.@class3) { .@class=2; }
		else if(.@class4) { .@class=3; }
		else if(.@class1) { .@class=0; }
		if(.@class != -1)
		{
			set .@costume_total, .@costume_total+ ( @sold_quantity[.@i]* .Points[.@class] );
			set .@costume_id[getarraysize(.@costume_id)], @sold_nameid[.@i];
			set .@costume_amt[getarraysize(.@costume_amt)], @sold_quantity[.@i];
		}		
	}
	deletearray @sold_nameid[0], getarraysize(@sold_nameid);
	deletearray @sold_quantity[0], getarraysize(@sold_quantity);
	if (!.@costume_id) {
		mes "-----------------------------------";
		mes "  ^FF0000This item is not included in the category^000000";
		emotion ET_SWEAT;
		close;
	}
	mes " ";
	mes "---------- Total: ^0055FF"+.@costume_total+" pt.^000000 -------";
	next;
	if(select(" > ^0055FFComplete trade...^000000: > ^777777Cancel^000000") == 2) {
		mes "[Costume Trader]";
		mes "Oh, okay...";
		emotion ET_SCRATCH;
		close;
	}
	for(set .@i,0; .@i<getarraysize(.@costume_id); set .@i,.@i+1)
		delitem .@costume_id[.@i],.@costume_amt[.@i];
	setd .Points$, getd(.Points$)+.@costume_total;
	mes "[Costume Trader]";
	mes "All done!";
	emotion ET_DELIGHT;
	close;

And my list item:

	set .class1$,	//Class 1
		",20054,19584,19634,19882,19605,31087,20341,20355,20354,20351,20352,20353,20356,20350,32109,32110,32111,32112,32113,32114,32115,32116,32117,32118,32119,32100,32101,32102,32103,32104,32105,32106,32107,32108,20241,20234,19506,20120,19521,19507,";

	set .class2$,	// Class 2 
		",20405,20239,19606,20259,20193,20150,20279,20043,19992,19952,20030,20264,20459,20147,20215,31096,19746,19853,19158,20270,20298,19826,19973,20452,19971,20212,19557,20466,31092,19876,19974,19800,20232,19565,32120,";		
	set .class3$,	// Class 3
		",20201,20034,20071,31055,20407,31093,20132,20416,20418,20419,20420,20421,20422,20423,20424,32121,19509,20318,20131,20399,20314,19934,18539,18600,19560,19991,19718,20402,20247,20199,20214,19745,20197,20068,20025,20232,19575,20117,20177,20177,19537,19587,5466,";		
	set .class4$,	// Class 4
		",20509,20502,20746,20761,20798,20440,20448,20727,20500,20404,20255,20430,20221,20312,20499,19976,19824,19936,19780,19968,20398,20432,";
	

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  342
  • Reputation:   169
  • Joined:  02/25/12
  • Last Seen:  

Okay gonna debug it myself as soon as possible.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

1 minute ago, Alayne said:

Okay gonna debug it myself as soon as possible.

okay thanks you :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

@Alayne any news about this bro?

 

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