Advertisement
Guest User

Rashid.lua

a guest
Jun 23rd, 2013
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.03 KB | None | 0 0
  1. -- RL Rashid Script by Zbizu, for OTLand.net --
  2. -- This script is 100% free and will be. You are not allowed to sell it! --
  3. -- special thanks to Dantez and Dubler for support with custom trade system --
  4. -- Yeah, yeah I suck in LUA, I know it could be shorter and shit, post better if you think this one is bad. --
  5.  
  6. -- config begins here
  7.     local MSG_MISSION_WRONG_DAY = "I'm not in the mood to talk about that right now. Come find me on another day."
  8.     local MSG_MISSION_DONE = "You helped enough for today. Come back tomorrow."
  9.     local MSG_MISSION_NEXT = "So, my friend, are you willing to proceed to the next mission to become a recognised trader?"
  10.     local MSG_QUEST_DONE = "You don't need to prove anything anymore, old friend. If you want to {trade}, just ask."
  11.     local DAY_GLOBALSTORAGE = 25358 -- must be same as in RashidHandler
  12.     local TRADE_PLAYERSTORAGE = 25358
  13.     local ENDSTORAGE = 13 -- last mission done storage
  14.  
  15. -- put there storages npcs check before they give player questitem
  16.     local Willard_storage = {85, 3}
  17.     local Miraia_storage = {85, 9}
  18.     local Briasol_storage = {85, 11}
  19.     local Uzgod_storage = {85, 14}
  20. -- config ends here
  21.  
  22. local keywordHandler = KeywordHandler:new()
  23. local npcHandler = NpcHandler:new(keywordHandler)
  24. NpcSystem.parseParameters(npcHandler)
  25. local talkState = {}
  26. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  27. local items = {}
  28.  
  29. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
  30. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
  31. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
  32. function onThink()                          npcHandler:onThink()                        end
  33. function onPlayerEndTrade(cid)              npcHandler:onPlayerEndTrade(cid)            end
  34. function onPlayerCloseChannel(cid)          npcHandler:onPlayerCloseChannel(cid)        end
  35.    
  36. function creatureSayCallback(cid, type, msg)
  37.     if(not npcHandler:isFocused(cid)) then
  38.         return false
  39.     end
  40.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  41. local RashidList = {
  42.     [1] = { -- armors
  43.     {id=20109, sell=7000, name="Buckle"}, -- 981
  44.     {id=8878, sell=16000, name="Crystalline Armor"},
  45.     {id=8885, sell=55000, name="Divine Plate"},
  46.     {id=2492, sell=40000, name="Dragon Scale Mail"},
  47.     {id=2503, sell=30000, name="Dwarven Armor"},
  48.     {id=9929, sell=1000, name="Flower Dress"},
  49.     {id=7897, sell=11000, name="Glacier Robe"},
  50.     {id=2466, sell=20000, name="Golden Armor"},
  51.     {id=8873, sell=3000, name="Hibiscus Dress"},
  52.     {id=8877, sell=16000, name="Lavos Armor"},
  53.     {id=3968, sell=1000, name="Leopard Armor"},
  54.     {id=7898, sell=11000, name="Lightning Robe"},
  55.     {id=2472, sell=90000, name="Magic Plate Armor"},
  56.     {id=7899, sell=11000, name="Magma Coat"},
  57.     {id=7463, sell=6000, name="Mammoth Fur Cape"},
  58.     {id=8891, sell=15000, name="Paladin Armor"},
  59.     {id=6095, sell=500, name="Pirate Shirt"},
  60.     {id=8889, sell=18000, name="Skullcracker Armor"},
  61.     {id=8880, sell=16000, name="Swamplair Armor"},
  62.     {id=7884, sell=11000, name="Terra Mantle"},
  63.     },
  64.  
  65.     [2] = { -- legs
  66.     {id=7896, sell=11000, name="Glacier Kilt"},
  67.     {id=2470, sell=30000, name="Golden Legs"},
  68.     {id=9928, sell=500, name="Leaf Legs"},
  69.     {id=7895, sell=11000, name="Lightning Legs"},
  70.     {id=7894, sell=11000, name="Magma Legs"},
  71.     {id=7464, sell=850, name="Mammoth Fur Shorts"},
  72.     {id=5918, sell=200, name="Pirate Knee Breeches"},
  73.     {id=7885, sell=11000, name="Terra Legs"},
  74.     },
  75.  
  76.     [3] = { -- shields
  77.     {id=2541, sell=80, name="Bone Shield"},
  78.     {id=2535, sell=5000, name="Castle Shield"},
  79.     {id=2521, sell=400, name="Dark Shield"},
  80.     {id=2520, sell=30000, name="Demon Shield"},
  81.     {id=2514, sell=50000, name="Mastermind Shield"},
  82.     {id=2536, sell=9000, name="Medusa Shield"},
  83.     {id=7460, sell=1500, name="Norse Shield"},
  84.     {id=2540, sell=2000, name="Scarab Shield"},
  85.     {id=2542, sell=35000, name="Tempest Shield"},
  86.     {id=6131, sell=150, name="Tortoise Shield"},
  87.     },
  88.  
  89.     [4] = { -- helmets
  90.     {id=5917, sell=150, name="Bandana"},
  91.     {id=3972, sell=7500, name="Bonelord Helmet"},
  92.     {id=12630, sell=40000, name="Cobra Crown"},
  93.     {id=2462, sell=1000, name="Devil Helmet"},
  94.     {id=9927, sell=500, name="Flower Wreath"},
  95.     {id=7902, sell=2500, name="Glacier Mask"},
  96.     {id=20132, sell=2000, name="Helmet of the Lost"}, -- 981
  97.     {id=7461, sell=200, name="Krimhorn Helmet"},
  98.     {id=7901, sell=2500, name="Lightning Headband"},
  99.     {id=7900, sell=2500, name="Magma Monocle"},
  100.     {id=6096, sell=1000, name="Pirate Hat"},
  101.     {id=7462, sell=400, name="Ragnir Helmet"},
  102.     {id=5741, sell=40000, name="Skull Helmet"},
  103.     {id=7903, sell=2500, name="Terra Hood"},
  104.     {id=10570, sell=5000, name="Witch Hat"},
  105.     },
  106.  
  107.     [5] = { -- boots
  108.     {id=9931, sell=500, name="Coconut Shoes"},
  109.     {id=3982, sell=1000, name="Crocodile Boots"},
  110.     {id=7457, sell=2000, name="Fur Boots"},
  111.     {id=7892, sell=2500, name="Glacier Shoes"},
  112.     {id=7893, sell=2500, name="Lightning Boots"},
  113.     {id=7891, sell=2500, name="Magma Boots"},
  114.     {id=2641, sell=2000, name="Patched Boots"},
  115.     {id=5462, sell=3000, name="Pirate Boots"},
  116.     {id=2645, sell=30000, name="Steel Boots"},
  117.     {id=7886, sell=2500, name="Terra Boots"},
  118.     },
  119.  
  120.     [6] = { -- weapons
  121.     {id=7414, sell=20000, name="Abyss Hammer"},
  122.     {id=7426, sell=8000, name="Amber Staff"},
  123.     {id=7404, sell=20000, name="Assassin Dagger"},
  124.     {id=3962, sell=1500, name="Beastslayer Axe"},
  125.     {id=7403, sell=40000, name="Berserker"},
  126.     {id=7406, sell=6000, name="Blacksteel Sword"},
  127.     {id=7429, sell=40000, name="Blessed Sceptre"},
  128.     {id=7379, sell=1500, name="Brutetamer's Staff"},
  129.     {id=8850, sell=40000, name="Chain Bolter"},
  130.     {id=7427, sell=9000, name="Chaos Mace"},
  131.     {id=8855, sell=25000, name="Composite Hornbow"},
  132.     {id=7415, sell=30000, name="Cranial Basher"},
  133.     {id=18453, sell=35000, name="Crystal Crossbow"}, -- 96
  134.     {id=2445, sell=12000, name="Crystal Mace"},
  135.     {id=7449, sell=600, name="Crystal Sword"},
  136.     {id=2439, sell=110, name="Daramanian Mace"},
  137.     {id=2440, sell=1000, name="Daramanian Waraxe"},
  138.     {id=7382, sell=36000, name="Demonrage Sword"},
  139.     {id=7387, sell=3000, name="Diamond Sceptre"},
  140.     {id=2451, sell=15000, name="Djinn Blade"},
  141.     {id=7402, sell=15000, name="Dragon Slayer"},
  142.     {id=7430, sell=3000, name="Dragonbone Staff"},
  143.     {id=7419, sell=10000, name="Dreaded Cleaver"}, -- green djinn 15k
  144.     {id=7438, sell=2000, name="Elvish Bow"},
  145.     {id=2438, sell=8000, name="Epee"},
  146.     {id=7432, sell=1000, name="Furry Club"},
  147.     {id=2427, sell=11000, name="Guardian Halberd"},
  148.     {id=2444, sell=30000, name="Hammer of Wrath"},
  149.     {id=7380, sell=6000, name="Headchopper"},
  150.     {id=2452, sell=50000, name="Heavy Mace"},
  151.     {id=2442, sell=90, name="Heavy Machete"},
  152.     {id=13838, sell=2000, name="Heavy Trident"}, -- 92
  153.     {id=7389, sell=30000, name="Heroic Axe"},
  154.     {id=7422, sell=25000, name="Jade Hammer"},
  155.     {id=7390, sell=40000, name="Justice Seeker"},
  156.     {id=7424, sell=5000, name="Lunar Staff"},
  157.     {id=7381, sell=300, name="Mammoth Whopper"},
  158.     {id=7386, sell=12000, name="Mercenary Sword"},
  159.     {id=18454, sell=35000, name="Mycological Bow"}, -- 96
  160.     {id=7384, sell=30000, name="Mystic Blade"},
  161.     {id=2426, sell=2000, name="Naginata"},
  162.     {id=7418, sell=35000, name="Nightmare Blade"},
  163.     {id=7456, sell=10000, name="Noble Axe"},
  164.     {id=7392, sell=6000, name="Orcish Maul"},
  165.     {id=20108, sell=4000, name="Pair of Iron Fists"}, -- 981
  166.     {id=2446, sell=23000, name="Pharaoh Sword"},
  167.     {id=7383, sell=25000, name="Relic Sword"},
  168.     {id=7434, sell=40000, name="Royal Axe"},
  169.     {id=6553, sell=45000, name="Ruthless Axe"},
  170.     {id=7437, sell=7000, name="Sapphire Hammer"},
  171.     {id=2402, sell=500, name="Silver Dagger"},
  172.     {id=7452, sell=5000, name="Spiked Squelcher"},
  173.     {id=7425, sell=500, name="Taurus Mace"},
  174.     {id=7388, sell=30000, name="Vile Axe"},
  175.     {id=2454, sell=12000, name="War Axe"},
  176.     {id=7408, sell=1500, name="Wyvern Fang"},
  177.     },
  178.  
  179.     [7] = { -- ench wp
  180.     {id=7866, sell=30000, name="Earth Cranial Basher"},
  181.     {id=7858, sell=15000, name="Earth Dragon Slayer"},
  182.     {id=7862, sell=6000, name="Earth Headchopper"},
  183.     {id=7861, sell=30000, name="Earth Heroic Axe"},
  184.     {id=7856, sell=30000, name="Earth Mystic Blade"},
  185.     {id=7867, sell=6000, name="Earth Orcish Maul"},
  186.     {id=7855, sell=25000, name="Earth Relic Sword"},
  187.     {id=7863, sell=12000, name="Earth War Axe"},
  188.     {id=7881, sell=30000, name="Energy Cranial Basher"},
  189.     {id=7873, sell=15000, name="Energy Dragon Slayer"},
  190.     {id=7877, sell=6000, name="Energy Headchopper"},
  191.     {id=7876, sell=30000, name="Energy Heroic Axe"},
  192.     {id=7871, sell=30000, name="Energy Mystic Blade"},
  193.     {id=7882, sell=6000, name="Energy Orcish Maul"},
  194.     {id=7870, sell=25000, name="Energy Relic Sword"},
  195.     {id=7878, sell=12000, name="Energy War Axe"},
  196.     {id=7756, sell=30000, name="Fiery Cranial Basher"},
  197.     {id=7748, sell=15000, name="Fiery Dragon Slayer"},
  198.     {id=7752, sell=6000, name="Fiery Headchopper"},
  199.     {id=7751, sell=30000, name="Fiery Heroic Axe"},
  200.     {id=7746, sell=30000, name="Fiery Mystic Blade"},
  201.     {id=7757, sell=6000, name="Fiery Orcish Maul"},
  202.     {id=7745, sell=25000, name="Fiery Relic Sword"},
  203.     {id=7753, sell=12000, name="Fiery War Axe"},
  204.     {id=7775, sell=30000, name="Icy Cranial Basher"},
  205.     {id=7767, sell=15000, name="Icy Dragon Slayer"},
  206.     {id=7771, sell=6000, name="Icy Headchopper"},
  207.     {id=7770, sell=30000, name="Icy Heroic Axe"},
  208.     {id=7765, sell=30000, name="Icy Mystic Blade"},
  209.     {id=7776, sell=6000, name="Icy Orcish Maul"},
  210.     {id=7764, sell=25000, name="Icy Relic Sword"},
  211.     {id=7772, sell=12000, name="Icy War Axe"},
  212.     },
  213.  
  214.     [8] = { -- jewelry
  215.     {id=2142, sell=200, name="Ancient Amulet"},
  216.     {id=11374, sell=1500, name="Beetle Necklace"},
  217.     {id=2125, sell=500, name="Crystal Necklace"},
  218.     {id=2124, sell=250, name="Crystal Ring"},
  219.     {id=6300, sell=1000, name="Death Ring"},
  220.     {id=2136, sell=32000, name="Demonbone Amulet"},
  221.     {id=2127, sell=800, name="Emerald Bangle"},
  222.     {id=7888, sell=1500, name="Glacier Amulet"},
  223.     {id=2179, sell=8000, name="Gold Ring"},
  224.     {id=10220, sell=3000, name="Leviathan's Amulet"},
  225.     {id=7889, sell=1500, name="Lightning Pendant"},
  226.     {id=7890, sell=1500, name="Magma Amulet"},
  227.     {id=2171, sell=2500, name="Platinum Amulet"},
  228.     {id=2123, sell=30000, name="Ring of the Sky"},
  229.     {id=2133, sell=2000, name="Ruby Necklace"},
  230.     {id=10219, sell=3000, name="Sacred Tree Amulet"},
  231.     {id=2135, sell=200, name="Scarab Amulet"},
  232.     {id=10221, sell=3000, name="Shockwave Amulet"},
  233.     {id=2134, sell=150, name="Silver Brooch"},
  234.     {id=7887, sell=1500, name="Terra Amulet"},
  235.     },
  236.  
  237.     [9] = { -- misc
  238.     {id=2110, sell=200, name="Doll"},
  239.     {id=5710, sell=300, name="Light Shovel"},
  240.     {id=5810, sell=500, name="Pirate Voodoo Doll"},
  241.     {id=3955, sell=400, name="Voodoo Doll"},
  242.     {id=2079, sell=8000, name="War Horn"},
  243.     }
  244.  
  245.     }
  246. local RashidTypes = {
  247. ["armors"] = 1,
  248. ["legs"] = 2,
  249. ["shields"] = 3,
  250. ["helmets"] = 4,
  251. ["boots"] = 5,
  252. ["weapons"] = 6,
  253. ["enchanted weapons"] = 7,
  254. ["jewelry"] = 8,
  255. ["miscellaneous"] = 9
  256. }
  257.     local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
  258.     for _, item in ipairs(items) do
  259.         items[item.id] = {item_id = item.id, sellPrice = item.sell, subType = 0}
  260.     end
  261.    
  262.         if(subType < 1 or getItemInfo(items[item].item_id).stackable) then
  263.             subType = -1
  264.         end
  265.         if(doPlayerRemoveItem(cid, items[item].item_id, amount, subType, ignoreEquipped)) then
  266.         if amount > 1 then nm = getItemPluralNameById(items[item].item_id) else nm = getItemNameById(items[item].item_id) end
  267.         if amount > 1 then nn = amount else nn = getItemArticleById(items[item].item_id) end
  268.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Sold ' .. nn .. ' ' .. nm .. ' for ' .. amount * items[item].sellPrice .. ' gold.')
  269.             doPlayerAddMoney(cid, amount * items[item].sellPrice)
  270.             return true
  271.         end
  272.     end
  273.     local function TypeWindow()
  274.         openShopWindow(cid, RashidList[RashidTypes[msg]], onBuy, onSell)
  275.     end
  276.  
  277.     local function AllWindow()
  278.         openShopWindow(cid, items, onBuy, onSell)
  279.     end
  280.    
  281.     if talkState[talkUser] == 19 and RashidTypes[msg] ~= null then
  282.         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == ENDSTORAGE then
  283.         closeShopWindow(cid)
  284.         addEvent(TypeWindow, 10, cid)
  285.         selfSay("Here.", cid)
  286.         else
  287.             selfSay("Sorry, but you do not belong to my exclusive customers. I have to make sure that I can trust in the quality of your wares.", cid)
  288.             talkState[talkUser] = 0
  289.         end
  290.     end
  291.     if msgcontains(msg, 'trade') or msgcontains(msg, 'offer') then
  292.         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == ENDSTORAGE then
  293.         items = {}
  294.         for i=1, #RashidList do
  295.         for k,v in pairs(RashidList[i]) do
  296.             table.insert(items,v)
  297.         end
  298.         end
  299.                 closeShopWindow(cid)
  300.                 addEvent(AllWindow, 10, cid)
  301.                 selfSay("Of course, old friend. You can also browse only {armors}, {legs}, {shields}, {helmets}, {boots}, {weapons}, {enchanted weapons}, {jewelry} or {miscellaneous} stuff.", cid)
  302.                 talkState[talkUser] = 19
  303.         else
  304.                 selfSay("Sorry, but you do not belong to my exclusive customers. I have to make sure that I can trust in the quality of your wares.", cid)
  305.                 talkState[talkUser] = 0
  306.         end
  307.     end
  308.    
  309.     -- mission handler begins here
  310.     if msgcontains(msg, "no")then
  311.         selfSay("Then stop wasting my time!", cid)
  312.         talkState[talkUser] = 0
  313.         npcHandler:releaseFocus(cid)
  314.     end
  315.     if msgcontains(msg, "yes") then
  316.         if talkState[talkUser] == 18 then
  317.             if doPlayerRemoveItem(cid,5929,1) then
  318.                 selfSay("Thank you!! Ah, this makes my day! I'll take the rest of the day off to get to know this little guy. Come see me tomorrow, if you like.", cid)
  319.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 12)
  320.             else
  321.                 selfSay("This is not funny. Fulfill your promise or get out of my eyes!", cid)
  322.             end
  323.             talkState[talkUser] = 0
  324.             npcHandler:releaseFocus(cid)
  325.         elseif talkState[talkUser] == 17 then
  326.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 11)
  327.             selfSay("Thanks so much! I'll be waiting eagerly for your return then.", cid)
  328.             talkState[talkUser] = 0
  329.             npcHandler:releaseFocus(cid)
  330.         elseif talkState[talkUser] == 16 then
  331.         talkState[talkUser] = 17
  332.             npcHandler:say("My friend, it seems you have already learnt a lot about the art of trading. I think you are more than worthy to become a recognised trader. ...", cid)
  333.             npcHandler:say("There is just one little favour that I would ask from you... something personal, actually, forgive my boldness. ...", cid, 8000)
  334.             npcHandler:say("I have always dreamed to have a small pet, one that I could take with me and which wouldn't cause problems. ...", cid, 13000)
  335.             npcHandler:say("Could you - just maybe - bring me a small goldfish in a bowl? I know that you would be able to get one, wouldn't you?", cid, 17000)
  336.         elseif talkState[talkUser] == 15 then
  337.             if doPlayerRemoveItem(cid,8209,1) then
  338.                 selfSay("Ha! You are clever indeed, well done! I'll take this from you. Come see me tomorrow, I think we two might get into business after all.", cid)
  339.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 10)
  340.             else
  341.                 if getPlayerItemCount(cid, 11395) > 0 then
  342.                     selfSay("I don't even want to know what happend there. This quality is awful. Go to Uzgod and try again.", cid)
  343.                 else
  344.                     if getPlayerItemCount(cid, 7385) > 0 then
  345.                         selfSay("You paid too much for this one! Try again and remember that you may spend only 400 gold on it.", cid)
  346.                     else
  347.                         selfSay("It seems you lost it. Go and get another one!", cid)
  348.                     end
  349.                 end
  350.             end
  351.             talkState[talkUser] = 0
  352.             npcHandler:releaseFocus(cid)
  353.         elseif talkState[talkUser] == 14 then
  354.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 9)
  355.             doCreatureSetStorage(cid, Uzgod_storage[1], Uzgod_storage[2])
  356.             selfSay("Okay, I'm curious how you will do with Uzgod. Good luck!", cid)
  357.             talkState[talkUser] = 0
  358.             npcHandler:releaseFocus(cid)
  359.         elseif talkState[talkUser] == 13 then
  360.         talkState[talkUser] = 14
  361.             npcHandler:say("Fine! There's one more skill that I need to test and which is cruicial for a successful trader. ...", cid)
  362.             npcHandler:say("Of course you must be able to haggle, else you won't survive long in this business. To make things as hard as possible for you, I have the perfect trade partner for you. ...", cid, 8000)
  363.             npcHandler:say("Dwarves are said to be the most stubborn of all traders. Travel to {Kazordoon} and try to get the smith Uzgod to sell a crimson sword to you. ...", cid, 13000)
  364.             npcHandler:say("Of course, it has to be cheap. Don't come back with anything more expensive than 400 gold. ...", cid, 17000)
  365.             npcHandler:say("And the quality must not suffer, of course! Everything clear and understood?", cid, 21000)
  366.         elseif talkState[talkUser] == 12 then
  367.             if doPlayerRemoveItem(cid,7582,1) then
  368.                 selfSay("I'm surprised that you managed to bring this vase without a single crack. That was what I needed to know, thank you.", cid)
  369.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 8)
  370.             else
  371.                 selfSay("It seems you lost it. Go and get another one!", cid)
  372.             end
  373.             talkState[talkUser] = 0
  374.             npcHandler:releaseFocus(cid)
  375.         elseif talkState[talkUser] == 11 then
  376.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 7)
  377.             doCreatureSetStorage(cid, Briasol_storage[1], Briasol_storage[2])
  378.             selfSay("Okay, then please find Briasol in {Ab'Dendriel} and ask for a 'fine vase'.", cid)
  379.             talkState[talkUser] = 0
  380.             npcHandler:releaseFocus(cid)
  381.         elseif talkState[talkUser] == 10 then
  382.         talkState[talkUser] = 11
  383.             npcHandler:say("Well, that's good to hear. From you as my trader and deliveryman, I expect more than bringing stinky cheese. ...", cid)
  384.             npcHandler:say("I wonder if you are able to deliver goods so fragile they almost break when looked at. ...", cid, 6000)
  385.             npcHandler:say("I have ordered a special elven vase from Briasol in Ab'Dendriel. Get it from him and don't even touch it, just bring it to me while I'm in Ankrahmun. Everything clear and understood?", cid, 12000)
  386.         elseif talkState[talkUser] == 9 then
  387.             if doPlayerRemoveItem(cid,8112,1) then
  388.                 selfSay("Mmmhh, the lovely odeur of scarab cheese! I really can't understand why most people can't stand it. Thanks, well done!", cid)
  389.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 6)
  390.             else
  391.                 selfSay("This is NOT a scarab cheese! You can't fake its odour.", cid)
  392.             end
  393.             talkState[talkUser] = 0
  394.             npcHandler:releaseFocus(cid)
  395.         elseif talkState[talkUser] == 8 then
  396.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 5)
  397.             doCreatureSetStorage(cid, Miraia_storage[1], Miraia_storage[2])
  398.             selfSay("Okay, then please find Miraia in {Darashia} and ask her about the 'scarab cheese'.", cid)
  399.             talkState[talkUser] = 0
  400.             npcHandler:releaseFocus(cid)
  401.         elseif talkState[talkUser] == 7 then
  402.         talkState[talkUser] = 8
  403.             npcHandler:say("Well, that's good to hear. From you as my trader and deliveryman, I expect more than carrying heavy packages. ...", cid)
  404.             npcHandler:say("You also need to be fast and deliver wares in time. I have ordered a very special cheese wheel made from Darashian milk. ...", cid, 8000)
  405.             npcHandler:say("Unfortunately, the high temperature in the desert makes it rot really fast, so it must not stay in the sun for too long. ...", cid, 15000)
  406.             npcHandler:say("I'm also afraid that you might not be able to use ships because of the smell of the cheese. ...", cid, 19000)
  407.             npcHandler:say("Please get the cheese from {Miraia} and bring it to me while I'm in {Port Hope}. Everything clear and understood?", cid, 25000)
  408.         elseif talkState[talkUser] == 6 then
  409.             if doPlayerRemoveItem(cid,7503,1) then
  410.                 selfSay("Great. Just place it over there - yes, thanks, that's it. Come see me another day, I'll be busy for a while now.", cid)
  411.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 4)
  412.             else
  413.                 selfSay("Then find Willard and ask him for 'package for Rashid'. I'll be busy for a while now.", cid)
  414.             end
  415.             talkState[talkUser] = 0
  416.             npcHandler:releaseFocus(cid)
  417.         elseif talkState[talkUser] == 5 then
  418.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 3)
  419.             doCreatureSetStorage(cid, Willard_storage[1], Willard_storage[2])
  420.             selfSay("Fine. Then off you go, just ask {Willard} about the 'package for Rashid'.", cid)
  421.             talkState[talkUser] = 0
  422.             npcHandler:releaseFocus(cid)
  423.         elseif talkState[talkUser] == 4 then
  424.         talkState[talkUser] = 5
  425.             npcHandler:say("Alright, that's good to hear. From you as my trader and deliveryman, I expect more than finding rare items. ...", cid)
  426.             npcHandler:say("You also need to be able to transport heavy wares, weaklings won't get far here. I have ordered a special package from {Edron}. ...", cid, 8000)
  427.             npcHandler:say("Pick it up from Willard and bring it back to me while I'm in Liberty Bay. Everything clear and understood?", cid, 15000)
  428.         elseif talkState[talkUser] == 3 then
  429.             if doPlayerRemoveItem(cid,7397,1) then
  430.                 selfSay("Well done! I'll take that from you. <snags it> Come see me another day, I'll be busy for a while now.", cid)
  431.                 doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 2)
  432.             else
  433.                 selfSay("Stop wasting my time, I am busy person.", cid)
  434.             end
  435.             talkState[talkUser] = 0
  436.             npcHandler:releaseFocus(cid)
  437.         elseif talkState[talkUser] == 2 then
  438.             selfSay("Fine. Then get a hold of that {deer trophy} and bring it to me while I'm in {Svargrond}. Just ask me about your {mission}.", cid)
  439.             doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 1)
  440.             talkState[talkUser] = 0
  441.             npcHandler:releaseFocus(cid)
  442.         elseif talkState[talkUser] == 1 then
  443.         talkState[talkUser] = 2
  444.             npcHandler:say("Very good! I need talented people who are able to handle my wares with care, find good offers and the like, so I'm going to test you. ...", cid)
  445.             npcHandler:say("First, I'd like to see if you can dig up rare wares. Something like a ...", cid, 8000)
  446.             npcHandler:say("mastermind shield! ...", cid, 15000)
  447.             npcHandler:say("Haha, just kidding, fooled you there, didn't I? Always control your nerves, that's quite important during bargaining. ...", cid, 19000)
  448.             npcHandler:say("Okay, all I want from you is one of these rare {deer trophies}. I have a customer here in {Svargrond} who ordered one, so I'd like you to deliver it to me while I'm in Svargrond. ...", cid, 25000)
  449.             npcHandler:say("Everything clear and understood?", cid, 32000)
  450.         end
  451.     end
  452.     if msgcontains(msg, "deer") or msgcontains(msg, "trophy") then
  453.         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 1 then
  454.             if getPlayerItemCount(cid, 7397) > 0 then
  455.                 selfSay("Have you managed to obtain a rare deer trophy for my customer?", cid)
  456.                 talkState[talkUser] = 3
  457.             else
  458.                 selfSay("Your mission is to find a deer trophy. I will accept this trophy only on mondays, so hurry up.", cid)
  459.                 talkState[talkUser] = 0
  460.             end
  461.         else
  462.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) < 1 then
  463.                 selfSay("Currently I'm out of them, but if I get any I'll let you know.", cid)
  464.             else
  465.                 selfSay("I don't need any at the moment, old friend. If you want to {trade} other items, just ask me.", cid)           
  466.             end
  467.             talkState[talkUser] = 0
  468.         end
  469.     end
  470.     if msgcontains(msg, "package") then
  471.         if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 2 then
  472.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 3 then
  473.                 selfSay("Did you bring me the package?", cid)
  474.                 talkState[talkUser] = 6
  475.             else
  476.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 2 then
  477.                     selfSay(MSG_MISSION_DONE, cid)
  478.                     talkState[talkUser] = 0
  479.                 else
  480.                     selfSay(MSG_MISSION_WRONG_DAY, cid)
  481.                     talkState[talkUser] = 0
  482.                 end
  483.             end
  484.         end
  485.     end
  486.     if msgcontains(msg, "scarab") or msgcontains(msg, "cheese") then
  487.         if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 3 then
  488.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 5 then
  489.                     selfSay("Have you brought the cheese?", cid)
  490.                     talkState[talkUser] = 9
  491.             else
  492.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 4 then
  493.                     selfSay(MSG_MISSION_DONE, cid)
  494.                     talkState[talkUser] = 0
  495.                 else
  496.                     selfSay(MSG_MISSION_WRONG_DAY, cid)
  497.                     talkState[talkUser] = 0
  498.                 end
  499.             end
  500.         end
  501.     end
  502.     if msgcontains(msg, "vase") then
  503.         if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 4 then
  504.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 7 then
  505.                     selfSay("Have you brought the vase?", cid)
  506.                     talkState[talkUser] = 12
  507.             else
  508.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 6 then
  509.                     selfSay(MSG_MISSION_DONE, cid)
  510.                     talkState[talkUser] = 0
  511.                 else
  512.                     selfSay(MSG_MISSION_WRONG_DAY, cid)
  513.                     talkState[talkUser] = 0
  514.                 end
  515.             end
  516.         end
  517.     end
  518.     if msgcontains(msg, "crimson") or msgcontains(msg, "sword") then
  519.         if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 5 then
  520.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 9 then
  521.                     selfSay("Have you brought a cheap but good crimson sword?", cid)
  522.                     talkState[talkUser] = 15
  523.             else
  524.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 8 then
  525.                     selfSay(MSG_MISSION_DONE, cid)
  526.                     talkState[talkUser] = 0
  527.                 else
  528.                     selfSay(MSG_MISSION_WRONG_DAY, cid)
  529.                     talkState[talkUser] = 0
  530.                 end
  531.             end
  532.         end
  533.     end
  534.     if msgcontains(msg, "fish") or msgcontains(msg, "bowl") then
  535.         if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 6 then
  536.             if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 11 then
  537.                     selfSay("Have you brought me a gold fish??", cid)
  538.                     talkState[talkUser] = 18
  539.             else
  540.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 10 then
  541.                     selfSay(MSG_MISSION_DONE, cid)
  542.                     talkState[talkUser] = 0
  543.                 else
  544.                     selfSay(MSG_MISSION_WRONG_DAY, cid)
  545.                     talkState[talkUser] = 0
  546.                 end
  547.             end
  548.         end
  549.     end
  550.     if msgcontains(msg, "mission") then
  551.         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > ENDSTORAGE then
  552.             selfSay(MSG_QUEST_DONE, cid)
  553.             talkState[talkUser] = 0
  554.         else
  555.             -- MONDAY --
  556.             if getGlobalStorageValue(DAY_GLOBALSTORAGE) == 1 then
  557.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 1 then
  558.                     selfSay(MSG_MISSION_DONE, cid)
  559.                     talkState[talkUser] = 0
  560.                 else
  561.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 1 then
  562.                         selfSay("Have you managed to obtain a rare deer trophy for my customer?", cid)
  563.                         talkState[talkUser] = 3
  564.                     else
  565.                         selfSay("Well, you could attempt the mission to become a recognised trader, but it requires a lot of travelling. Are you willing to try?", cid)
  566.                         talkState[talkUser] = 1
  567.                     end
  568.                 end
  569.             -- TUESDAY --              
  570.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 2 then
  571.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 3 then
  572.                     selfSay("Did you bring me the package?", cid)
  573.                     talkState[talkUser] = 6
  574.                 else
  575.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 2 then
  576.                             selfSay(MSG_MISSION_NEXT, cid)
  577.                             talkState[talkUser] = 4
  578.                     else
  579.                         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 2 then
  580.                             selfSay(MSG_MISSION_DONE, cid)
  581.                             talkState[talkUser] = 0
  582.                         else
  583.                             selfSay(MSG_MISSION_WRONG_DAY, cid)
  584.                             talkState[talkUser] = 0
  585.                         end
  586.                     end
  587.                 end
  588.             -- WEDNESDAY --
  589.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 3 then
  590.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 5 then
  591.                     selfSay("Have you brought the cheese?", cid)
  592.                     talkState[talkUser] = 9
  593.                 else
  594.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 4 then
  595.                             selfSay(MSG_MISSION_NEXT, cid)
  596.                             talkState[talkUser] = 7
  597.                     else
  598.                         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 4 then
  599.                             selfSay(MSG_MISSION_DONE, cid)
  600.                             talkState[talkUser] = 0
  601.                         else
  602.                             selfSay(MSG_MISSION_WRONG_DAY, cid)
  603.                             talkState[talkUser] = 0
  604.                         end
  605.                     end
  606.                 end
  607.             -- THURSDAY --
  608.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 4 then
  609.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 7 then
  610.                     selfSay("Have you brought the vase?", cid)
  611.                     talkState[talkUser] = 12
  612.                 else
  613.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 6 then
  614.                             selfSay(MSG_MISSION_NEXT, cid)
  615.                             talkState[talkUser] = 10
  616.                     else
  617.                         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 6 then
  618.                             selfSay(MSG_MISSION_DONE, cid)
  619.                             talkState[talkUser] = 0
  620.                         else
  621.                             selfSay(MSG_MISSION_WRONG_DAY, cid)
  622.                             talkState[talkUser] = 0
  623.                         end
  624.                     end
  625.                 end
  626.             -- FRIDAY --
  627.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 5 then
  628.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 9 then
  629.                     selfSay("Have you brought a cheap but good crimson sword?", cid)
  630.                     talkState[talkUser] = 15
  631.                 else
  632.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 8 then
  633.                             selfSay(MSG_MISSION_NEXT, cid)
  634.                             talkState[talkUser] = 13
  635.                     else
  636.                         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 8 then
  637.                             selfSay(MSG_MISSION_DONE, cid)
  638.                             talkState[talkUser] = 0
  639.                         else
  640.                             selfSay(MSG_MISSION_WRONG_DAY, cid)
  641.                             talkState[talkUser] = 0
  642.                         end
  643.                     end
  644.                 end
  645.             -- SATURDAY --
  646.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 6 then
  647.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 11 then
  648.                     selfSay("Have you brought me a gold fish??", cid)
  649.                     talkState[talkUser] = 18
  650.                 else
  651.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 10 then
  652.                             selfSay(MSG_MISSION_NEXT, cid)
  653.                             talkState[talkUser] = 16
  654.                     else
  655.                         if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 10 then
  656.                             selfSay(MSG_MISSION_DONE, cid)
  657.                             talkState[talkUser] = 0
  658.                         else
  659.                             selfSay(MSG_MISSION_WRONG_DAY, cid)
  660.                             talkState[talkUser] = 0
  661.                         end
  662.                     end
  663.                 end
  664.             -- SUNDAY --
  665.             elseif getGlobalStorageValue(DAY_GLOBALSTORAGE) == 7 then
  666.                 if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) == 12 then
  667.                         selfSay("Ah, right. <ahem> I hereby declare you - one of my recognised traders! Feel free to offer me your wares!", cid)
  668.                         doCreatureSetStorage(cid, TRADE_PLAYERSTORAGE, 13)
  669.                         -- if your server uses achievement system place recognised trader achievement here
  670.                 else
  671.                     if getCreatureStorage(cid, TRADE_PLAYERSTORAGE) > 12 then
  672.                         selfSay(MSG_MISSION_DONE, cid)
  673.                     else
  674.                         selfSay(MSG_MISSION_WRONG_DAY, cid)
  675.                     end
  676.                 end
  677.                 talkState[talkUser] = 0
  678.             else
  679.                 selfSay(MSG_MISSION_WRONG_DAY .. " I don't even know what day is it. Please report that issue to server administrator.", cid)
  680.                 print("\n[Warning - " .. getCreatureName(getNpcId()) .. "] RashidHandler: Wrong global storage! \nRashidHandler wasn't installed or is disabled! \nIt's impossible to do The Travelling Trader Quest now!")
  681.             end
  682.         end
  683.     end
  684.     -- mission handler ends here
  685.     return true
  686. end
  687.  
  688. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  689. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  690. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement