Hey im using tfs 1.3 and used some of the scripts on forum but i cant solve thing to count monsters there.
Quest works ok it proceeds to killing and doesnt count monsters when i kill them.
Here is npc:
and here is the creatures xml and script;
Quest works ok it proceeds to killing and doesnt count monsters when i kill them.
Here is npc:
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
local storage = 5002
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, "mission") then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("I have a mission for you to kill 15 Skeletons and 3 Skeleton Warriors, do you accept?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you kill 15 Skeletons and 3 Skeleton Warriors?", cid)
talkState[talkUser] = 1
else
selfSay("You already did the mission.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Good, come back when you killed them.", cid)
setPlayerStorageValue(cid, storage, 1)
else
if getPlayerStorageValue(cid, 19000) == 15 and getPlayerStorageValue(cid, 19001) == 3 then
selfSay("Good job, here is your reward.", cid)
doPlayerAddItem(cid, 2195, 1)
doPlayerAddExp(cid, 50000)
setPlayerStorageValue(cid, storage, 2)
else
selfSay("You didn't kill them all.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and here is the creatures xml and script;
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua" />
<event type="logout" name="PlayerLogout" script="logout.lua" />
<event type="login" name="FirstItems" script="firstitems.lua" />
<event type="login" name="OfflineTraining" script="offlinetraining.lua" />
<event type="login" name="RegenerateStamina" script="regeneratestamina.lua" />
<event type="death" name="PlayerDeath" script="playerdeath.lua" />
<event type="death" name="DropLoot" script="droploot.lua" />
<event type="extendedopcode" name="ExtendedOpcode" script="extendedopcode.lua" />
<event type="login" name="UpgradeSystemLogin" script="upgrade_system_cs.lua" />
<event type="death" name="UpgradeSystemDeath" script="upgrade_system_cs.lua" />
<event type="kill" name="UpgradeSystemKill" script="upgrade_system_cs.lua" />
<event type="healthchange" name="UpgradeSystemHealth" script="upgrade_system_cs.lua" />
<event type="manachange" name="UpgradeSystemMana" script="upgrade_system_cs.lua" />
<event type="preparedeath" name="UpgradeSystemPD" script="upgrade_system_cs.lua" />
<event type="death" name="extra_loot_d" script="extra_loot.lua"/>
<event type="kill" name="skeleton" script="skeleton.lua" />
</creaturescripts>
Lua:
local config = {
['Skeleton'] = {amount = 15, storage = 19000, startstorage = 5002, startvalue = 1},
['Skeleton Warrior'] = {amount = 3, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
end
if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
return true
end