nfell2009

CodeGenAPI - 2.0

Jul 7th, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. #CodeGenAPI
  2. #By nfell2009
  3.  
  4. options:
  5. P: &8[&aCGA&8]&a
  6.  
  7. on script load:
  8. delete {cga.list::*}
  9. add "a" to {cga.list::*}
  10. add "b" to {cga.list::*}
  11. add "c" to {cga.list::*}
  12. add "d" to {cga.list::*}
  13. add "e" to {cga.list::*}
  14. add "f" to {cga.list::*}
  15. add "g" to {cga.list::*}
  16. add "h" to {cga.list::*}
  17. add "i" to {cga.list::*}
  18. add "j" to {cga.list::*}
  19. add "k" to {cga.list::*}
  20. add "l" to {cga.list::*}
  21. add "m" to {cga.list::*}
  22. add "n" to {cga.list::*}
  23. add "o" to {cga.list::*}
  24. add "p" to {cga.list::*}
  25. add "q" to {cga.list::*}
  26. add "r" to {cga.list::*}
  27. add "s" to {cga.list::*}
  28. add "t" to {cga.list::*}
  29. add "u" to {cga.list::*}
  30. add "v" to {cga.list::*}
  31. add "w" to {cga.list::*}
  32. add "x" to {cga.list::*}
  33. add "y" to {cga.list::*}
  34. add "z" to {cga.list::*}
  35. add "1" to {cga.list::*}
  36. add "2" to {cga.list::*}
  37. add "3" to {cga.list::*}
  38. add "4" to {cga.list::*}
  39. add "5" to {cga.list::*}
  40. add "6" to {cga.list::*}
  41. add "7" to {cga.list::*}
  42. add "8" to {cga.list::*}
  43. add "9" to {cga.list::*}
  44. set {cga.max} to size of {cga.list::*}
  45.  
  46. command /cgapi [<text>] [<text>]:
  47. permission: codegenapi.usage
  48. trigger:
  49. if arg 1 is not set:
  50. message "{@P} You must provide a sub-command!"
  51. else if arg 1 is "api":
  52. if arg 2 is "hooks" or "list":
  53. if size of {cga.apilist.codes::*} is 0:
  54. message "{@P} There are currently no scripts hooked into CodeGenAPI"
  55. else:
  56. loop {cga.apilist.codes::*}:
  57. set {_code} to loop-value
  58. add 1 to {_num}
  59. message "{@P} %{_num}%- %{cga.apilist.names::%{_code}%}% - %{_code}%"
  60. else if arg 1 is "code":
  61. if arg 2 is "stats":
  62. loop {cga.codelist::*}:
  63. set {_first} to loop-value
  64. stop loop
  65. loop {cga.codelist::*}:
  66. add 1 to {_num}
  67. set {_code} to loop-value
  68. set {_code.length} to length of {_code}
  69. set {_first.length} to length of {_first}
  70. if {_code.length} is greater than {_first.length}:
  71. set {_first} to {_code}
  72. message "{@P} CodeGenAPI Code Stats:"
  73. message "{@P} There have been: %{_num}% codes made"
  74. message "{@P} The longest is: %{_first}% with a length of: %length of {_first}%"
  75. message "{@P} There are: %size of {cga.apilist.names::*}% scripts hooked into CodeGenAPI"
  76. message "{@P} Want another stat added? Contact nfell2009 on the Skript Forums"
  77. else if arg 2 is "count":
  78. message "{@P} The size of the codes list is: %size of {cga.codelist::*}%"
  79.  
  80. command /codegenapi [<text>] [<text>] [<text>] [<text>] [<text>]:
  81. executable by: console
  82. trigger:
  83. if arg 1 is "generate" or "gen" or "g":
  84. if arg 2 is "key" or "k":
  85. if arg 3 is not set:
  86. broadcast "{@P} A Skript just tried to create an API key for CodeGenAPI, however it failed to give its name"
  87. else:
  88. set {_code} to ""
  89. loop 100000000 times:
  90. loop 6 times:
  91. set {_type} to a rounded random integer between 1 and 10
  92. if {_type} is equal to 1 or 3 or 5 or 7 or 9:
  93. set {_rand} to a rounded random integer between 27 and {cga.max}
  94. set {_char} to {cga.list::%{_rand}%}
  95. else:
  96. set {_rand} to a rounded random integer between 1 and 26
  97. set {_char} to {cga.list::%{_rand}%}
  98. set {_code} to "%{_code}%%{_char}%"
  99. if {cga.codelist::%{_code}%} is not set:
  100. set {cga.codelist::%{_code}%} to {_code}
  101. set {cga.apilist.names::%{_code}%} to arg 3
  102. set {cga.apilist.codes::%{_code}%} to {_code}
  103. set {cga.%arg 3%.code} to {_code}
  104. exit
  105. else if arg 2 is "code" or "c":
  106. set {_key} to arg 3
  107. if arg 3 is not set:
  108. broadcast "{@P} A Skript tried to generate a code with CodeGenAPI, but failed to supply its API Key"
  109. else if {cga.codelist::%{_key}%} is not set:
  110. broadcast "{@P} A Skript tried to generate a code with CodeGenAPI, but the API Key given doesn't exist"
  111. else if {cga.codelist::%{_key}%} is set:
  112. set {_code} to ""
  113. if arg 4 is set:
  114. if arg 5 is not set:
  115. loop 100000000 times:
  116. loop 6 times:
  117. set {_type} to a rounded random integer between 1 and 10
  118. if {_type} is equal to 1 or 3 or 5 or 7 or 9:
  119. set {_rand} to a rounded random integer between 27 and {cga.max}
  120. set {_char} to {cga.list::%{_rand}%}
  121. else:
  122. set {_rand} to a rounded random integer between 1 and 26
  123. set {_char} to {cga.list::%{_rand}%}
  124. set {_code} to "%{_code}%%{_char}%"
  125. if {cga.codelist::%{_code}%} is not set:
  126. set {cga.codelist::%{_code}%} to {_code}
  127. set {cga.%arg 3%.%arg 4%.code} to {_code}
  128. exit
  129. else:
  130. set {_times} to arg 5 parsed as integer
  131. loop 100000000 times:
  132. loop {_times} times:
  133. set {_type} to a rounded random integer between 1 and 10
  134. if {_type} is equal to 1 or 3 or 5 or 7 or 9:
  135. set {_rand} to a rounded random integer between 27 and {cga.max}
  136. set {_char} to {cga.list::%{_rand}%}
  137. else:
  138. set {_rand} to a rounded random integer between 1 and 26
  139. set {_char} to {cga.list::%{_rand}%}
  140. set {_code} to "%{_code}%%{_char}%"
  141. if {cga.codelist::%{_code}%} is not set:
  142. set {cga.codelist::%{_code}%} to {_code}
  143. set {cga.%arg 3%.%arg 4%.code} to {_code}
  144. exit
  145. else:
  146. broadcast "{@P} A Skript tried to generate a code with CodeGenAPI, but failed to give a unique identifier"
  147. else:
  148. set {_code} to "&c[ERROR] CodeGenAPI failed to get the API key so couldn't create a code..."
Advertisement
Add Comment
Please, Sign In to add comment