Jump to content
  • 0

Cards for Cash (HELP)


lttrmn

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  3
  • Reputation:   0
  • Joined:  07/09/18
  • Last Seen:  

Good evening,

So... Weeks ago, here in the forums, I found a very useful script of a NPC who can trade itens for cashpoints.

Even knowing nothing about what was happening in this particular script, I did some changes and it is partially functional for my purposes now.

The NPC calls directly for a SELL window, as I wished. The problem now is:

The script seems to have an uncecessary amount of content, which probably causes the player to sell only 2 types of card at a time.

Spoiler

-    shop    exg_exp    -1,501:50.

prontera,161,185,3    script    Card Dealer    10187,{
    callshop "exg_exp",2;
    npcshopattach "exg_exp";
    end;

OnSellItem:
    if( !getarraysize(.@choice$) )
        setarray .@choice$, "@sold_", "sold", "1", "@delitem";
    .@len = getarraysize(getd(.@choice$+"nameid"));
    for ( .@i = 0; .@i < .@len; .@i++ ) {
    
        if( .@choice$[1] == "sold" ) {
            if ( countitem(@sold_nameid[.@i]) < @sold_quantity[.@i] || @sold_quantity[.@i] <= 0 ) {
                mes "Something went wrong!";
                close;
            }
        } else {
            if ( @bought_quantity[.@i] <= 0 ) {
                mes "Something went wrong...";
                close;
            }
        }
        
        for ( .@a = 0; .@a < .len; .@a = .@a + 2 ) {
            if( getd(.@choice$+"nameid["+.@i+"]") == .item_base[.@a] ) {
                if ( #CASHPOINTS < .item_base[.@a+1] * @bought_quantity[.@i]
                &&   .@choice$[1] != "sold" ) {
                    mes "You have insufficient cashpoints.";
                    close;
                }
                atcommand .@choice$[3]+" "+.item_base[.@a]+" "+getd(.@choice$+"quantity["+.@i+"]");
                .@cashpoints = ( getd(.@choice$+"quantity["+.@i+"]") * .item_base[.@a+1] ) * atoi(.@choice$[2]);
                #CASHPOINTS = #CASHPOINTS + .@cashpoints;
                dispbottom getitemname(.item_base[.@a]) +" x"+ getd(.@choice$+"quantity["+.@i+"]") +" "+ .@choice$[1] +" for "+ .@cashpoints +" CASHPOINTS!";
            }
        }
    }
    deletearray getd(.@choice$+"quantity");
    deletearray getd(.@choice$+"nameid");
    mes "Deal completed.";
    close;
    
OnInit:
    setarray .item_base, 4001, 3, 4006, 3, 4002, 3;
    .len = getarraysize(.item_base);
    npcshopdelitem "exg_exp",501;
    for ( .@a = 0; .@a < .len; .@a = .@a + 2 )
        npcshopadditem "exg_exp",.item_base[.@a],.item_base[.@a+1];
}

Weirdly enough, when I try to sell a single card, the NPC displays the message "Deal Completed", but when I sell 2 types of cards, the deal is completed with no message. If I try to sell 3 or more type of cards, only 2 of then are effectively sold.

I need a clean script that fulfills the same function.

Thanks in advance.

Edited by lttrmn
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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