xardas33
New Member
- Joined
- Jan 28, 2010
- Messages
- 83
- Reaction score
- 0
Hello. I need to edit this script, NPC should sell me key with action id (in this situation i need action ID = 4600)
Here is full script:
And here is part with key buying:
Here is full script:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
npcHandler:addModule(FocusModule:new())
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local first = {
useExpReward = false,
}
if(msgcontains(msg, 'present')) then
if getPlayerStorageValue(cid,1004) <= 0 then
selfSay("Do you wanna give me present?", cid)
talkState[talkUser] = 1
else
setPlayerStorageValue(cid,1004,1)
selfSay("You already gave me present.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerStorageValue(cid,1004) <= 0 then
if getPlayerItemCount(cid,1990) >= 1 then
if(doPlayerRemoveItem(cid,1990,1)) then
selfSay("Good work, now you can take this.", cid)
doPlayerAddItem(cid,2480,1)
setPlayerStorageValue(cid,1004,1)
talkState[talkUser] = 0
elseif(useExpReward) then
doPlayerAddExperience(cid,0)
end
else
getPlayerItemCount(cid,1990,0)
selfSay("I really need present.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay("Back when you have it.", cid)
talkState[talkUser] = 0
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'key')) then
if getPlayerStorageValue(cid,55002) <= 0 then
selfSay("I can sell you key to arena under our city. Can you pay me 5 gp for it?", cid)
talkState[talkUser] = 2
else
setPlayerStorageValue(cid,55002,1)
selfSay("I sold you my key, I don't have more.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if getPlayerStorageValue(cid,55002) <= 0 then
if getPlayerItemCount(cid,2148) >= 5 then
if(doPlayerRemoveItem(cid,2148,5)) then
selfSay("Here you are.", cid)
doPlayerAddItem(cid,2088,1)
setPlayerStorageValue(cid,55002,-1)
talkState[talkUser] = 0
elseif(useExpReward) then
doPlayerAddExperience(cid,0)
end
else
getPlayerItemCount(cid,2148,0-4)
selfSay("You need more money.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 2) then
selfSay("Okey.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
And here is part with key buying:
Code:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'key')) then
if getPlayerStorageValue(cid,55002) <= 0 then
selfSay("I can sell you key to arena under our city. Can you pay me 5 gp for it?", cid)
talkState[talkUser] = 2
else
setPlayerStorageValue(cid,55002,1)
selfSay("I sold you my key, I don't have more.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if getPlayerStorageValue(cid,55002) <= 0 then
if getPlayerItemCount(cid,2148) >= 5 then
if(doPlayerRemoveItem(cid,2148,5)) then
selfSay("Here you are.", cid)
doPlayerAddItem(cid,2088,1)
setPlayerStorageValue(cid,55002,-1)
talkState[talkUser] = 0
elseif(useExpReward) then
doPlayerAddExperience(cid,0)
end
else
getPlayerItemCount(cid,2148,0-4)
selfSay("You need more money.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 2) then
selfSay("Okey.", cid)
talkState[talkUser] = 0
end