Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local talkState = {}
- function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
- function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
- function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
- function onThink() npcHandler:onThink() end
- local items = {[1] = {5878, 100}, [2] = {5876, 50}}
- local exp = 5000
- local function getLeftItems(cid,tablem)
- local text = ""
- for i = 1,#tablem do
- if i == 1 then
- text = ""..text.." "..tablem[i][2] - getPlayerItemCount(cid, tablem[i][2]).." "..getItemNameById(tablem[i][1]).."."
- elseif i > 1 then
- text = ""..text.." and "..tablem[i][2] - getPlayerItemCount(cid, tablem[i][2]).." "..getItemNameById(tablem[i][1]).."."
- elseif i == #tablem then
- text = ""..text.." and "..tablem[i][2] - getPlayerItemCount(cid, tablem[i][2]).." "..getItemNameById(tablem[i][1]).."."
- end
- end
- return text
- end
- local function getItemsFromTable(cid,tablem)
- local text = ""
- for i = 1,#tablem do
- if i == 1 then
- text = ""..text.." "..tablem[i][2].."x "..getItemNameById(tablem[i][1])..""
- elseif i > 1 then
- text = ""..text.." and "..tablem[i][2].."x "..getItemNameById(tablem[i][1])..""
- elseif i == #tablem then
- text = ""..text.." and "..tablem[i][2].."x "..getItemNameById(tablem[i][1]).."."
- end
- doPlayerAddItem(cid,tablem[i][1],tablem[i][2])
- end
- return text
- end
- local function hasItems(cid,tablem)
- for i = 1,#tablem do
- if getPlayerItemCount(cid, tablem[i][1]) >= tablem[i][2] then
- return true
- end
- end
- return false
- end
- local function RemoveCollected(cid,tablem)
- local text = ""
- for i = 1,#tablem do
- doPlayerRemoveItem(cid, tablem[i][1], tablem[i][2])
- end
- return true
- end
- local function getItemsFromTable2(cid,tablem)
- local text = ""
- for i = 1,#tablem do
- if i == 1 then
- text = ""..text.." "..tablem[i][2].."x "..getItemNameById(tablem[i][1])..""
- elseif i > 1 then
- text = ""..text.." and "..tablem[i][2].."x "..getItemNameById(tablem[i][1])..""
- elseif i == #tablem then
- text = ""..text.." and "..tablem[i][2].."x "..getItemNameById(tablem[i][1]).."."
- end
- end
- return text
- end
- function creatureSayCallback(cid, type, msg)
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- if not npcHandler:isFocused(cid) then
- return false
- end
- local t = 0
- if msgcontains(msg, 'mission') then
- selfSay("So You Are The Guy Who Wana pass through that Door??", cid)
- talkState[talkUser] = 1
- elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
- if getPlayerStorageValue(cid, 5027) <= 0 then
- if getPlayerLevel(cid) >= 1100000 then
- selfSay("First You Have To Prove Yourself By Collecting this", cid)
- talkState[talkUser] = 2
- else
- selfSay("I Know you Have must Courage.. but you need to be level 1100000 to get the quest.", cid)
- end
- elseif getPlayerStorageValue(cid, 5027) > 0 and hasItems(cid,items) then
- RemoveCollected(cid,items)
- doPlayerSetStorageValue(cid, 5027, 2)
- doPlayerAddExperience(cid, exp)
- selfSay("You Are Now Allowed to Pass Through the Door..",cid)
- elseif getPlayerStorageValue(cid, 5027) > 0 and not hasItems(cid,items) then
- selfSay("you still need "..getLeftItems(cid,items)..".",cid)
- elseif getPlayerStorageValue(cid, 5027) > 1 then
- selfSay("This Mission is already Done",cid)
- end
- elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
- doPlayerSetStorageValue(cid, 5027,1)
- selfSay("Here is what you need to collect so i can make you a key",cid)
- selfSay(""..getItemsFromTable2(cid,items).."",cid)
- elseif msgcontains(msg, 'done') then
- if hasItems(cid,items) then
- RemoveCollected(cid,items)
- doPlayerAddExperience(cid, exp)
- doPlayerSetStorageValue(cid, 5027, 2)
- selfSay("You Are Now Allowed to Pass Through the Door..",cid)
- else
- selfSay("you still need "..getLeftItems(cid,items)..".",cid)
- end
- end
- return true
- end
- npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
- npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye? I guess...")
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement