Advertisement
Guest User

Untitled

a guest
Oct 5th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. ynpc = YNPC:new( npcHandler )
  2.  
  3. ynpc:initialize()
  4. --Opções iniciais( quando o player começa a conversa com o npc ) de topicos
  5. ynpc:setDefaultTopics( { JOB, FURNITURE } )
  6.  
  7. ynpc:addTopic( {
  8.     id = DONTUNDERSTAND,
  9.     words    = {},
  10.     answer = "I don't understand you. I'm a busy man, if you don't have anything important to talk let me alone. Or you have any wood for me?",
  11.     next     = { WOOD },
  12.     default  = { reset = true }
  13. } )
  14.  
  15. ynpc:addTopic( {
  16.     id = JOB,
  17.     words    = { "job", "work" },
  18.     answer = "I work with {wood}. I can transform it in many useful things.",
  19.     next     = { WOOD },
  20.     default = {topic = DONTUNDERSTAND}
  21. } )
  22.  
  23.  ynpc:addTopic( {
  24.     id = FURNITURE,
  25.     words = { "furniture" },
  26.     answer = "I build a lot of furniture types. Besides, i need good {wood} for build any furniture.",
  27.     next = { WOOD },
  28.     condition = getCondition,
  29.     conditionDefault = { reset = true },
  30.     default = {topic = DONTUNDERSTAND}
  31. } )
  32.  
  33. ynpc:addTopic( {
  34.     id = WOOD,
  35.     words = { "wood" },
  36.     answer = "Yes, its very important to do my job. Can you give me some wood?",
  37.     next = { WOODYES, WOODNO },
  38.     default = {message = "I don't understand you."}
  39. } )
  40.  
  41. local function getWoodFromPlayer( cid, next )
  42.     local player = Player( cid )
  43.     local amount = player:getItemCount( 5901 )
  44.     if amount > 0 then
  45.         player:removeItem( 5901, amount )
  46.         npcHandler:say("Than you!", cid )
  47.     else
  48.         npcHandler:say("You don't have any wood.", cid )
  49.     end
  50.    
  51.     return true
  52. end
  53.  
  54. yesWoodTopic = ynpc:addTopic( {
  55.     id = WOODYES,
  56.     words = { "yes" },
  57.     answer = getWoodFromPlayer,
  58.     next = {}
  59. } )
  60.  
  61. ynpc:addTopic( {
  62.     id = WOODNO,
  63.     words = { "no" },
  64.     answer = "Ok. Come back when you have interest in giving me some wood.",
  65.     next = { }
  66. } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement