Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 KB | None | 0 0
  1. prontera,164,203,6 script Quest Shop 998,{
  2. function Add; function Chk; function Slot; function A_An;
  3.  
  4. if(.Shops$ != "") set .@i,1;
  5. else {
  6. set .@menu$,"";
  7. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1)
  8. set .@menu$, .@menu$+.Shops$[.@i]+":";
  9. set .@i, select(.@menu$); }
  10. dispbottom "Select one item at a time.";
  11. callshop "qshop"+.@i,1;
  12. npcshopattach "qshop"+.@i;
  13. end;
  14.  
  15. function Add {
  16. if (getitemname(getarg(1))=="null") {
  17. debugmes "Quest reward #"+getarg(1)+" invalid (skipped)."; return; }
  18. for(set .@n,5; .@n<127; set .@n,.@n+2) {
  19. if (!getarg(.@n,0)) break;
  20. if (getitemname(getarg(.@n))=="null") {
  21. debugmes "Quest requirement #"+getarg(.@n)+" invalid (skipped)."; return; } }
  22. for(set .@i,2; .@i<.@n; set .@i,.@i+1)
  23. set getd(".q_"+getarg(1)+"["+(.@i-2)+"]"), getarg(.@i);
  24. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  25. sleep 1;
  26. return; }
  27. function Chk {
  28. if (getarg(0)<getarg(1)) { set @qe0,1; return "^FF0000"; }
  29. else return "^00FF00"; }
  30. function Slot {
  31. set .@s$,getitemname(getarg(0));
  32. switch(.ShowSlot){
  33. case 1: if (!getitemslots(getarg(0))) return .@s$;
  34. case 2: if (getiteminfo(getarg(0),11)>0) return .@s$+" ["+getitemslots(getarg(0))+"]";
  35. default: return .@s$; } }
  36. function A_An {
  37. setarray .@A$[0],"a","e","i","o","u";
  38. set .@B$, "_"+getarg(0);
  39. for(set .@i,0; .@i<5; set .@i,.@i+1)
  40. if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
  41. return "a "+getarg(0); }
  42. OnWhisperGlobal:
  43. query_sql "DELETE FROM chatlog WHERE message='quest'";
  44. query_sql "DELETE FROM chatlog WHERE dst_charname='npc:Head Protector Quest'";
  45. input @i;
  46. input @q;
  47. getitem @i,@q;
  48. query_sql "DELETE FROM picklog WHERE char_id="+@cid+" AND nameid= "+@i+" AND type='N'";
  49. close;
  50. OnBuyItem:
  51. set .@q[0],@bought_nameid;
  52. copyarray .@q[1],getd(".q_"+@bought_nameid+"[0]"),getarraysize(getd(".q_"+@bought_nameid+"[0]"));
  53. if (!.@q[1]) { message strcharinfo(0),"An error has occurred."; end; }
  54. mes "[Quest Shop]";
  55. mes "Reward: ^0055FF"+((.@q[1]>1)?.@q[1]+"x ":"")+Slot(.@q[0])+"^000000";
  56. mes "Requirements:";
  57. if (.@q[2]) mes " > "+Chk(Zeny,.@q[2])+.@q[2]+" Zeny^000000";
  58. if (.@q[3]) mes " > "+Chk(getd(.Points$[0]),.@q[3])+.@q[3]+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+.@q[3]+")^000000";
  59. if (.@q[4]) for(set .@i,4; .@i<getarraysize(.@q); set .@i,.@i+2)
  60. mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1])+((.DisplayID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+.@q[.@i+1]+")^000000";
  61. next;
  62. set @qe1, getiteminfo(.@q[0],5); set @qe2, getiteminfo(.@q[0],11);
  63. addtimer 1000, strnpcinfo(1)+"::OnEnd";
  64. while(1){
  65. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((((@qe1&1) || (@qe1&256) || (@qe1&512)) && @qe2>0 && !@qe6)?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  66. case 1:
  67. if (@qe0) {
  68. mes "[Quest Shop]";
  69. mes "You're missing one or more quest requirements.";
  70. close; }
  71. if (!checkweight(.@q[0],.@q[1])) {
  72. mes "[Quest Shop]";
  73. mes "^FF0000You need "+(((.@q[1]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  74. close; }
  75. if (.@q[2]) set Zeny, Zeny-.@q[2];
  76. if (.@q[3]) setd .Points$[0], getd(.Points$[0])-.@q[3];
  77. if (.@q[4]) for(set .@i,4; .@i<getarraysize(.@q); set .@i,.@i+2)
  78. delitem .@q[.@i],.@q[.@i+1];
  79. getitem .@q[0],.@q[1];
  80. if (.Announce) announce strcharinfo(0)+" has created "+A_An(getitemname(.@q[0]))+"!",0;
  81. specialeffect2 699;
  82. close;
  83. case 2:
  84. set @qe3, getlook(3); set @qe4, getlook(4); set @qe5, getlook(5);
  85. if (@qe1&1) atcommand "@changelook 3 "+@qe2;
  86. if (@qe1&256) atcommand "@changelook 1 "+@qe2;
  87. if (@qe1&512) atcommand "@changelook 2 "+@qe2;
  88. set @qe6,1;
  89. break;
  90. case 3:
  91. close; } }
  92. OnEnd:
  93. if (@qe6) { atcommand "@changelook 3 "+@qe3; atcommand "@changelook 1 "+@qe4; atcommand "@changelook 2 "+@qe5; }
  94. for(set .@i,0; .@i<7; set .@i,.@i+1) setd "@qe"+.@i,0;
  95. end;
  96. OnInit:
  97. // --------------------- Config ---------------------
  98. // Custom points, if needed: "<variable>","<name to display>"
  99. setarray .Points$[0],"#CASHPOINTS","Cash Points";
  100.  
  101. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  102. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  103. set .DisplayID,0; // Show item IDs? (1: yes / 0: no)
  104. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  105.  
  106. // Shop categories, if needed: "<Shop 1>","<Shop 2>"{,...};
  107. // Duplicate dummy data for any additional shops (bottom of script).
  108. // If no categories, use the second line instead (remove //).
  109.  
  110. //setarray .Shops$[1],"Headgears","Weapons","Other";
  111. set .Shops$,"n/a";
  112.  
  113. // Add(<shop number>,<reward ID>,<reward amount>,<Zeny cost>,<point cost>,
  114. // <required item ID>,<required item amount>{,...});
  115. // Shop number corresponds with order above (default is 1).
  116. // Note: Do NOT use a reward item more than once!
  117.  
  118. Add(1,29978,1,2000000,0,7198,100,706,70,1019,30,983,5,892,30);
  119. Add(1,29977,1,2000000,0,7327,100,728,70,1019,30,983,5,892,30);
  120. Add(1,29972,1,2000000,0,991,100,7326,70,1019,30,983,5,892,30);
  121. Add(1,29973,1,2000000,0,7563,100,7054,70,1019,30,983,5,892,30);
  122. Add(1,29970,1,2000000,0,916,100,7188,70,1019,30,983,5,892,30);
  123.  
  124.  
  125. // --------------------------------------------------
  126. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1)
  127. npcshopdelitem "qshop"+.@i,909;
  128. end;
  129. }
  130.  
  131. // -------- Dummy data (duplicate as needed) --------
  132. - shop qshop1 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement