Jump to content
  • 0

Refund Script


vBrenth

Question


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

I'm need this script, so if anyone can make/help me please?

I have 100+ custom items in my server that i want to delete(exchange) it to different amount of tickets..

Example:

I have 3 items 501,502,503 and i want them to exchange with different amount of tickets, i need shorter script, and if the item has a card inside the NPC will denied it...

Thanks...

Link to comment
Share on other sites

20 answers to this question

Recommended Posts


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

are you looking for something work like this ??

Player able to Exchange any 4 type of their Points into a Ticket which cost 100 Point Accordingly ???

try this one :

prontera,155,181,5 script Sample 718,{
function PointExchange;

mes "Which Point you would like to use it to exchange into ticket ?";
next;
switch( select( "Custom Point 1",
"Custom Point 2",
"Custom Point 3",
"Custom Point 4" )){

Case 1: PointExchange( CustomPoint1,100,7539 );
Case 2: PointExchange( CustomPoint2,100,7539 );
Case 3: PointExchange( CustomPoint3,100,7539 );
Case 4: PointExchange( CustomPoint4,100,7539 );
default: break;
}
close;


PointExchange:
if( getarg(0) < getarg(1) ){
mes "Sorry you required "+getarg(1)+" Points to exchange into 1 "+getitemname(getarg(2))+" .";
}else{
mes "You have "+getarg(0)+" Points total now.";
mes "Are you sure want to change "+getarg(1)+" Points to change into 1 "+getitemname(getarg(2))+" ?";
next;
if ( select("NO:YES") == 1 ) close;
set getarg(0), getarg(0) - getarg(1);
mes "Gained 1 "+getitemname(getarg(2))+" by exchanged 100 Points of yours Points.";
getitem getarg(2),1;
}
close;
}

Setting :

PointExchange( <PointVariable> , <Cost> , <Item Gain> );

Example : use any 100 Points of each type to exhange into 1 Poring Coin

Case 1: PointExchange( CustomPoint1,100,7539 );
Case 2: PointExchange( CustomPoint2,100,7539 );
Case 3: PointExchange( CustomPoint3,100,7539 );
Case 4: PointExchange( CustomPoint4,100,7539 );

Script are not tested yet ~

if it doesnt work..please explain in detail..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  56
  • Reputation:   8
  • Joined:  11/10/11
  • Last Seen:  

I think you should make a NPC for it like a quest or something?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

If you could explain yourself better with the 'exchange' thing I can help.

Edited by Noah
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Here's what I have understood from it...

You have 100+ different items... could be 100 could be 200 you don't know (so I've already determined this will need a setd / getd setup to use multiple "array lists"

From there, you need to tell the npc you want to sell an item or item(s), each item id will have a different corresponding ticket value (aka another setd / getd array to match each list)

I assume, since he wants to know about cards... you will need to use a NPC SELL SCRIPT to determine if the item does in fact have cards, if it does, skip over item and return back to user...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Exactly Z3R0.... very well said...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  243
  • Reputation:   206
  • Joined:  11/28/11
  • Last Seen:  

Alternate Method:

If your custom items are not normally found in a (regular/zeny) shop, you could edit the "Buy Price" or "Sell Price" in your item database. The value in that column would correspond to the item's ticket value. To read the value you can use getiteminfo (documentation below). This would make your script less complicated but may get confusing when viewing your item DB. If you are interested in this method and would like further explanation, let me know =)

*getiteminfo(<item ID>,<type>)

This function will look up the item with the specified ID number in the database

and return the info set by TYPE argument.

It will return -1 if there is no such item.

Valid types are:

0 - Buy Price; 1 - Sell Price; 2 - Item Type;

3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..

if = 0, then monsters don't drop it at all (rare or a quest item)

if = 10000, then this item is sold in NPC shops only

4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;

10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id

Check sample in npssamplegetiteminfo.txt

Or.. A similar method described above is to make a custom column (or a use of a delimiter) in the item database itself for a ticket value price. (ie. Item ID#, ..., NPC Sell, NPC Buy, Ticket Price, Item Type, ..., ViewID, Item Script) However, this would need a source modification.

EDIT:

I realized that this thread is in the Script Request sub forum so I quickly created the code for my method (and quickly tested it in-game) :

//20000,Ticket_Item,Ticket Item,3,,,0,,,,,0xFFFFFFFF,7,2,,,,,,{},{},{}
//20001,Custom_Item,Custom Item,3,[b]20[/b],,0,,,,,0xFFFFFFFF,7,2,,,,,,{},{},{}
//The bold-faced number 20 is the number of tickets a player can get if they exchange the item whose id is 20001
prontera,100,100,1 script Exchange for Tickets 46,{
mes "Input Item ID# that you want to exchange for tickets.";
mes "Make sure it is in your inventory and have no slotted cards!";
next;
input .@iid;
// range of valid custom items that can be exchanged for tickets
if(.@iid >= 20001 && .@iid <= 25000) {
 // make sure they have one of this item so that it doesnt delete the wrong one?
 if(countitem(.@iid) == 1) {
  getinventorylist;
  // for loop to check if item to be deleted has cards in it
  for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1) {
// item found in inventory
if(@inventorylist_id[.@i] == .@iid) {
 // item has a card in it
 if(@inventorylist_card1[.@i] || @inventorylist_card2[.@i] || @inventorylist_card3[.@i] || @inventorylist_card4[.@i])
  mes "There is a card in that item!";
 // item doesnt have a card - give tickets and delete item
 else {
  delitem .@iid,1;
  getitem 20000, getiteminfo(.@iid,0);
  mes "Done!";
 }
 close;
}
  }
 }
 // error message if item is not a custom item that can be exchanged
 else
  mes "Invalid item. This item cannot be exchanged into tickets.";
}
// error message if item input not found in inventory
else
 mes "You do not have that item or have more than one in your inventory!";
close;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Here you go, try this: refund.txt

Configure the list of items they can return at the bottom in the OnInit section (there is no limit to how many items you can list):

	// set .<item_id>, <amount of="" tickets="" to="" refund="">;
set .501, 3;
set .502, 4;
set .503, 15;

also set the item_id of your refund Ticket there:

	set .refund_id, 617; // Item ID of "Ticket" that they will be refunded

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Brian i'm using your script but when i click Exchange All and i have 3 items it will only exchange 2 pcs of my items and then.. if i have 2 same items the npc says "where did my item go"

Edited by vBrenth
Link to comment
Share on other sites


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

1) When .@i equal "0" the array size isn't increment (so it erase this value after).

- set .@exchange[getarraysize(.@exchange)], .@i;
+  set .@exchange[getarraysize(.@exchange)], .@i+1;

- set .@count, .@count + doRefund(.@exchange[.@i]);
+ set .@count, .@count + doRefund(.@exchange[.@i]-1);

2)Equipment aren't stackable but are cumulate with countitem2... ( use < instead of != )

-	if (countitem2(@inventorylist_id[.@i],@inventorylist_identify[.@i],@inventorylist_refine[.@i],@inventorylist_attribute[.@i], 0,0,0,0) != .@amt) {
+	if (countitem2(@inventorylist_id[.@i],@inventorylist_identify[.@i],@inventorylist_refine[.@i],@inventorylist_attribute[.@i], 0,0,0,0) < .@amt) {

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Thanks keyworld your really really really good ;) thanks my problem solved now.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Thanks KeyWorld!

Sorry Brenth, I wrote it but couldn't test it because no RO on that computer last night.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Well that's fine ^^, atleast you write almost 95% of the script and BTW thanks to everyone

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

// http://rathena.org/board/topic/53748-refund-script/

artzan,111,109,3    script    Refund NPC    911,{
   function doRefund;
   mes "[Refund NPC]";
   getinventorylist;

   // build menu list of items
   for (set .@i,0; .@i < @inventorylist_count; set .@i, .@i +1) {
       // check if item can be returned
       if (getd("."+@inventorylist_id[.@i]) &&
          !(@inventorylist_card1[.@i] || @inventorylist_card2[.@i] || @inventorylist_card3[.@i] || @inventorylist_card4[.@i])) {
           // add to menu
           set .@menu$, .@menu$ + getitemname(@inventorylist_id[.@i]) + " - "
          					  + getd("."+@inventorylist_id[.@i]) + " Tickets";
           // add .@i to arraylist in case they pick "Exchange ALL"
           set .@exchange[getarraysize(.@exchange)], .@i+1;
       }
       set .@menu$, .@menu$ + ":";
   }
   if (getstrlen(.@menu$) == @inventorylist_count) {
       mes "Sorry, there are no refunds for any of your items.";
       close;
   }

   // pick an item, or pick ALL
   select(.@menu$ + "Exchange ALL");
   if (@menu == (@inventorylist_count +1)) {
       // ALL
       for (set .@i,0; .@i<getarraysize(.@exchange); set .@i,.@i+1)
           set .@count, .@count + doRefund(.@exchange[.@i]-1);
   } else {
       // they picked 1 specific item
       set .@count, doRefund(@menu -1);
   }
   if (.@count) mes "Here are your "+.@count+" "+getitemname(.refund_id)+".";
   mes "Thank you, come again!";
   close;

function doRefund {
   set .@i, getarg(0); // index
   set .@amt, @inventorylist_amount[.@i];
   set .@price, getd("."+@inventorylist_id[.@i]);

   if (countitem2(@inventorylist_id[.@i],@inventorylist_identify[.@i],@inventorylist_refine[.@i],@inventorylist_attribute[.@i], 0,0,0,0) < .@amt) {
       mes "^FF0000Where did your "+( (.@amt==1) ? "item" : "items" )+" go?!";
       emotion e_omg;
       close;
   } else if (!checkweight(.refund_id, .@price*.@amt)) {
       mes "^FF0000You are overweight or have too many items in your inventory.";
       emotion e_swt;
       close;
   }
   delitem2 @inventorylist_id[.@i],.@amt, @inventorylist_identify[.@i],@inventorylist_refine[.@i],@inventorylist_attribute[.@i], 0,0,0,0;
   getitem .refund_id, .@price*.@amt;
   dispbottom "Refund NPC: Returned "+.@amt+" "+getitemname(@inventorylist_id[.@i])+" for "+.@price+" Tickets";
   return (.@price*.@amt);
}

OnInit:
   set .refund_id, 20908; // Item ID of "Ticket" that they will be refunded

   // set .<item_id>, <amount of tickets to refund>;
   set .30710, 5;
   set .30711, 5;
   set .30712, 5;
   set .30713, 5;
   set .30714, 5;
   set .30715, 5;
   set .30716, 5;
   set .30717, 5;
   set .30718, 5;
   // etc.
   end;
}


This is my current script that working well, i want to request that if the item is +10/additional 3 tickets.. thanks.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Find this line:

set .@price, getd("."+@inventorylist_id[.@i]);

and add a line after:

set .@price, getd("."+@inventorylist_id[.@i]);
if (@inventorylist_refine[.@i] == 10) set .@price, .@price +3;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Thanks Brian and i have another request..instead of making new thread i will post it here.....

I use 4 kinds of points system like... pkpoints/tokenpoints/artzanpoints/etc... and i want an NPC that you can exchange your different points.. to Tickets exchange rate is 100 points to 1 ticket.....

Thankies

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

1 Day bump =,= sorry but i really need this, thanks in advance..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

set getarg(0), getarg(0) - getarg(1);

I don't think that line will work because you passed the value of the variable to the function.

Other than that, Emistry's script looks good!

In case it doesn't work, here's another way:

// http://rathena.org/board/topic/53748-refund-script/page__view__findpost__p__57271

prontera,155,188,0	script	Points Exchanger	910,{
mes "[Points Exchanger]";
mes "Which points would you like to exchange?";
switch(select("PK Points:Token Points:Artzan Points")) {
case 1:    callsub S_ExchangePoints,"pkpoints";      break;
case 2:    callsub S_ExchangePoints,"tokenpoints";   break;
case 3:    callsub S_ExchangePoints,"artzanpoints";  break;
}
close;

S_ExchangePoints:
set .ticket_id, 20908; // Ticket
set .exchange_rate, 100; // How many points equals 1 Ticket?
set .@points, getd(getarg(0));
set .@tickets, .@points / .exchange_rate;

if (.@tickets < 1) {
	mes "Sorry you only have " + .@points + " " + getarg(0);
	mes "You need " + .exchange_rate + " to exchange for 1 "+getitemname(.ticket_id);
	return;
}
mes .@points + " " + getarg(0);
mes "--> " + .@tickets + " " + getitemname(.ticket_id) + "?";
if (select("No:Yes, exchange points!") == 1) {
	;
} else if (getd(getarg(0)) < (.@tickets * .exchange_rate)) {
	mes "^FF0000 Where did your points go?";
	emotion e_omg;
} else if (!checkweight(.ticket_id, .@tickets)) {
	mes "^FF0000 You are overweight or have too many items in your inventory.";
	emotion e_swt;
} else {
	setd getarg(0), getd(getarg(0)) - (.@tickets * .exchange_rate);
	getitem .ticket_id, .@tickets;
	mes "Here are your "+.@tickets+" "+getitemname(.ticket_id);
}
return;
}

Link to comment
Share on other sites


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

Previous Message ~

I don't think that line will work because you passed the value of the variable to the function.

Aww...Sorry for that ~ i though it might work ~

because last time...when it come to #CASHPOINTS / #KAFRAPOINTS

there is one time i remember i using callsub to pass the value into the script like that ~

afterward using these getarg command to get the value ~

and that time seem to work for me xD


Deng !!! =='' i didnt saw the spoiler there was another fixed script xD

haha ( and yeah...that is what i was trying to do ~ )

seem like i was forget to use double quote mark to pass the value ~

Other than that, Emistry's script looks good!

Yay.....damn happy to hear this from Brian.. : 3


Updated Message :

The script did actually work ~ i have tested xD

Case 1: PointExchange( CustomPoint1 , 100 , 7539 );

this part did actually pass the value of CustomPoint1 into the script xD

Sample Script i used to Check this :

Added 2 Extra Features : Add Point and Check Point

( this script just for test use.. )

prontera,155,181,5 script Sample 718,{
function PointExchange;

mes "Which Point you would like to use it to exchange into ticket ?";
next;
switch( select( "Custom Point 1",
"Custom Point 2",
"Custom Point 3",
"Custom Point 4",
"Check Point" )){

Case 1: PointExchange( CustomPoint1,100,7539 );
Case 2: PointExchange( CustomPoint2,100,7539 );
Case 3: PointExchange( CustomPoint3,100,7539 );
Case 4: PointExchange( CustomPoint4,100,7539 );
Case 5:
mes "You updated point : ";
mes "CustomPoint1 = "+CustomPoint1;
mes "CustomPoint2 = "+CustomPoint2;
mes "CustomPoint3 = "+CustomPoint3;
mes "CustomPoint4 = "+CustomPoint4;
close;

default: break;
}
close;


PointExchange:
if( getarg(0) < getarg(1) ){
mes "Sorry you required "+getarg(1)+" Points to exchange into 1 "+getitemname(getarg(2))+" .";
}else{
mes "You have "+getarg(0)+" Points total now.";
mes "Are you sure want to change "+getarg(1)+" Points to change into 1 "+getitemname(getarg(2))+" ?";
next;
if ( select("NO:YES") == 1 ) close;
set getarg(0), getarg(0) - getarg(1);
mes "Gained 1 "+getitemname(getarg(2))+" by exchanged 100 Points of yours Points.";
getitem getarg(2),1;
}
close;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

Can I have a pastebin link for this? XD

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  311
  • Reputation:   46
  • Joined:  11/06/11
  • Last Seen:  

Lol why ? you can copy paste it anytime you want =,="

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