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
- -- [[ START THE SETTINGS ]] ---
- local knives = {
- ["name1"] = {id = xxxx, tradeid = 2152, tradecount = 10},
- ["name2"] = {id = xxxx, tradeid = xxxx, tradecount = 100},
- ["name3"] = {id = xxxx, tradeid = xxxx, tradecount = 100},
- }
- -- [[ END FROM SETTINGS THINGS ]] ---
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- knife = knives[""..msg..""]
- if knife then
- selfSay('You really wanna trade '..knife.tradecount..' '..getItemNameById(knife.tradeid)..' for a '..msg..'?', cid)
- talkState[talkUser] = 1
- -- [[ CONFIRMANDO BROADCASTMESSAGES ]] --
- elseif talkState[talkUser] == 1 then
- if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
- if getPlayerItemCount(cid, knife.tradeid) >= knife.tradecount then
- doPlayerRemoveItem(cid, knife.tradeid, knife.tradecount)
- doPlayerAddItem(cid, knife.id, 1)
- selfSay('Here are your item.', cid)
- talkState[talkUser] = 0
- else
- selfSay('Sorry, but you don\'t have '..knife.tradecount..' '..getItemNameById(knife.tradeid)..'s.', cid)
- talkState[talkUser] = 0
- end
- else
- selfSay('Okay, see u later.', cid)
- talkState[talkUser] = 0
- end
- else
- local str = ''
- for index, result in pairs(knives) do
- str = str.."{"..index.."}, "
- end
- selfSay('Sorry, but have to say a knife name: '..str..'.', cid)
- talkState[talkUser] = 0
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment