Jump to content
  • 0

Help with this exchanger script, please.


Mistique

Question


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  09/15/12
  • Last Seen:  

Hello everyone! :)

 

I was curious is someone could help me with this script.

 

This is how it works, the items in "setarray .@exc_1" can be traded/exchanged for the items in "setarray .@exc_2".

 

Problem: The script works fine if a item of "setarray .@exc_1" is present in the characters inventory, but if it isn't and someone uses the NPC, the script will bug out at the menu. As in, no "close" button will appear. (The "Cancel" doesn't actually cancel, it sends you to the next menu regardless if a item in the list is present)

 

I've tried several ways to fix it, but it is more difficult than I thought.

 

 

quiz_test,95,84,4    script    Item Trader    797,{
    setarray .@exc_1,8005,8006,8015,8016;    // <- Checks in inventory for these items.
    setarray .@exc_2,8005,8006,8015,8016;    // <- Available items for exchange. Pretty much a copy/paste of the IDs above^
    set .@n$,"[Item Trader]";
 
    mes .@n$;
    mes "Hello! I can exchange headgears, that means if you're bored of your current headgear, I can easily give you another!";
    next;
    mes .@n$;
    mes "This is not a free service though. I require the following:";
    mes "1x Headgear";
    mes "3x Cash Point";
    next;
    mes .@n$;    
    mes "If you want me to do the exchange process for you, please select the Headgear you wish to exchange:";
    while (.@e!=2) {
        set .@e,(!.@e)?"1":"2";
        if (.@e==2) { next; mes .@n$; mes "Please pick your new desired Headgear:";
        mes " ";
        mes "^FF0000(To see a list of existing sprites please check our servers database, accessable through the forums!)"; }
        for (set .@i,0; .@i<getarraysize(getd(".@exc_"+.@e)); set .@i,.@i+1) setd ".@m"+.@e+"$",getd(".@m"+.@e+"$")+""+(((.@e==2||(.@e==1&&countitem(.@exc_1[.@i]))))?getitemname(getd(".@exc_"+.@e+"["+.@i+"]")):"")+":";
        setd ".@m"+.@e,select(getd(".@m"+.@e+"$")+":Cancel")-1;
        if (getd(".@m"+.@e)==getarraysize(getd(".@exc_"+.@e))) close;
        }
    next;
    mes .@n$;
    mes "Are you sure you want to exchange this item?";
    menu "Yes, proceed.",-;    
    mes "Granted, have fun!";
    delitem .@exc_1[.@m1],1;
    getitem .@exc_2[.@m2],1;
    set #CASHPOINTS,#CASHPOINTS - 3;
    dispbottom "3 Cash Points have been deducted. Current Balance = "+#CASHPOINTS+" Cash Points.";
    close;
}
        }
Edited by Mistique
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

I have an additional request for this script, could you help me, Skorm? How do I make it so the item doesn't lose it's refine rates?

 

Right now, if you trade a +10 item, you get a unrefined item in return. I'd like it if the item you receive for it to be also +10. If you (or anyone) could help me here, I'd be very very happy! :D

 

prontera,150,150,0    script    Exchanger    100,{
    mes .npc$;
    mes "Hello " +strcharinfo(0)+ ", I am the exchanger on this server. Do you have something to exchange?";
    next;
    if(select("Yes:No") - 1) close;
    mes .npc$;
    mes "You are charge to spend " +.req_zeny+ " zeny for using my service. Still want to use my service?";
    next;

    if (select("Yes:No") - 1) close;
    if (Zeny < .req_zeny) {
        mes .npc$;
        mes "You do not have enough zeny for you to use my service";
        close;
    }

    mes .npc$;
    mes "Good then, What item you want to exchange?";
    next;
    getinventorylist;
    for (.@i = 0; .@i < @inventorylist_count; .@i++) {
                if (compare(.itemidcompare$, ":"+ @inventorylist_id[.@i] +":" ) ) {
                        .@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) +":";
                        .@select[ .@c ] = @inventorylist_id[.@i];
                        .@c++;
                }
        }

    if (.@c == 0) {
        mes .npc$;
        mes "You have no items to exchange";
        close;
    }
    
    .@pickid = .@select[select(.@menu$) - 1];
    mes .npc$;
    mes "You want to exchange " +getitemname(.@pickid)+ " right?";
    next;
    if (select("Yes:No") - 1) close;
    mes .npc$;
    mes "Where do you want to exchange your " +getitemname(.@pickid)+ "?";
    next;
    .@menu$ = getitemname(.itemid);
    for (.@i = 1; .@i < .itemidsize; .@i++) 
        .@menu$ = .@menu$ + ":" + getitemname(.itemid[.@i]);
        .@tradeid = .itemid[select( .@menu$ ) -1];
        mes .npc$;
        mes "Are you sure you want to spend " +.req_zeny+ " zeny for trading " +getitemname(.@pickid) + " into " + getitemname(.@tradeid)+ "?";
        next;
        if (select("Yes:No") - 1) close;
        if (countitem(.@pickid) == 0 || Zeny < .req_zeny) {
            mes .npc$;
            mes "You do not meet the requirements";
            close;
        }

    getinventorylist;
        for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){
            if( @inventorylist_id[.@i] == .@pickid ) {
                set .@refine_rate, @inventorylist_refine[.@i];
            }
        }

        delitem .@pickid, 1;
    
    if ( !.@refine_rate ) 
        getitem .@tradeid, 1;
    else 
        getitem2 .@tradeid,1,1,.@refine_rate,0,@card1,@card2,@card3,@card4;
   
        set Zeny,Zeny - .req_zeny;
        mes .npc$;
        mes "===================================";
        mes "Official Receipt";
        mes "===================================";
        mes "From : " +getitemname(.@pickid);
        mes "To : " +getitemname(.@tradeid);
        mes "===================================";
        next;
        mes .npc$;
        mes "Thank you for using our trading system " +strcharinfo(0)+ ". Have a nice day";
        close;




    OnInit:
            set .npc$,"^FF0000" +strnpcinfo(1)+ "^000000"; // NPC Name
            .req_zeny = 0; // Zeny to use the service.
            setarray .itemid, 1618, 1604; // Put all id here


            set .itemidsize, getarraysize( .itemid );
            set .itemidcompare$, ":"+ .itemid[0];
            for ( .@i = 1; .@i < .itemidsize; .@i++ )
                    .itemidcompare$ = .itemidcompare$ +":"+ .itemid[.@i] +":";
            end;
}

Try this one. Didn't test though :D and BTW i am not @Skorm i am @Patskie

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

You can try this one. By default it uses Zeny before you can exchange.

prontera,150,150,0    script    Exchanger    100,{
    mes .npc$;
    mes "Hello " +strcharinfo(0)+ ", I am the exchanger on this server. Do you have something to exchange?";
    next;
    if(select("Yes:No") - 1) close;
    mes .npc$;
    mes "You are charge to spend " +.req_zeny+ " zeny for using my service. Still want to use my service?";
    next;


    if (select("Yes:No") - 1) close;
    if (Zeny < .req_zeny) {
        mes .npc$;
        mes "You do not have enough zeny for you to use my service";
        close;
    }


    mes .npc$;
    mes "Good then, What item you want to exchange?";
    next;
    getinventorylist;
    for (.@i = 0; .@i < @inventorylist_count; .@i++) {
                if (compare(.itemidcompare$, ":"+ @inventorylist_id[.@i] +":" ) ) {
                        .@menu$ = .@menu$ + getitemname( @inventorylist_id[.@i] ) +":";
                        .@select[ .@c ] = @inventorylist_id[.@i];
                        .@c++;
                }
        }


    if (.@c == 0) {
        mes .npc$;
        mes "You have no items to exchange";
        close;
    }
    
    .@pickid = .@select[select(.@menu$) - 1];
    mes .npc$;
    mes "You want to exchange " +getitemname(.@pickid)+ " right?";
    next;
    if (select("Yes:No") - 1) close;
    mes .npc$;
    mes "Where do you want to exchange your " +getitemname(.@pickid)+ "?";
    next;
    .@menu$ = getitemname(.itemid);
    for (.@i = 1; .@i < .itemidsize; .@i++) 
        .@menu$ = .@menu$ + ":" + getitemname(.itemid[.@i]);
        .@tradeid = .itemid[select( .@menu$ ) -1];
        mes .npc$;
        mes "Are you sure you want to spend " +.req_zeny+ " zeny for trading " +getitemname(.@pickid) + " into " + getitemname(.@tradeid)+ "?";
        next;
        if (select("Yes:No") - 1) close;
        if (countitem(.@pickid) == 0 || Zeny < .req_zeny) {
            mes .npc$;
            mes "You do not meet the requirements";
            close;
        }
        delitem .@pickid, 1;
        getitem .@tradeid, 1;
        set Zeny,Zeny - .req_zeny;
        mes .npc$;
        mes "===================================";
        mes "Official Receipt";
        mes "===================================";
        mes "From : " +getitemname(.@pickid);
        mes "To : " +getitemname(.@tradeid);
        mes "===================================";
        next;
        mes .npc$;
        mes "Thank you for using our trading system " +strcharinfo(0)+ ". Have a nice day";
        close;


    OnInit:
            set .npc$,"^FF0000" +strnpcinfo(1)+ "^000000"; // NPC Name
            .req_zeny = 10000; // Zeny to use the service.
            setarray .itemid, 8005, 8006, 8015, 8016, 607, 608; // Put all id here

            set .itemidsize, getarraysize( .itemid );
            set .itemidcompare$, ":"+ .itemid[0];
            for ( .@i = 1; .@i < .itemidsize; .@i++ )
                    .itemidcompare$ = .itemidcompare$ +":"+ .itemid[.@i] +":";
            end;
}
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  09/15/12
  • Last Seen:  

I'll try that, thank you. :)

 

Works like a charm!

Edited by Mistique
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  09/15/12
  • Last Seen:  

I have an additional request for this script, could you help me, Skorm? How do I make it so the item doesn't lose it's refine rates?

 

Right now, if you trade a +10 item, you get a unrefined item in return. I'd like it if the item you receive for it to be also +10. If you (or anyone) could help me here, I'd be very very happy! :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  09/15/12
  • Last Seen:  

Wow my bad! How did I mess that up... I'm sorry!

 

Works perfect, thanks Patskie!

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