Advertisement
kolton

Untitled

Dec 24th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. Unit.prototype.sell = function () {
  2. if (this.type !== 4) { // Check if it's an item we want to buy
  3. throw new Error("sell: Must be used on items.");
  4. }
  5.  
  6. if (!getUIFlag(0xC)) { // Check if it's an item belonging to a NPC
  7. throw new Error("sell: Must be used in a show window.");
  8. }
  9.  
  10. var i, tick,
  11. sold = false;
  12.  
  13. function ItemAction(gid, mode, code, global) {
  14. if (mode === 101) {
  15. sold = true;
  16. }
  17. }
  18.  
  19. addEventListener("itemaction", ItemAction);
  20.  
  21. for (i = 0; i < 3; i += 1) {
  22. this.shop(1);
  23.  
  24. tick = getTickCount();
  25.  
  26. while (getTickCount() - tick < 1000) {
  27. if (sold) {
  28. break;
  29. }
  30.  
  31. delay(10);
  32. }
  33. }
  34.  
  35. removeEventListener("itemaction", ItemAction);
  36.  
  37. return sold;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement