Jpstafe
Well-Known Member
- Joined
- Aug 8, 2011
- Messages
- 505
- Reaction score
- 67
hello otland community .. my task system, the last one who kills the monster kills .. only one, not all..
How do I get it to kill everything?
I don't want it to be lasthit .. but for everyone
task.xml
before it was like this:
..function onKill(cid, target, lastHit)..
now i put it;
..function onKill(cid, target, onKill)..
it has not worked..
task.lua
How do I get it to kill everything?
I don't want it to be lasthit .. but for everyone
task.xml
Lua:
<event type="kill" name="KillTask" event="script"><![CDATA[
domodlib('task_func')
function onKill(cid, target, onKill)
if(isMonster(target) == true) then
local n = string.lower(getCreatureName(target))
for race, mob in pairs(tasktabble) do
if getPlayerStorageValue(cid,mob .storage_start) >= 1 then
for i = 1,#mob.monster_race do
if n == mob.monster_race[i] then
local contagem = getPlayerStorageValue(cid, mob.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then return true end
if contagem > mob.count then return true end
if contagem > mob.count then return true end
setPlayerStorageValue(cid, mob.storage, contagem+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,""..(contagem == mob.count and "Congratulations! You finished the task of "..race.."." or "defeated. Total [" .. contagem .. "/" .. mob.count .. "] " .. race .. ".").."")
end
end
end
end
end
return true
end]]></event>
</mod>
before it was like this:
..function onKill(cid, target, lastHit)..
now i put it;
..function onKill(cid, target, onKill)..
it has not worked..
task.lua
Lua:
domodlib('task_func')
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
local msg = string.lower(msg)
if isInArray({"task"}, msg) then
npcHandler:say("Easy, Medium, Hard and Very Hard!", cid)
talkState[talkUser] = 1
elseif isInArray({"easy"}, msg) then
npcHandler:say("Tell me the name of the monster you want to make the task! Dwarfs, Goblins, Humans, Larvas, Minotaurs, Rotworms, Orcs, Pandas, Scarabs, Tarantulas and Trolls", cid)
talkState[talkUser] = 1
elseif isInArray({"medium"}, msg) then
npcHandler:say("Tell me the name of the monster you want to make the task! Ancient Scarabs, Apes, Black Knights, Cyclops, Demon Skeletons, Dragons, Dwarf Guards, Fire Elementals, Giant Spiders, Heros, Necromancers, Orc Warlords, Terror Birds And Vampires", cid)
talkState[talkUser] = 1
elseif isInArray({"hard"}, msg) then
npcHandler:say("Tell me the name of the monster you want to make the task! Behemoths, Dragon Lords, Demons, Hydras, Serpent Spawns, warlocks!", cid)
talkState[talkUser] = 1
elseif isInArray({"very hard"}, msg) then
npcHandler:say("Tell me the name of the monster you want to make the task! Betrayed Wraiths, Blightwalkers, Dark Torturers, Defilers, Destroyers, Diabolic Imps, Hand of Cursed Fates, Hellhounds, Hellfire Fighters, Juggernauts, Lost Souls, Nightmares, Plaguesmiths, Son of Verminors, Undead Dragons, ", cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if tasktabble[msg] then
if CheckTask(cid) ~= true then
local contagem = getPlayerStorageValue(cid, tasktabble[msg].storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('Sorry, but you have already finished the task of '..msg, cid) return true end
setPlayerStorageValue(cid, tasktabble[msg].storage_start, 1)
npcHandler:say("Congratulations, you are now participating in the mission of the task "..msg..", lack kill "..string.sub(((contagem)-1)-tasktabble[msg].count, 2).." "..msg, cid)
talkState[talkUser] = 0
else
npcHandler:say('Sorry, but you are already part of a task!', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('enter the correct name of the task mission!', cid)
talkState[talkUser] = 1
end
elseif isInArray({"receber","reward","recompensa","report","reportar","receiver"}, msg) then
if CheckTask(cid) then
for k, v in pairs(tasktabble) do
racetype = k
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
if not tonumber(contagem) then npcHandler:say('you can only get items once!', cid) return true end
if (((contagem)-1) >= v.count) then
for _, check in pairs(configbosses_task) do
if string.lower(check.race) == string.lower(racetype) then
local on = getPlayersOnline()
for i=1, #on do
if HavePlayerPosition(on[i], check.FromPosToPos[1],check.FromPosToPos[2]) then
selfSay('wait a moment, there are people doing the task.', cid) return true
end
end
doTeleportThing(cid, check.Playerpos)
local function checkArea(cid)
if not isCreature(cid) then return LUA_ERROR end
if HavePlayerPosition(cid, check.FromPosToPos[1],check.FromPosToPos[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
addEvent(checkArea, check.time*60*1000, cid)
end
end
local str = ""
if v.exp ~= nil then doPlayerAddExp(cid, v.exp ) str = str.."".. (str == "" and "" or ",") .." "..v.exp.." of experience" end
if v.money ~= nil then doPlayerAddMoney(cid, v.money) str = str.."".. (str == "" and "" or ",") ..""..v.money.." Golds" end
if v.reward ~= nil then doAddItemsFromList(cid,v.reward) str = str.."".. (str == "" and "" or ",") ..""..getItemsFromList(v.reward) end
npcHandler:say("Thanks for your help Rewards: "..(str == "" and "any" or ""..str.."").." for completing the task of "..k, cid)
setPlayerStorageValue(cid, v.storage, "Finished")
setPlayerStorageValue(cid, v.storage_start, 0)
setPlayerStorageValue(cid, v.storage_site, 1)
setPlayerStorageValue(cid, 521456, getPlayerStorageValue(cid, 521456) == -1 and 1 or getPlayerStorageValue(cid, 521456)+1)
finisheAllTask(cid)
else
npcHandler:say('Sorry, but you just killed '..((contagem)-1)..' of '..v.count..' '..k, cid)
end
end
end
else
npcHandler:say("you're not on any mission task", cid)
end
elseif isInArray({"sair","leave","exit"}, msg) then
if CheckTask(cid) then
talkState[talkUser] = 2
for k, v in pairs(tasktabble) do
if getPlayerStorageValue(cid,v.storage_start) >= 1 then
storagesair = v.storage_start
storagezerar = v.storage
local contagem = getPlayerStorageValue(cid, v.storage)
if (contagem == -1) then contagem = 1 end
npcHandler:say('you are participating in a task mission '..k..' and has already '..((contagem)-1)..' '..k..' dead, want to quit?', cid)
end
end
else
npcHandler:say("you're not on any mission task", cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
setPlayerStorageValue(cid, storagesair, 0)
setPlayerStorageValue(cid, storagezerar, 1)
npcHandler:say("You have been removed from the task successfully!", cid)
elseif msg == "no" then
selfSay("then alright", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())