Advertisement
Emistry

[RO] AntiBot - Shop based

Mar 13th, 2016
1,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1.  
  2. - shop anti_bot_shop -1,909:-1
  3.  
  4. - script anti_bot_shop_main -1,{
  5.  
  6. OnInit:
  7. .max_wrong_count = 3;
  8. .duration = 5;
  9. .shop_name$ = "anti_bot_shop";
  10.  
  11. setarray .item_list,
  12. 501,
  13. 502,
  14. 503,
  15. 504,
  16. 505;
  17. .item_list_size = getarraysize( .item_list );
  18. .npc_name$ = strnpcinfo(3);
  19. npcshopdelitem .shop_name$,909;
  20. for ( .@i = 0; .@i < .item_list_size; .@i++ )
  21. npcshopadditem .shop_name$,.item_list[.@i],-1;
  22. end;
  23.  
  24. OnPCLoginEvent:
  25. mes "Welcome!";
  26. mes "Protecting the player's benefit, we have an anti-bot checking. Please finish it within "+.duration+" seconds.";
  27. mes "When "+.max_wrong_count+" attempts failed will sent you to jail.";
  28. next;
  29. OnRepeat:
  30. @wrong_count++;
  31. mes "attempt : "+@wrong_count+"/"+.max_wrong_count;
  32. deltimer .npc_name$+"::OnJail";
  33. addtimer ( .duration * 1000 ),.npc_name$+"::OnJail";
  34. @rand_itemid = .item_list[ rand( .item_list_size ) ];
  35. @rand_amount = rand( 1,100 );
  36. mes "Please buy "+@rand_amount+" "+getitemname( @rand_itemid )+".";
  37. npcshopattach .shop_name$,1;
  38. callshop .shop_name$,1;
  39. end;
  40.  
  41. OnBuyItem:
  42. if ( @bought_nameid[0] != @rand_itemid || @bought_quantity[0] != @rand_amount ) {
  43. mes "Wrong.";
  44. close2;
  45. if ( @wrong_count >= .max_wrong_count ) {
  46. doevent .npc_name$+"::OnJail";
  47. }
  48. else {
  49. doevent .npc_name$+"::OnRepeat";
  50. }
  51. }
  52. deltimer .npc_name$+"::OnJail";
  53. end;
  54.  
  55. OnJail:
  56. mes "Failed.";
  57. atcommand "@jail "+strcharinfo(0);
  58. end;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement