Landera
Veteran OT User
- Joined
- Nov 24, 2011
- Messages
- 905
- Solutions
- 1
- Reaction score
- 318
Good evening,
This evening i was struggling with my NPC file and after I succesfully added the items and 3 items to choose from I've hit a solid wall.
I cant figure out to put a storage on it, so the player can only do this once and can only pick the one weapon he choose from.
WARNING I'm not a great scripter so the code can look messy
This evening i was struggling with my NPC file and after I succesfully added the items and 3 items to choose from I've hit a solid wall.
I cant figure out to put a storage on it, so the player can only do this once and can only pick the one weapon he choose from.
WARNING I'm not a great scripter so the code can look messy
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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
elseif msgcontains(msg, 'job') or msgcontains(msg, 'mission') then
npcHandler:say('I keep an eye on the armory, and {weaponry} so people won\'t just grab what they want.', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'weaponry') or msgcontains(msg, 'weapon') then
npcHandler:say('I could gift you an {sword}, {axe} or a {club} weapon if you gather some {items} for me so I can see ur worthy enough.', cid)
Topic[cid] = nil
elseif msgcontains(msg, 'items') or msgcontains(msg, 'item') then
npcHandler:say('I need the following items five cyclops toes, five wolf paws and a battle shield, you can only pick one reward.', cid)
Topic[cid] = nil
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'sword') then
if getPlayerItemCount(cid,10574) >= 5 and getPlayerItemCount(cid,5897) >= 5 and getPlayerItemCount(cid,2513) >= 1 then
if doPlayerRemoveItem(cid,10574,5) and doPlayerRemoveItem(cid,5897,5) and doPlayerRemoveItem(cid,2513,1) then
npcHandler:say('Oh, that\'s amazing! Please take this as reward!', cid)
doPlayerAddItem(cid, 8602, 1)
setPlayerStorageValue(cid, 8602, 1)
end
else
npcHandler:say('You don\'t have all the required items.', cid)
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'axe') then
if getPlayerItemCount(cid,10574) >= 5 and getPlayerItemCount(cid,5897) >= 5 and getPlayerItemCount(cid,2513) >= 1 then
if doPlayerRemoveItem(cid,10574,5) and doPlayerRemoveItem(cid,5897,5) and doPlayerRemoveItem(cid,2513,1) then
npcHandler:say('Oh, that\'s amazing! Please take this as reward!', cid)
doPlayerAddItem(cid, 8601, 1)
setPlayerStorageValue(cid, 8602, 1)
end
else
npcHandler:say('You don\'t have all the required items.', cid)
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'club') then
if getPlayerItemCount(cid,10574) >= 5 and getPlayerItemCount(cid,5897) >= 5 and getPlayerItemCount(cid,2513) >= 1 then
if doPlayerRemoveItem(cid,10574,5) and doPlayerRemoveItem(cid,5897,5) and doPlayerRemoveItem(cid,2513,1) then
npcHandler:say('Oh, that\'s amazing! Please take this as reward!', cid)
doPlayerAddItem(cid, 2439, 1)
setPlayerStorageValue(cid, 8602, 1)
end
else
npcHandler:say('You don\'t have all the required items.', cid)
end
Topic[cid] = nil
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())