Advertisement
Kaiquegabriel

nahlesar

Jul 27th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.55 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5.  
  6. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  7. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  8. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  9. function onThink() npcHandler:onThink() end
  10.  
  11. local itemWindow = {
  12. {id=2208, subType=0, sell=50, name="axe ring"},
  13. {id=2191, subType=0, sell=100, name="wand of dragonbreath"},
  14. {id=2197, subType=0, sell=250, name="stone skin amulet"},
  15. {id=2172, subType=0, sell=25, name="bronze amulet"},
  16. {id=2209, subType=0, sell=50, name="club ring"},
  17. {id=2198, subType=0, sell=50, name="elven amulet"},
  18. {id=2199, subType=0, sell=25, name="garlic necklace"},
  19. {id=2177, subType=0, sell=25, name="life crystal"},
  20. {id=2162, subType=0, sell=20, name="magic lightwand"},
  21. {id=2178, subType=0, sell=50, name="mindstone"},
  22. {id=2176, subType=0, sell=375, name="orb"},
  23. {id=2166, subType=0, sell=25, name="power ring"},
  24. {id=2165, subType=0, sell=100, name="stealth ring"},
  25. {id=2207, subType=0, sell=50, name="sword ring"},
  26. {id=2189, subType=0, sell=1000, name="wand of cosmic energy"},
  27. {id=2188, subType=0, sell=500, name="wand of decay"},
  28. {id=8921, subType=0, sell=750, name="wand of draconia"},
  29. {id=2187, subType=0, sell=1500, name="wand of inferno"},
  30. {id=2190, subType=0, sell=50, name="wand of vortex"},
  31. {id=2532, subType=0, sell=450, name="ancient shield"},
  32. {id=2529, subType=0, sell=800, name="black shield"},
  33. {id=7428, subType=0, sell=5000, name="bonebreaker"},
  34. {id=2489, subType=0, sell=200, name="dark armor"},
  35. {id=2490, subType=0, sell=125, name="dark helmet"},
  36. {id=2434, subType=0, sell=1000, name="dragon hammer"},
  37. {id=7419, subType=0, sell=7500, name="dreaded cleaver"},
  38. {id=2393, subType=0, sell=8500, name="giant sword"},
  39. {id=7407, subType=0, sell=4000, name="haunted blade"},
  40. {id=2476, subType=0, sell=2500, name="knight armor"},
  41. {id=2430, subType=0, sell=1000, name="knight axe"},
  42. {id=2477, subType=0, sell=2500, name="knight legs"},
  43. {id=2663, subType=0, sell=75, name="mystic turban"},
  44. {id=7421, subType=0, sell=11000, name="onyx flail"},
  45. {id=7411, subType=0, sell=10000, name="ornamented axe"},
  46. {id=2411, subType=0, sell=25, name="poison dagger"},
  47. {id=2419, subType=0, sell=75, name="scimitar"},
  48. {id=2409, subType=0, sell=450, name="serpent sword"},
  49. {id=2436, subType=0, sell=3000, name="skull staff"},
  50. {id=2479, subType=0, sell=250, name="strange helmet"},
  51. {id=7413, subType=0, sell=2000, name="titan axe"},
  52. {id=2528, subType=0, sell=4000, name="tower shield"},
  53. {id=2534, subType=0, sell=7500, name="vampire shield"},
  54. {id=2475, subType=0, sell=2500, name="warrior helmet"},
  55. {id=7436, subType=0, sell=2500, name="angelic axe"},
  56. {id=2656, subType=0, sell=5000, name="blue robe"},
  57. {id=2518, subType=0, sell=600, name="beholder shield"},
  58. {id=2195, subType=0, sell=15000, name="boots of haste"},
  59. {id=2413, subType=0, sell=250, name="broadsword"},
  60. {id=7412, subType=0, sell=9000, name="butchers axe"},
  61. {id=2487, subType=0, sell=6000, name="crown armor"},
  62. {id=2491, subType=0, sell=1250, name="crown helmet"},
  63. {id=2488, subType=0, sell=6000, name="crown legs"},
  64. {id=2519, subType=0, sell=4000, name="crown shield"},
  65. {id=2497, subType=0, sell=3000, name="crusader helmet"},
  66. {id=2414, subType=0, sell=4500, name="dragon lance"},
  67. {id=2516, subType=0, sell=2000, name="dragon shield"},
  68. {id=2432, subType=0, sell=4000, name="fire axe"},
  69. {id=2392, subType=0, sell=2000, name="fire sword"},
  70. {id=7454, subType=0, sell=1500, name="glorious axe"},
  71. {id=2515, subType=0, sell=1000, name="guardian shield"},
  72. {id=2396, subType=0, sell=500, name="ice rapier"},
  73. {id=2486, subType=0, sell=450, name="noble armor"},
  74. {id=2425, subType=0, sell=250, name="obsidian lance"},
  75. {id=2539, subType=0, sell=8000, name="phoenix shield"},
  76. {id=7410, subType=0, sell=5000, name="queen sceptre"},
  77. {id=2498, subType=0, sell=15000, name="royal helmet"},
  78. {id=7451, subType=0, sell=5000, name="shadow sceptre"},
  79. {id=2383, subType=0, sell=500, name="spike sword"},
  80. {id=7391, subType=0, sell=8000, name="thaian sword"},
  81. {id=2391, subType=0, sell=600, name="war hammer"},
  82. {id=2193, subType=0, sell=50, name="ankh"},
  83. {id=2201, subType=0, sell=50, name="dragon necklace"},
  84. {id=2213, subType=0, sell=50, name="dwarven ring"},
  85. {id=2167, subType=0, sell=50, name="energy ring"},
  86. {id=2183, subType=0, sell=1500, name="hailstorm rod"},
  87. {id=2168, subType=0, sell=25, name="life ring"},
  88. {id=2164, subType=0, sell=125, name="might ring"},
  89. {id=2186, subType=0, sell=100, name="moonlight rod"},
  90. {id=2194, subType=0, sell=25, name="mysterious fetish"},
  91. {id=2185, subType=0, sell=500, name="necrotic rod"},
  92. {id=8911, subType=0, sell=750, name="northwind rod"},
  93. {id=2200, subType=0, sell=50, name="protection amulet"},
  94. {id=2214, subType=0, sell=50, name="ring of healing"},
  95. {id=2185, subType=0, sell=15, name="strange talisman"},
  96. {id=2170, subType=0, sell=25, name="silver amulet"},
  97. {id=2182, subType=0, sell=50, name="snakebite rod"},
  98. {id=2181, subType=0, sell=1000, name="terra rod"},
  99. {id=2169, subType=0, sell=50, name="time ring"}
  100. -- ID = ID DO ITEM
  101. -- SBUTYPE = SÓ DEUS SABE
  102. -- SELL = VALOR PARA O PLAYER VENDER
  103. -- NAME = NOME QUE APARECE NA JANELA DE COMPRA/VENDA
  104. }
  105.  
  106. local itemWindowPremium = {
  107. {id=2208, subType=0, sell=100, name="axe ring"},
  108. {id=2191, subType=0, sell=200, name="wand of dragonbreath"},
  109. {id=2197, subType=0, sell=500, name="stone skin amulet"},
  110. {id=2172, subType=0, sell=50, name="bronze amulet"},
  111. {id=2209, subType=0, sell=100, name="club ring"},
  112. {id=2198, subType=0, sell=100, name="elven amulet"},
  113. {id=2199, subType=0, sell=50, name="garlic necklace"},
  114. {id=2177, subType=0, sell=50, name="life crystal"},
  115. {id=2162, subType=0, sell=40, name="magic lightwand"},
  116. {id=2178, subType=0, sell=100, name="mindstone"},
  117. {id=2176, subType=0, sell=750, name="orb"},
  118. {id=2166, subType=0, sell=50, name="power ring"},
  119. {id=2165, subType=0, sell=200, name="stealth ring"},
  120. {id=2207, subType=0, sell=100, name="sword ring"},
  121. {id=2189, subType=0, sell=2000, name="wand of cosmic energy"},
  122. {id=2188, subType=0, sell=1000, name="wand of decay"},
  123. {id=8921, subType=0, sell=1500, name="wand of draconia"},
  124. {id=2187, subType=0, sell=3000, name="wand of inferno"},
  125. {id=2190, subType=0, sell=100, name="wand of vortex"},
  126. {id=2532, subType=0, sell=900, name="ancient shield"},
  127. {id=2529, subType=0, sell=1600, name="black shield"},
  128. {id=7428, subType=0, sell=10000, name="bonebreaker"},
  129. {id=2489, subType=0, sell=400, name="dark armor"},
  130. {id=2490, subType=0, sell=250, name="dark helmet"},
  131. {id=2434, subType=0, sell=2000, name="dragon hammer"},
  132. {id=7419, subType=0, sell=15000, name="dreaded cleaver"},
  133. {id=2393, subType=0, sell=17000, name="giant sword"},
  134. {id=7407, subType=0, sell=8000, name="haunted blade"},
  135. {id=2476, subType=0, sell=5000, name="knight armor"},
  136. {id=2430, subType=0, sell=2000, name="knight axe"},
  137. {id=2477, subType=0, sell=5000, name="knight legs"},
  138. {id=2663, subType=0, sell=150, name="mystic turban"},
  139. {id=7421, subType=0, sell=22000, name="onyx flail"},
  140. {id=7411, subType=0, sell=20000, name="ornamented axe"},
  141. {id=2411, subType=0, sell=50, name="poison dagger"},
  142. {id=2419, subType=0, sell=150, name="scimitar"},
  143. {id=2409, subType=0, sell=900, name="serpent sword"},
  144. {id=2436, subType=0, sell=6000, name="skull staff"},
  145. {id=2479, subType=0, sell=500, name="strange helmet"},
  146. {id=7413, subType=0, sell=4000, name="titan axe"},
  147. {id=2528, subType=0, sell=8000, name="tower shield"},
  148. {id=2534, subType=0, sell=15000, name="vampire shield"},
  149. {id=2475, subType=0, sell=5000, name="warrior helmet"},
  150. {id=7436, subType=0, sell=5000, name="angelic axe"},
  151. {id=2656, subType=0, sell=10000, name="blue robe"},
  152. {id=2518, subType=0, sell=1200, name="beholder shield"},
  153. {id=2195, subType=0, sell=30000, name="boots of haste"},
  154. {id=2413, subType=0, sell=500, name="broadsword"},
  155. {id=7412, subType=0, sell=18000, name="butchers axe"},
  156. {id=2487, subType=0, sell=12000, name="crown armor"},
  157. {id=2491, subType=0, sell=2500, name="crown helmet"},
  158. {id=2488, subType=0, sell=12000, name="crown legs"},
  159. {id=2519, subType=0, sell=8000, name="crown shield"},
  160. {id=2497, subType=0, sell=6000, name="crusader helmet"},
  161. {id=2414, subType=0, sell=9000, name="dragon lance"},
  162. {id=2516, subType=0, sell=4000, name="dragon shield"},
  163. {id=2432, subType=0, sell=8000, name="fire axe"},
  164. {id=2392, subType=0, sell=4000, name="fire sword"},
  165. {id=7454, subType=0, sell=3000, name="glorious axe"},
  166. {id=2515, subType=0, sell=2000, name="guardian shield"},
  167. {id=2396, subType=0, sell=1000, name="ice rapier"},
  168. {id=2486, subType=0, sell=900, name="noble armor"},
  169. {id=2425, subType=0, sell=500, name="obsidian lance"},
  170. {id=2539, subType=0, sell=16000, name="phoenix shield"},
  171. {id=7410, subType=0, sell=10000, name="queen sceptre"},
  172. {id=2498, subType=0, sell=30000, name="royal helmet"},
  173. {id=7451, subType=0, sell=10000, name="shadow sceptre"},
  174. {id=2383, subType=0, sell=1000, name="spike sword"},
  175. {id=7391, subType=0, sell=16000, name="thaian sword"},
  176. {id=2391, subType=0, sell=1200, name="war hammer"},
  177. {id=2193, subType=0, sell=100, name="ankh"},
  178. {id=2201, subType=0, sell=100, name="dragon necklace"},
  179. {id=2213, subType=0, sell=100, name="dwarven ring"},
  180. {id=2167, subType=0, sell=100, name="energy ring"},
  181. {id=2183, subType=0, sell=3000, name="hailstorm rod"},
  182. {id=2168, subType=0, sell=50, name="life ring"},
  183. {id=2164, subType=0, sell=250, name="might ring"},
  184. {id=2186, subType=0, sell=200, name="moonlight rod"},
  185. {id=2194, subType=0, sell=50, name="mysterious fetish"},
  186. {id=2185, subType=0, sell=1000, name="necrotic rod"},
  187. {id=8911, subType=0, sell=1500, name="northwind rod"},
  188. {id=2200, subType=0, sell=100, name="protection amulet"},
  189. {id=2214, subType=0, sell=100, name="ring of healing"},
  190. {id=2185, subType=0, sell=30, name="strange talisman"},
  191. {id=2170, subType=0, sell=50, name="silver amulet"},
  192. {id=2182, subType=0, sell=100, name="snakebite rod"},
  193. {id=2181, subType=0, sell=2000, name="terra rod"},
  194. {id=2169, subType=0, sell=100, name="time ring"}
  195. -- ID = ID DO ITEM
  196. -- SBUTYPE = SÓ DEUS SABE
  197. -- SELL = VALOR PARA O PLAYER VENDER
  198. -- NAME = NOME QUE APARECE NA JANELA DE COMPRA/VENDA
  199. }
  200.  
  201. local items = {}
  202. if(isPremium == true) then
  203. for _, item in ipairs(itemWindowPremium) do
  204. items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, subType = item.subType, realName = item.name}
  205. end
  206. else
  207. for _, item in ipairs(itemWindow) do
  208. items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, subType = item.subType, realName = item.name}
  209. end
  210. end
  211.  
  212. local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
  213. if(items[item] == nil) then
  214. selfSay("Ehm.. sorry... this shouldn't be there, I'm not buying it.", cid)
  215. end
  216.  
  217. if(subType < 1) then
  218. subType = -1
  219. end
  220.  
  221. if(isPremium(cid) == true) then
  222. if(doPlayerRemoveItem(cid, item, amount, subType)) then
  223. doPlayerAddMoney(cid, items[item].sellPrice * 2 * amount)
  224. selfSay("Uhh... It's always good to make a profit.", cid)
  225. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sold ".. amount .."x ".. items[item].realName .." for ".. items[item].sellPrice * 2 * amount .." gold.")
  226. else
  227. selfSay("No item, no deal.", cid)
  228. end
  229. else
  230. if(doPlayerRemoveItem(cid, item, amount, subType)) then
  231. doPlayerAddMoney(cid, items[item].sellPrice * amount)
  232. selfSay("Uhh... It's always good to make a profit.", cid)
  233. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sold ".. amount .."x ".. items[item].realName .." for ".. items[item].sellPrice * amount .." gold.")
  234. else
  235. selfSay("No item, no deal.", cid)
  236. end
  237. end
  238. end
  239.  
  240. function creatureSayCallback(cid, type, msg)
  241. if(not npcHandler:isFocused(cid)) then
  242. return false
  243. end
  244.  
  245. if(msgcontains(msg, "trade")) then
  246. if(isPremium(cid) == true) then
  247. selfSay("Hmm, it's great to have someone to trade.", cid)
  248. openShopWindow(cid, itemWindowPremium, onBuy, onSell)
  249. else
  250. selfSay("Hmm, it's great to have someone to trade.", cid)
  251. openShopWindow(cid, itemWindow, onBuy, onSell)
  252. end
  253. end
  254. end
  255.  
  256. local interval = 2 -- EM SEGUNDOS
  257.  
  258. function onThink()
  259. local npc = getNpcCid()
  260. addEvent(function()
  261. if(isCreature(npc)) then
  262. doCreatureChangeOutfit(npc, {lookType = (getCreatureOutfit(npc).lookType == 80 and 51 or 80)})
  263. end
  264. end, interval*1000)
  265. end
  266.  
  267. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  268. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement