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 cfg = {
- outfit = {nome = "Royalist", sto = 322},
- task = {t = true, key = 00000, value = 1, name = ""},
- itemList = {
- [1] = {id = 2160, count = 10},
- [2] = {id = 2152, count = 15},
- }
- }
- -- [[ 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
- if (msgcontains(msg:lower(), ''..cfg.outfit.nome:lower()..'')) then
- if getPlayerStorageValue(cid, cfg.outfit.sto) < 1 then
- list = getItemList(cid, cfg.itemList)
- if cfg.task.t then
- selfSay('You have completed the '..cfg.task.name..' mission and wanna give me '..list..'?', cid)
- else
- selfSay('You have '..list..' to trade for the '..cfg.outfit.nome..' outfit?', cid)
- end
- talkState[talkUser] = 1
- else
- selfSay('Sorry but you already can wear this outfit.', cid)
- talkState[talkUser] = 0
- end
- elseif talkState[talkUser] == 1 then
- if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
- if cfg.task.t then
- if getPlayerStorageValue(cid, cfg.task.key) >= cfg.task.value then
- ctrl = 0
- for i = 1, #cfg.itemList do
- if getPlayerItemCount(cid, cfg.itemList[i].id) >= cfg.itemList[i].count then
- ctrl = ctrl + 1
- else
- selfSay('I\'m so sorry, but you don\'t have '..cfg.itemList[i].count..' '..getItemNameById(cfg.itemList[i].id)..'.', cid)
- talkState[talkUser] = 0
- return true
- end
- if ctrl == #cfg.itemList then
- for x = 1, #cfg.itemList do
- doPlayerRemoveItem(cid, cfg.itemList[i].id, cfg.itemList[i].count)
- end
- setPlayerStorageValue(cid, cfg.outfit.sto, 1)
- selfSay('Congratulations, now you can wear the '..cfg.outfit.nome..' outfit.', cid)
- talkState[talkUser] = 0
- return true
- end
- end
- else
- selfSay('Sorry, but you don\'t have the '..cfg.task.name..' mission.', cid)
- talkState[talkUser] = 0
- end
- else
- ctrl = 0
- for i = 1, #cfg.itemList do
- if getPlayerItemCount(cid, cfg.itemList[i].id) >= cfg.itemList[i].count then
- ctrl = ctrl + 1
- else
- selfSay('I\'m so sorry, but you don\'t have '..cfg.itemList[i].count..' '..getItemNameById(cfg.itemList[i].id)..'.', cid)
- talkState[talkUser] = 0
- return true
- end
- if ctrl == #cfg.itemList then
- for x = 1, #cfg.itemList do
- doPlayerRemoveItem(cid, cfg.itemList[i].id, cfg.itemList[i].count)
- end
- setPlayerStorageValue(cid, cfg.outfit.sto, 1)
- selfSay('Congratulations, now you can wear the '..cfg.outfit.nome..' outfit.', cid)
- return true
- end
- end
- end
- talkState[talkUser] = 0
- else
- selfSay('Okay, see u later.', cid)
- talkState[talkUser] = 0
- end
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
- -------- [[ FUNCTION SWATT IN LIBRARY ]] --------
- function getItemList(cid, list) -- Retorna Lista de Premiação
- local awardList = ''
- get = list
- for a = 1, #list do
- if (a+1) == #list then
- if list[a].count <= 1 then
- awardList = awardList.."{"..list[a].count.."x "..getItemNameById(list[a].id).."} and "
- else
- awardList = awardList.."{"..list[a].count.."x "..getItemPluralNameById(list[a].id).."} and "
- end
- elseif (a+1) > #list then
- if list[a].count <= 1 then
- awardList = awardList.."{"..list[a].count.."x "..getItemNameById(list[a].id).."}"
- else
- awardList = awardList.."{"..list[a].count.."x "..getItemPluralNameById(list[a].id).."}"
- end
- else
- if list[a].count <= 1 then
- awardList = awardList.."{"..list[a].count.."x "..getItemNameById(list[a].id).."}, "
- else
- awardList = awardList.."{"..list[a].count.."x "..getItemPluralNameById(list[a].id).."}, "
- end
- end
- end
- return awardList
- end
Add Comment
Please, Sign In to add comment