sharpy
New Member
- Joined
- Jan 4, 2010
- Messages
- 77
- Reaction score
- 0
alright so heres the script im trying to make (keep in mind im not good at all at scripting)
ive edited this script from another npc script and i keep getting all kinds of different errors
i need this npc to give you and item with a unique id when you say quest and also need him to give a reward for bringing him back 5x of an item (item with uid is small axe (2559) and uid (10102) and the item to bring him is ancient rune (2348)) if someone could help me out with this i would appreciate it very much.
ive edited this script from another npc script and i keep getting all kinds of different errors
i need this npc to give you and item with a unique id when you say quest and also need him to give a reward for bringing him back 5x of an item (item with uid is small axe (2559) and uid (10102) and the item to bring him is ancient rune (2348)) if someone could help me out with this i would appreciate it very much.
Lua:
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
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, 'quest') or msgcontains(msg, 'mission')) then
selfSay('Do you want to help me by doing me a favor?', cid)
talkState[talkUser] = 1
end
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
doPlayerAddItem(cid, 2559, 1, 10102)
selfSay('Here take this axe and bring me back five ancient runes.', cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
end
elseif(msgcontains(msg, 'anchient runes') then
selfSay('Do you have five anchient runes for me?', cid)
talkState[talkUser] = 2
end
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser]== 2) then
if(getPlayerItemCount(cid, 2348) >= 5) then
doPlayerRemoveItem(cid, 2348, 5)
selfSay('thank you for helping me here is your reward.', cid)
doPlayerAddItem(cid, 2160, 1)
elseif(getplayerItemCount(cid, 2348) < 5) then
selfsay('You do not have enough ancient runes.', cid)
talkState[talkuser] = 0
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())