2007-06-30

responseOnMatrixNumber v1.0.2a

  1. ###########################
  2. # responseOnMatrixNumber v1.0.2a
  3. #
  4. # For OpenKore 1.9.x
  5. #
  6. # (test in Creamsoda server >> http://creamsoda.i.am) 23/6/250
  7. #
  8. # NOTE: This plugin meant to be use with hakore's reactOnNPC
  9. package responseOnMatrixNumber;
  10. use strict;
  11. use Plugins;
  12. use Utils;
  13. use Globals qw(%talk);
  14. use Commands qw(run register unregister);
  15. use Log qw(message debug);
  16. use I18N qw(bytesToString);
  17. my %reactOnNPC;
  18. my @actOnNPC;
  19. my $num1;
  20. my $num2;
  21. my $num3;
  22. my $all_line;
  23. my $line;
  24. my $matrix;
  25. my @array;
  26. my @NPCresponses;
  27. Plugins::register('responseOnMatrixNumber', "response On MatrixNumber", \&Unload);
  28. my $cmd = Commands::register(['MatrixNumber', 'talk response On MatrixNumber', \&onMatrixCmd]);
  29. my $hooks = Plugins::addHooks(
  30. ['packet/npc_talk', \&onNPCTalk],
  31. ['packet/npc_talk_close', \&onClose]
  32. );
  33. sub onUnload {
  34. Plugins::delHooks($hooks);
  35. Commands::unregister($cmd);
  36. undef %reactOnNPC;
  37. undef @actOnNPC;
  38. undef $num1;
  39. undef $num2;
  40. undef $num3;
  41. undef $all_line;
  42. undef $line;
  43. undef $matrix;
  44. undef @array;
  45. undef @NPCresponses;
  46. }
  47. sub onClose {
  48. undef %reactOnNPC if defined %reactOnNPC;
  49. }
  50. sub onNPCTalk {
  51. my (undef, $args) = @_;
  52. my $msg = I18N::bytesToString(unpack("Z*", substr($args->{RAW_MSG}, 8)));
  53. if (!defined %reactOnNPC || $reactOnNPC{action}) {
  54. undef %reactOnNPC if defined %reactOnNPC;
  55. $reactOnNPC{index} = 1;
  56. $reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
  57. } else {
  58. $reactOnNPC{index}++;
  59. $reactOnNPC{msg}[$reactOnNPC{index}] = $msg;
  60. }
  61. debug "01 $reactOnNPC{msg}[1]\n", "success";
  62. debug "02 $reactOnNPC{msg}[2]\n", "success";
  63. debug "03 $reactOnNPC{msg}[3]\n", "success";
  64. debug "04 $reactOnNPC{msg}[4]\n", "success";
  65. debug "05 $reactOnNPC{msg}[5]\n", "success";
  66. debug "06 $reactOnNPC{msg}[6]\n", "success";
  67. debug "07 $reactOnNPC{msg}[7]\n", "success";
  68. debug "08 $reactOnNPC{msg}[8]\n", "success";
  69. debug "09 $reactOnNPC{msg}[9]\n", "success";
  70. debug "10 $reactOnNPC{msg}[10]\n", "success";
  71. }
  72. sub onCheckMatrix {
  73. my (undef, $args) = @_;
  74. undef @actOnNPC if defined @actOnNPC;
  75. my $i = 0;
  76. for ($i=3;$i<8 ;$i++) {
  77. push (@actOnNPC , $reactOnNPC{msg}[$i]);
  78. }
  79. undef %reactOnNPC if defined %reactOnNPC;
  80. my $matrix = '';
  81. my $all_line = '';
  82. my $line = '';
  83. my @array = '';
  84. for $matrix (@actOnNPC) {
  85. @array = split(/\^/,$matrix);
  86. foreach $line (@array) {
  87. if ($line =~ s/\b[f|F,7|8|9|f|F]{6}//) {
  88. $line =~ s/./=/g;
  89. } else {
  90. $line =~ s/\b[a-f0-9A-F]{6}//;
  91. $line =~ s/./#/g;
  92. }
  93. $all_line .= $line;
  94. }
  95. }
  96. # get num 1
  97. $num1 = substr($all_line, 0, 5);
  98. $num1 .= substr($all_line, 19, 5);
  99. $num1 .= substr($all_line, 38, 5);
  100. $num1 .= substr($all_line, 57, 5);
  101. $num1 .= substr($all_line, 76, 5);
  102. debug "num 1 $num1\n", "success";
  103. # get num 2
  104. $num2 = substr($all_line, 7, 5);
  105. $num2 .= substr($all_line, 26, 5);
  106. $num2 .= substr($all_line, 45, 5);
  107. $num2 .= substr($all_line, 64, 5);
  108. $num2 .= substr($all_line, 83, 5);
  109. debug "num 2 $num2\n", "success";
  110. # get num 3
  111. $num3 = substr($all_line, 14, 5);
  112. $num3 .= substr($all_line, 33, 5);
  113. $num3 .= substr($all_line, 52, 5);
  114. $num3 .= substr($all_line, 71, 5);
  115. $num3 .= substr($all_line, 90, 5);
  116. debug "num 3 $num3\n", "success";
  117. # get line for print
  118. my $line1 = substr($all_line, 0, 19);
  119. my $line2 = substr($all_line, 19, 19);
  120. my $line3 = substr($all_line, 38, 19);
  121. my $line4 = substr($all_line, 57, 19);
  122. my $line5 = substr($all_line, 76, 19);
  123. message "$line1\n", "success";
  124. message "$line2\n", "success";
  125. message "$line3\n", "success";
  126. message "$line4\n", "success";
  127. message "$line5\n", "success";
  128. undef $all_line;
  129. undef $line;
  130. undef $matrix;
  131. undef @array;
  132. undef @actOnNPC if defined @actOnNPC;
  133. undef %reactOnNPC if defined %reactOnNPC;
  134. }
  135. sub onMatrixCmd {
  136. my (undef, $args) = @_;
  137. onCheckMatrix;
  138. my %digit = ("######===##===##===######" => 0,
  139. "==#===##====#====#==#####" => 1,
  140. "==#====#====#====#====#==" => 1,
  141. "==##====#====#====#====#=" => 1,
  142. "#####====#######====#####" => 2,
  143. "#####====######====######" => 3,
  144. "#===##===######====#====#" => 4,
  145. "===#===##==#=#=#####===#=" => 4,
  146. "######====#####====######" => 5,
  147. "#====#====######===######" => 6,
  148. "######====######===######" => 6,
  149. "#####====#====#====#====#" => 7,
  150. "#####===#===#===#====#===" => 7,
  151. "######===#######===######" => 8,
  152. "######===######====######" => 9);
  153. my $resutl1 = '';
  154. my $resutl2 = '';
  155. my $resutl3 = '';
  156. foreach (keys %digit) {
  157. if ($_ eq $num1) {
  158. $resutl1 = $digit{$_}
  159. }
  160. if ($_ eq $num2) {
  161. $resutl2 = $digit{$_}
  162. }
  163. if ($_ eq $num3) {
  164. $resutl3 = $digit{$_}
  165. }
  166. }
  167. $cmd = "talk $args " .$resutl1.$resutl2.$resutl3;
  168. message "[MatrixNumber] Executing command \"$cmd\".\n", "success";
  169. #add Delay 1-5 sec
  170. message "*** Delay before $cmd ***.\n", "connection";
  171. my $startTime = time;
  172. while (1) {
  173. last if (timeOut($startTime,5));
  174. }
  175. Commands::run($cmd);
  176. Commands::run("tele");
  177. undef $resutl1;
  178. undef $resutl2;
  179. undef $resutl3;
  180. undef $num1;
  181. undef $num2;
  182. undef $num3;
  183. }

2 ความคิดเห็น:

sineji กล่าวว่า...

อยากให้พี่พัฒนาตอบบอทกัน 3 ชั้นจังเลยครับ ระดับพี่ต้องแก้่ได้แน่ๆ ยังไงก็เป็นกำลังใจ ให้พัฒนาต่อไปนะครับ

3 แบบคือ
1. ให้อักษรสีมา 1 ชุดแต่ให้่พิมสีที่กำหนดให้
2.ถาม < , > , <= , =
3.ถามว่ามีกี่ชุด ( อันนี้รู้สึกพี่พัฒนาแล้ว)

ไม่ระบุชื่อ กล่าวว่า...

[url=http://www.game.jabpid.com/] :D [/url] เว็บเกมออนไลน์ รวมเกม มันส์ๆ
http://www.jabpid.com/
สถานที่เที่ยว-ค้นหาข้อมูลท่องเที่ยวทั่วไทย เที่ยวเมืองไทย ไม่ไปไม่รู้
http://www.tour.jabpid.com/

VT13L1QV5D8UAQ1

[url=http://www.jobs.jabpid.com/] :)[/url] [url=http://www.parttime.jabpid.com/] :)[/url] [url=http://www.music.jabpid.com/] :)[/url] [url=http://www.business.jabpid.com/] :)[/url] [url=http://www.variety.jabpid.com/] :)[/url] [url=http://www.board.jabpid.com/] :)[/url]