Jump to content
  • 0

OnBuyItem. Deletes item by boughtprice.


Question

Posted (edited)

OnBuyItem:

set @currentprice,0;

for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){

set @currentprice,@currentprice + (getiteminfo(@bought_nameid[@i],0) * @bought_quantity[@i]);

}

if(countitem(12618) < @bought_quantity*@currentprice) { //It doesn't read. Not enough 12618 but script still buys.

mes @npc$;

mes "You do not have enough Misc Points.";

close;

}

delitem 12618,-@bought_quantity*@currentprice; //doesn't work?

//Let's give them those items!

for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){

getitem @bought_nameid[@i],@bought_quantity[@i];

}

mes @npc$;

mes "That's that, then! Come again!";

deletearray @bought_quantity, getarraysize(@bought_quantity);

deletearray @bought_nameid, getarraysize(@bought_nameid);

close;

}

}

Edited by Dreamworks

1 answer to this question

Recommended Posts

Posted

What if:

OnBuyItem:
set @currentprice,0;
for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1) {
set @currentprice,@currentprice + (getiteminfo(@bought_nameid[@i],0) * @bought_quantity[@i]);
}
if(countitem(12618) < (@bought_quantity*@currentprice)) {
mes @npc$;
mes "You do not have enough Misc Points.";
close;
}
delitem 12618,(-@bought_quantity*@currentprice);
for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){
getitem @bought_nameid[@i],@bought_quantity[@i];
}
mes @npc$;
mes "That's that, then! Come again!";
deletearray @bought_quantity, getarraysize(@bought_quantity);
deletearray @bought_nameid, getarraysize(@bought_nameid);
close;
}
}

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...