Onizuka
Member
- Joined
- Jul 5, 2008
- Messages
- 2,291
- Reaction score
- 14
i need these 2 scripts put into 1. if possible
thanks ;x
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
item = 'You do not have the required items.'
done = 'Here you are.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'offer') then
selfSay('You can here change some items for {warrior sweat}, {magic sulphur}, {enchanted chicken wing}, {fighting spirit}.', cid)
elseif msgcontains(msg, 'spider silk yarn') then
if getPlayerItemCount(cid,5879) >= 10 then
selfSay('Did you bring me 10 giant spider silks?', cid)
talk_state = 4
else
selfSay('I need {10 giant spider silks}, to give you spider silk yarn. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 4 then
talk_state = 0
if getPlayerItemCount(cid,5879) >= 10 then
if doPlayerRemoveItem(cid,5879,10) == TRUE then
doPlayerAddItem(cid,5886,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'warrior\'s sweat') then
if getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 and getPlayerItemCount(cid,2475) >= 1 then
selfSay('Did you bring me the 4 warrior helmets?', cid)
talk_state = 10
else
selfSay('I need a {4 warrior helmet\'s}, to give you the warrior sweat. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 10 then
talk_state = 0
if getPlayerItemCount(cid,2475) >= 4 then
if doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE and doPlayerRemoveItem(cid,2475,1) == TRUE then
doPlayerAddItem(cid,5885,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'magic sulphur') then
if getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 and getPlayerItemCount(cid,2392) >= 1 then
selfSay('Did you bring me 3 fire swords?', cid)
talk_state = 5
else
selfSay('I need {3 fire sword\'s}, to give you the magic sulpher. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 5 then
talk_state = 0
if getPlayerItemCount(cid,2392) >= 3 then
if doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE and doPlayerRemoveItem(cid,2392,1) == TRUE then
doPlayerAddItem(cid,5904,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'enchanted chicken wing') then
if getPlayerItemCount(cid,2195) >= 1 then
selfSay('Did you bring me boots of haste?', cid)
talk_state = 6
else
selfSay('I need {boots of haste}, to give you the enchanted chicken wing. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 6 then
talk_state = 0
if getPlayerItemCount(cid,2195) >= 1 then
if doPlayerRemoveItem(cid,2195,1) == TRUE then
doPlayerAddItem(cid,5891,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'fighting spirit') then
if getPlayerItemCount(cid,2498) >= 1 and getPlayerItemCount(cid,2498) >= 1 then
selfSay('Did you bring me the 2 Royal Helmets?', cid)
talk_state = 10
else
selfSay('I need a {2 Royal Helmet\'s}, to give you the Fighting Spirit. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 10 then
talk_state = 0
if getPlayerItemCount(cid,2498) >= 2 then
if doPlayerRemoveItem(cid,2498,1) == TRUE and doPlayerRemoveItem(cid,2498,1) == TRUE then
doPlayerAddItem(cid,5884,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('So Leave, LEAVE ME NOW!')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local hasItems = {}
local amuletStatus = 12000
local items = {
[1] = {8264, 1},
[1] = {8263, 1},
[1] = {8262, 1},
[1] = {8265, 1}
}
local wait = {
storage = 12001,
_time = 24 * 3600
}
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
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, 'amulet') and getCreatureStorage(cid, amuletStatus) <= 0) then
selfSay('Do you want me to forge all the amulet pieces?', cid)
talkState[talkUser] = 3
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
hasItems[talkUser] = true
for _, data in ipairs(items) do
if(getPlayerItemCount(cid, data[1]) < data[2]) then
hasItems[talkUser] = false
end
end
if(hasItems[talkUser]) then
for _, data in ipairs(items) do
doPlayerRemoveItem(cid, data[1], data[2])
end
exhaustion.set(cid, wait.storage, wait._time)
doCreatureSetStorage(cid, amuletStatus, 2)
selfSay('Great, come back in 24 hours and ill have the amulet forged.', cid)
else
selfSay('You don\'t have required items.', cid)
end
hasItems[talkUser] = nil
talkState[talkUser] = nil
elseif(msgcontains(msg, 'amulet') and getCreatureStorage(cid, amuletStatus) == 2) then
if(not exhaustion.get(cid, wait.storage)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
doCreatureSetStorage(cid, amuletStatus, 3)
doPlayerAddItem(cid, 8266, 1)
selfSay('Just in time! Your amulet is forged and ready.', cid)
else
selfSay('I need more time.', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())