Mera Mero
Guess Who?
- Joined
- Dec 27, 2014
- Messages
- 417
- Reaction score
- 86
Greeting otlanders ,i've got problem with npc that sell keys with actionid i need this npc to sell more than 1 key and what can i add to make it sell items by trade window? if someone can help me to make it easy config would be nice this is script of npc
and i've got another issue i need to make duration for that key to disappear after X time ,do you know how? TFS 0.3.6
Thanks otlanders
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,
}
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)
doItemSetAttribute(doPlayerAddItem(cid, 2088, 1), 'aid', 3142)
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())
Thanks otlanders
Last edited: