Jump to content
  • 0

OnBuyItem. Deletes item by boughtprice.


Currently

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  313
  • Reputation:   1
  • Joined:  01/22/12
  • Last Seen:  

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
Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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;
}
}

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