Advertisement
Guest User

Untitled

a guest
Feb 15th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 KB | None | 0 0
  1. local function addSkills(player, skillId)
  2. player:addSkillTries(skillId, player:getVocation():getRequiredSkillTries(skillId, player:getSkillLevel(skillId) + 1) - player:getSkillTries(skillId))
  3. return false
  4. end
  5.  
  6.  
  7. local skillids = {
  8. ["shield"] = SKILL_SHIELD,
  9. ["sword"] = SKILL_SWORD,
  10. ["axe"] = SKILL_AXE,
  11. ["club"] = SKILL_CLUB,
  12. ["fist"] = SKILL_FIST,
  13. ["dist"] = SKILL_DISTANCE
  14. }
  15. local attributes = {
  16. ["health"] = {reqPoints = 1, increaseBy = 2, name = "Hit Points"},
  17. ["mana"] = {reqPoints = 1, increaseBy = 2, name = "Mana Points"},
  18. ["magic"] = {reqPoints = 15, increaseBy = 1, name = "Magic Level"},
  19. ["shielding"] = {reqPoints = 15, increaseBy = 1, name = "Shielding Skill"},
  20. ["sword"] = {reqPoints = 15, increaseBy = 1, name = "Sword Skill"},
  21. ["axe"] = {reqPoints = 15, increaseBy = 1, name = "Axe Skill"},
  22. ["club"] = {reqPoints = 15, increaseBy = 1, name = "Club Skill"},
  23. ["fist"] = {reqPoints = 15, increaseBy = 1, name = "Fist Skill"},
  24. ["distance"] = {reqPoints = 15, increaseBy = 1, name = "Distance Skill"},
  25. }
  26.  
  27. function onModalWindow(player, modalWindowId, buttonId, choiceId)
  28. print("LOADED")
  29. local SKILL_POINTS = 45200 --- Change here the storage value used to save the skill points
  30. local points = player:getStorageValue(SKILL_POINTS)
  31.  
  32. local function sendCancel()
  33. player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have the required amount of Skill Points!")
  34. end
  35.  
  36. local function doAddHealth(param, attributes)
  37. player:setMaxHealth(player:getMaxHealth() + attributes["health"].increaseBy*param)
  38. player:addHealth(attributes["health"].increaseBy*param)
  39. player:setStorageValue(SKILL_POINTS, points - attributes["health"].reqPoints*param)
  40. player:sendTextMessage(MESSAGE_INFO_DESCR, "You have gained " ..attributes["health"].increaseBy.. " " ..attributes["health"].name.. "!")
  41. return true
  42. end
  43.  
  44. local function doAddMana(param, attributes)
  45. player:setMaxMana(player:getMaxMana() + attributes["mana"].increaseBy*param)
  46. player:addMana(attributes["mana"].increaseBy*param)
  47. player:setStorageValue(SKILL_POINTS, points - attributes["mana"].reqPoints*param)
  48. player:sendTextMessage(MESSAGE_INFO_DESCR, "You have gained " ..attributes["mana"].increaseBy.. " " ..attributes["mana"].name.. "!")
  49. return true
  50. end
  51.  
  52. if (not modalWindowId == 1) or (buttonId == 4) then
  53. return false
  54. end
  55.  
  56. if choiceId == 1 then
  57. if buttonId == 1 then
  58. if points >= attributes["health"].reqPoints then
  59. doAddHealth(1, attributes)
  60. else
  61. sendCancel()
  62. end
  63. end
  64. if buttonId == 2 then
  65. if points >= attributes["health"].reqPoints*2 then
  66. doAddHealth(2, attributes)
  67. else
  68. sendCancel()
  69. end
  70. end
  71. if buttonId == 3 then
  72. if points >= attributes["health"].reqPoints*5 then
  73. doAddHealth(5, attributes)
  74. else
  75. sendCancel()
  76. end
  77. end
  78. end
  79. if choiceId == 2 then
  80. if buttonId == 1 then
  81. if points >= attributes["mana"].reqPoints then
  82. doAddMana(1, attributes)
  83. else
  84. sendCancel()
  85. end
  86. end
  87. if buttonId == 2 then
  88. if points >= attributes["mana"].reqPoints*2 then
  89. doAddMana(2, attributes)
  90. else
  91. sendCancel()
  92. end
  93. end
  94. if buttonId == 3 then
  95. if points >= attributes["mana"].reqPoints*5 then
  96. doAddMana(5, attributes)
  97. else
  98. sendCancel()
  99. end
  100. end
  101. end
  102. if choiceId == 3 then
  103. if buttonId == 1 then
  104. if points >= attributes["magic"].reqPoints then
  105. player:addManaSpent(math.ceil((player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1)) / configManager.getNumber(configKeys.RATE_MAGIC)))
  106. player:setStorageValue(SKILL_POINTS, points - attributes["magic"].reqPoints)
  107. else
  108. sendCancel()
  109. end
  110. end
  111. if buttonId == 2 then
  112. if points >= attributes["magic"].reqPoints*2 then
  113. for i = 1,2 do
  114. player:addManaSpent(math.ceil((player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1)) / configManager.getNumber(configKeys.RATE_MAGIC)))
  115. player:setStorageValue(SKILL_POINTS, points - attributes["magic"].reqPoints)
  116. end
  117. else
  118. sendCancel()
  119. end
  120. end
  121. if buttonId == 3 then
  122. if points >= attributes["magic"].reqPoints*5 then
  123. for i = 1,5 do
  124. player:addManaSpent(math.ceil((player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1)) / configManager.getNumber(configKeys.RATE_MAGIC)))
  125. player:setStorageValue(SKILL_POINTS, points - attributes["magic"].reqPoints)
  126. end
  127. else
  128. sendCancel()
  129. end
  130. end
  131. end
  132. if choiceId == 4 then
  133. if buttonId == 1 then
  134. if points >= attributes["sword"].reqPoints then
  135. addSkills(player, skillids["sword"])
  136. end
  137. end
  138. if buttonId == 2 then
  139. if points >= attributes["sword"].reqPoints*2 then
  140. for i = 1,2 do
  141. addSkills(player, skillids["sword"])
  142. end
  143. else
  144. sendCancel()
  145. end
  146. end
  147. if buttonId == 3 then
  148. if points >= attributes["sword"].reqPoints*5 then
  149. for i = 1,5 do
  150. addSkills(player, skillids["sword"])
  151. end
  152. else
  153. sendCancel()
  154. end
  155. end
  156. end
  157. if choiceId == 5 then
  158. if buttonId == 1 then
  159. if points >= attributes["axe"].reqPoints then
  160. addSkills(player, skillids["axe"])
  161. end
  162. else
  163. sendCancel()
  164. end
  165. if buttonId == 2 then
  166. if points >= attributes["axe"].reqPoints*2 then
  167. for i = 1,2 do
  168. addSkills(player, skillids["axe"])
  169. end
  170. else
  171. sendCancel()
  172. end
  173. end
  174. if buttonId == 3 then
  175. if points >= attributes["axe"].reqPoints*5 then
  176. for i = 1,5 do
  177. addSkills(player, skillids["axe"])
  178. end
  179. else
  180. sendCancel()
  181. end
  182. end
  183. end
  184. if choiceId == 6 then
  185. if buttonId == 1 then
  186. if points >= attributes["club"].reqPoints then
  187. addSkills(player, skillids["club"])
  188. end
  189. else
  190. sendCancel()
  191. end
  192. if buttonId == 2 then
  193. if points >= attributes["club"].reqPoints*2 then
  194. for i = 1,2 do
  195. addSkills(player, skillids["club"])
  196. end
  197. else
  198. sendCancel()
  199. end
  200. end
  201. if buttonId == 3 then
  202. if points >= attributes["club"].reqPoints*5 then
  203. for i = 1,5 do
  204. addSkills(player, skillids["club"])
  205. end
  206. else
  207. sendCancel()
  208. end
  209. end
  210. end
  211. if choiceId == 7 then
  212. if buttonId == 1 then
  213. if points >= attributes["shielding"].reqPoints then
  214. addSkills(player, skillids["shield"])
  215. end
  216. else
  217. sendCancel()
  218. end
  219. if buttonId == 2 then
  220. if points >= attributes["shielding"].reqPoints*2 then
  221. for i = 1,2 do
  222. addSkills(player, skillids["shield"])
  223. end
  224. else
  225. sendCancel()
  226. end
  227. end
  228. if buttonId == 3 then
  229. if points >= attributes["shielding"].reqPoints*5 then
  230. for i = 1,5 do
  231. addSkills(player, skillids["shield"])
  232. end
  233. else
  234. sendCancel()
  235. end
  236. end
  237. end
  238. if choiceId == 8 then
  239. if buttonId == 1 then
  240. if points >= attributes["distance"].reqPoints then
  241. addSkills(player, skillids["dist"])
  242. end
  243. else
  244. sendCancel()
  245. end
  246. if buttonId == 2 then
  247. if points >= attributes["distance"].reqPoints*2 then
  248. for i = 1,2 do
  249. addSkills(player, skillids["dist"])
  250. end
  251. else
  252. sendCancel()
  253. end
  254. end
  255. if buttonId == 3 then
  256. if points >= attributes["distance"].reqPoints*5 then
  257. for i = 1,5 do
  258. addSkills(player, skillids["dist"])
  259. end
  260. else
  261. sendCancel()
  262. end
  263. end
  264. end
  265. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement