Advertisement
Guest User

Untitled

a guest
Sep 13th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. function onCreatureAppear(cid)          npcHandler:onCreatureAppear(cid)            end
  6. function onCreatureDisappear(cid)       npcHandler:onCreatureDisappear(cid)         end
  7. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)        end
  8. function onThink()              npcHandler:onThink()                    end
  9.  
  10. function creatureSayCallback(cid, type, msg)
  11.     if not npcHandler:isFocused(cid) then
  12.         return false
  13.     end
  14.     local moeda = 9020
  15.     local msg = string.lower(msg)
  16.     local t = {
  17.         ["boots of haste"] = {15, 2195},
  18.         ["demon helmet"] = {25, 2493},
  19.         ["frozen starlight"] = {30, 2361},
  20.         ["royal crossbow"] = {20, 8851},
  21.         ["solar axe"] = {30, 8925},
  22.         ["soft boots"] = {50, 2640},
  23.         ["demon armor"] = {100, 2494},
  24.         ["firewalker boots"] = {50, 9932},
  25.         ["magic plate armor"] = {70, 2472},
  26.         ["flame blade"] = {100, 8931}
  27.     }
  28.     local player = Player(cid)
  29.         if msgcontains(msg, 'trade') then
  30.             local str = ""
  31.             str = str .. "Eu vendo estes items: "
  32.             for name, pos in pairs(t) do
  33.                 str = str.." {"..name.."} = "..pos[1].." Moedas /"
  34.             end
  35.             str = str .. "."
  36.             npcHandler:say(str, cid)
  37.         elseif t[msg] then
  38.         if player:removeItem(moeda, t[msg][1]) then
  39.             player:addItem(t[msg][2], 1)
  40.             npcHandler:say("Aqui está seu ".. ItemType(t[msg][2]):getName() .."!", cid)
  41.         else
  42.             npcHandler:say("Você não tem "..t[msg][1].." ".. ItemType(moeda):getName(), cid)
  43.         end
  44.     end
  45.     return true
  46. end
  47.  
  48. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  49. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement