Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. function doTakeReward(cid, table)
  2. if not isPlayer(cid) or (table and not next(table)) then
  3. return false
  4. end
  5.  
  6. local begin, text = true, ""
  7. if table.addMessage and table.addMessage ~= "" then
  8. if begin then
  9. text = "You received "
  10. begin = false
  11. else
  12. text = text .. ", "
  13. end
  14. text = table.addMessage
  15. end
  16.  
  17. local newContainer = nil
  18. if table.addMoney and table.addMoney > 0 then
  19. newContainer = doCreateItemEx(ITEM_PARCEL)
  20.  
  21. for _, coin in pairs(createMoney(table.addMoney)) do
  22. doAddContainerItem(newContainer, coin[1], coin[2])
  23. end
  24.  
  25. if not table.addItem then
  26. doPlayerAddItemEx(cid, newContainer)
  27. end
  28.  
  29. if begin then
  30. text = "You received "
  31. begin = false
  32. else
  33. text = text .. ", "
  34. end
  35. text = text .. getPrice(table.addMoney)
  36. end
  37.  
  38. if table.addItem and #table.addItem > 0 then
  39. local receivedItem, itemsWorth = 0, 0
  40. local itemsText = ""
  41. for k, item in ipairs(table.addItem) do
  42. if not item.ignoreInfo then
  43. itemsText = itemsText .. (item.count > 1 and (item.count .. 'x ') or '') .. getItemNameById(item.id)
  44. if k ~= #table.addItem then
  45. itemsText = itemsText .. ', '
  46. end
  47. end
  48. end
  49.  
  50. if #table.addItem > 1 or (table.addMoney and table.addMoney > 0) then
  51. if not newContainer then
  52. newContainer = doCreateItemEx(ITEM_PARCEL)
  53. end
  54.  
  55. for k, item in pairs(table.addItem) do
  56. doAddContainerItem(newContainer, item.id, item.count)
  57. end
  58. itemsText = itemsText .. "(in container"
  59.  
  60. if doPlayerAddItemEx(cid, newContainer) ~= RETURNVALUE_NOERROR then
  61. itemsText = itemsText .. ", sended to depo"
  62. doPlayerSendMailByName(getPlayerName(cid), newContainer)
  63. end
  64. itemsText = itemsText .. ")"
  65. else
  66. if table.addItem[1].count > 100 then
  67. if not newContainer then
  68. newContainer = doCreateItemEx(ITEM_PARCEL)
  69. end
  70.  
  71. itemsText = itemsText .. "(in container"
  72. doAddContainerItem(newContainer, table.addItem[1].id, table.addItem[1].count)
  73. if doPlayerAddItemEx(cid, newContainer) ~= RETURNVALUE_NOERROR then
  74. itemsText = itemsText .. ", sended to depo"
  75. doPlayerSendMailByName(getPlayerName(cid), newContainer)
  76. end
  77. itemsText = itemsText .. ")"
  78. else
  79. local newItem = doCreateItemEx(table.addItem[1].id, table.addItem[1].count)
  80. if doPlayerAddItemEx(cid, newItem) ~= RETURNVALUE_NOERROR then
  81. itemsText = itemsText .. "(sended to depo)"
  82. doPlayerSendMailByName(getPlayerName(cid), newItem)
  83. end
  84. end
  85. end
  86.  
  87. if begin then
  88. text = "You received "
  89. begin = false
  90. else
  91. if not table.addMessage then
  92. text = text .. ", "
  93. end
  94. end
  95. text = text .. itemsText
  96. end
  97.  
  98. if table.addExperience and table.addExperience ~= 0 or table.addExp and table.addExp ~= 0 then
  99. doPlayerAddExperience(cid, tonumber(table.addExperience and table.addExperience or table.addExp))
  100.  
  101. if begin then
  102. text = "You received "
  103. begin = false
  104. else
  105. text = text .. ", "
  106. end
  107. text = text .. '+' .. (table.addExperience and table.addExperience or table.addExp) .. ' experience'
  108. end
  109.  
  110. if table.addLevel and table.addLevel ~= 0 then
  111. doPlayerAddLevel(cid, table.addLevel)
  112.  
  113. if begin then
  114. text = "You received "
  115. begin = false
  116. else
  117. text = text .. ", "
  118. end
  119. text = text .. '+' .. table.addLevel .. ' level' .. (table.addLevel > 1 and 's' or '')
  120. end
  121.  
  122. if table.addStorage and type(table.addStorage) == 'table' then
  123. setPlayerStorageValue(cid, table.addStorage[1], table.addStorage[2])
  124.  
  125. if table.addStorage[3] then
  126. if begin then
  127. text = "You received "
  128. begin = false
  129. else
  130. text = text .. ", "
  131. end
  132. text = text .. table.addStorage[3]
  133. end
  134. end
  135.  
  136. if table.addSpell and table.addSpell ~= "" then
  137. doPlayerLearnInstantSpell(cid, table.addSpell)
  138.  
  139. if begin then
  140. text = "You received "
  141. begin = false
  142. else
  143. text = text .. ", "
  144. end
  145. text = text .. 'learned new spell *' .. table.addSpell .. '*'
  146. end
  147.  
  148. if table.addMaxHealth and table.addMaxHealth ~= 0 then
  149. setCreatureMaxHealth(cid, getCreatureMaxHealth(cid, true) + table.addMaxHealth)
  150.  
  151. if begin then
  152. text = "You received "
  153. begin = false
  154. else
  155. text = text .. ", "
  156. end
  157. text = text .. '+' .. table.addMaxHealth .. ' of maximum health'
  158. end
  159.  
  160. if table.addMaxMana and table.addMaxMana ~= 0 then
  161. setCreatureMaxMana(cid, getPlayerMaxMana(cid, true) + table.addMaxMana)
  162.  
  163. if begin then
  164. text = "You received "
  165. begin = false
  166. else
  167. text = text .. ", "
  168. end
  169. text = text .. '+' .. table.addMaxMana .. ' of maximum ki points'
  170. end
  171.  
  172. if table.addSkill and type(table.addSkill) == 'table' then
  173. doPlayerAddSkillLevel(cid, table.addSkill[1], table.addSkill[2])
  174.  
  175. if begin then
  176. text = "You received "
  177. begin = false
  178. else
  179. text = text .. ", "
  180. end
  181. text = text .. '+' .. table.addSkill[2] .. ' ' .. SKILL_NAMES[table.addSkill[1]]
  182. end
  183.  
  184. if table.teleport and type(table.teleport) == 'table' then
  185. doTeleportThing(cid, table.teleport[1])
  186.  
  187. if begin then
  188. text = "You received "
  189. begin = false
  190. else
  191. text = text .. ", "
  192. end
  193. text = text .. 'get teleported ' .. (table.teleport[2] and 'to ' .. table.teleport[2] or "somewhere")
  194. end
  195.  
  196. if text ~= "" then
  197. text = text .. "."
  198. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
  199. end
  200.  
  201. return true
  202. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement