• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

1 kill counting as 3 kills

Doug Stamper

New Member
Joined
May 16, 2018
Messages
2
Reaction score
0
Hey. I've been trying to add a task system to my 7.72 open tibia project, and I'm encountering a problem with the task counter.

I got the task npc working
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="taskhole" script="taskhole.lua" walkinterval="500" floorchange="0">
   <health now="100" max="100"/>
   <look type="130" head="2" body="37" legs="35" feet="47" addons="3"/>
</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 = 5003
local monsters = {
   ["dragons"] = {storage = 5010, mstorage = 19000, amount = 10, exp = 5000, item = {2160, 3}},
   ["dragon lords"] = {storage = 5011, mstorage = 19001, amount = 10, exp = 10000, item = {2160, 10}},
   ["heros"] = {storage = 5012, mstorage = 19002, amount = 10, exp = 8000, item = {2160, 8}},
   ["dwarf guards"] = {storage = 5013, mstorage = 19003, amount = 10, exp = 7000, item = {2160, 7}}
}
function creatureSayCallback(cid, type, msg)
     if npcHandler.focus ~= 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
             local text, n = "",  0
             for k, x in pairs(monsters) do
                 if getPlayerStorageValue(cid, x.storage) == -1 then
                     n = n + 1
                     text = text .. ", "
                     text = text .. ""..x.amount.." {"..k.."}"
                 end
             end
             if n > 1 then
                 npcHandler:say("I have several tasks for you to kill"..text..", which one do you choose?")
                 talkState[talkUser] = 1
             elseif n == 1 then
                 npcHandler:say("I have one last task for you"..text..".")
                 talkState[talkUser] = 1
             else
                 npcHandler:say("You already did the missions.")
             end
         elseif getPlayerStorageValue(cid, storage) == 1 then
             for k, x in pairs(monsters) do
                 if getPlayerStorageValue(cid, x.storage) == 1 then
                     npcHandler:say("Did you kill "..x.amount.." "..k.."?")
                     talkState[talkUser] = 2
                     xmsg = k
                 end
             end
         end
     elseif monsters[msg:lower()] and talkState[talkUser] == 1 then
         if getPlayerStorageValue(cid, monsters[msg:lower()].storage) == -1 then
             npcHandler:say("Good luck, come back when you killed "..monsters[msg:lower()].amount.." "..msg..".")
             setPlayerStorageValue(cid, storage, 1)
             setPlayerStorageValue(cid, monsters[msg:lower()].storage, 1)
         else
            npcHandler:say("You already did the "..msg.." mission.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
         if getPlayerStorageValue(cid, monsters[xmsg].mstorage) == monsters[xmsg].amount then
             npcHandler:say("Good job, here is your reward.")
             doPlayerAddItem(cid, monsters[xmsg].item[1], monsters[xmsg].item[2])
             doPlayerAddExp(cid, monsters[xmsg].exp)
             setPlayerStorageValue(cid, monsters[xmsg].storage, 2)
             setPlayerStorageValue(cid, storage, -1)
         else
             npcHandler:say("You didn't kill them all.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         npcHandler:say("Ok then.")
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I added a task script in creaturescripts.lua called "Dragons"
Lua:
 local config = {
  ['dragon'] = {amount = 10, storage = 19000, startstorage = 5010, startvalue = 1},
  ['dragon lord'] = {amount = 10, storage = 19001, startstorage = 5011, startvalue = 1},
  ['hero'] = {amount = 10, storage = 19002, startstorage = 5012, startvalue = 1},
  ['dwarf guard'] = {amount = 10, storage = 19003, startstorage = 5013, 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 and (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

I added registerCreatureEvent(cid, "Dragons") in login.lua
Lua:
function onLogin(cid)

   local events = {
       "RemoveBlesses", --Register the kill/die event
       "Give_Bag_After_Death", --Register the Give_Bag_After_Death
       "lootMessage", --Register loot message
   }
  
   -- Register events
   for i = 1, #events do
       registerCreatureEvent(cid, events[i])
       registerCreatureEvent(cid, "Dragons")
   end

   -- Register the Stage event
   if getBooleanFromString(getConfigInfo("experience_stages"), false) then
       registerCreatureEvent(cid, "ExpStage")
       checkStageChange(cid)
   end
  
   -- Add a backpack if it is a relogin after a death
   if getPlayerStorageValue(cid, STORAGE_DEATH_BAG) == 1 then
       if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid == 0 and getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) ~= 1 then
           local item_bag = doCreateItemEx(ITEM_BAG, 1)
           doPlayerAddItemEx(cid, item_bag, false, CONST_SLOT_BACKPACK)
       end
       setPlayerStorageValue(cid, STORAGE_DEATH_BAG, -1)
   end

   --Handle character sent to newbie island from main
   if getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) == 1 then
       -- first items
       if (getPlayerSex(cid) == 0) then
           doPlayerAddItem(cid, 2651, 1)
       else
           doPlayerAddItem(cid, 2650, 1) -- jacket
       end
       local club = doCreateItemEx(2382, 1) -- club
       doPlayerAddItemEx(cid, club, true, CONST_SLOT_LEFT)
       local bp = doPlayerAddItem(cid, 1987, 1) -- bag
       doAddContainerItem(bp, 2050, 1) -- torch
       doAddContainerItem(bp, 2674, 2) -- apples
       -- remove house
       local house = House.getHouseByOwner(cid)
       if(house) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
       -- reset storage
       setPlayerStorageValue(cid, getConfigInfo("storage_sendrook"), -1)
   end

   -- Remove blesses if necessary
   if getPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES) == 1 then
       local i = 1
       while i <= 5 do
           doPlayerRemoveBless(cid, i)
           i = i + 1
       end
       setPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES, -1)
   end

   -- Promotes player if necessary
   if(isPremium(cid)) then
       if(getPlayerStorageValue(cid, STORAGE_PROMOTION) == 1 and getPlayerVocation(cid) <= 4) then
           doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
           doPlayerRemoveSkillLossPercent(cid, 30)
           setPlayerStorageValue(cid, STORAGE_PROMOTION, -1)
       end
       if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == 1) then
           setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, -1)
       end
       return true
   end

   -- Player is not premium - remove premium privileges
   if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == -1) then

       -- Change outfit
       local outfit = getCreatureOutfit(cid)
       local lookType = outfit.lookType
       if (getPlayerSex(cid) == 0) then
           if lookType < 136 or lookType > 139 then
               lookType = 136
           end
       else
           if lookType < 128 or lookType > 131 then
               lookType = 128
           end
       end
       doCreatureChangeOutfit(cid, {lookType = lookType, lookHead = outfit.lookHead, lookBody = outfit.lookBody, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet})

       -- Clean house
       local house = House.getHouseByOwner(cid)
       if(house) and getBooleanFromString(getConfigInfo("house_only_premium"), true) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
      
       -- Make sure player moves to free account zone and has a free account temple
       if getPlayerTown(cid) == 11 then -- Rookgaard
           doTeleportThing(cid, getTownTemplePosition(11))
       elseif getPlayerTown(cid) >= 6 and getPlayerTown(cid) <= 9 then -- if player temple is a Premium town
           doPlayerSetTown(cid, 3) -- Thais
           doTeleportThing(cid, getTownTemplePosition(3))
       else
           doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
       end
      
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your premium account expired. You lost your Premium Account privileges.")
       setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, 1)
   end

   -- Remove promotion
   local isPromo = (getPlayerVocation(cid) > 4 and isPremium(cid) == false)
   if(isPromo) then
       doPlayerSetVocation(cid, getPlayerVocation(cid)-4)
       doPlayerRemoveSkillLossPercent(cid, -30)
       setPlayerStorageValue(cid, STORAGE_PROMOTION, 1)
   end

   return true
end

I added <event name="Dragons" type="kill" script="dragons.lua"/> in creaturescripts.xml
XML:
<?xml version="1.0"?>
<creaturescripts>
   <event name="PlayerLogin" type="login" script="login.lua"/>
   <event name="SendLoginInfo" type="login" script="sendlogininfo.lua"/>
   <event name="RemoveBlesses" type="die" script="removeblesses.lua"/>
   <event name="Give_Bag_After_Death" type="die" script="give_bag_after_death.lua"/>
   <event name="ExpStage" type="advance" script="exp_stage.lua"/>
   <event name="ServerRecord" type="login" script="record.lua"/>
   <event name="giveFirstItems" type="login" script="firstitems.lua" />
   <event name="lootMessage" type="kill" script="lootmessage.lua"/>
   <event name="addPremium" type="login" script="freepremium.lua" />
    <event name="Dragons" type="kill" script="dragons.lua"/>
</creaturescripts>


So the problem is that, when trying to complete a task, killing 1 creature in a task will give me 3 kills for the task, like this.
I kill 1 dragon:
1 out of 10 dragons killed.
2 out of 10 dragons killed.
3 out of 10 dragons killed.

Any help would be very much appreciated.
 
Solution
Login.lua, test again !
Lua:
function onLogin(cid)
   local events = {
       "RemoveBlesses", --Register the kill/die event
       "Give_Bag_After_Death", --Register the Give_Bag_After_Death
       "lootMessage", --Register loot message
       "Dragons"
   }
   -- Register events
   for i = 1, #events do
       registerCreatureEvent(cid, events[i])
   end
   -- Register the Stage event
   if getBooleanFromString(getConfigInfo("experience_stages"), false) then
       registerCreatureEvent(cid, "ExpStage")
       checkStageChange(cid)
   end
   -- Add a backpack if it is a relogin after a death
   if getPlayerStorageValue(cid, STORAGE_DEATH_BAG) == 1 then
       if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid == 0 and...
Login.lua, test again !
Lua:
function onLogin(cid)
   local events = {
       "RemoveBlesses", --Register the kill/die event
       "Give_Bag_After_Death", --Register the Give_Bag_After_Death
       "lootMessage", --Register loot message
       "Dragons"
   }
   -- Register events
   for i = 1, #events do
       registerCreatureEvent(cid, events[i])
   end
   -- Register the Stage event
   if getBooleanFromString(getConfigInfo("experience_stages"), false) then
       registerCreatureEvent(cid, "ExpStage")
       checkStageChange(cid)
   end
   -- Add a backpack if it is a relogin after a death
   if getPlayerStorageValue(cid, STORAGE_DEATH_BAG) == 1 then
       if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid == 0 and getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) ~= 1 then
           local item_bag = doCreateItemEx(ITEM_BAG, 1)
           doPlayerAddItemEx(cid, item_bag, false, CONST_SLOT_BACKPACK)
       end
       setPlayerStorageValue(cid, STORAGE_DEATH_BAG, -1)
   end
   --Handle character sent to newbie island from main
   if getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) == 1 then
       -- first items
       if (getPlayerSex(cid) == 0) then
           doPlayerAddItem(cid, 2651, 1)
       else
           doPlayerAddItem(cid, 2650, 1) -- jacket
       end
       local club = doCreateItemEx(2382, 1) -- club
       doPlayerAddItemEx(cid, club, true, CONST_SLOT_LEFT)
       local bp = doPlayerAddItem(cid, 1987, 1) -- bag
       doAddContainerItem(bp, 2050, 1) -- torch
       doAddContainerItem(bp, 2674, 2) -- apples
       -- remove house
       local house = House.getHouseByOwner(cid)
       if(house) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
       -- reset storage
       setPlayerStorageValue(cid, getConfigInfo("storage_sendrook"), -1)
   end
   -- Remove blesses if necessary
   if getPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES) == 1 then
       local i = 1
       while i <= 5 do
           doPlayerRemoveBless(cid, i)
           i = i + 1
       end
       setPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES, -1)
   end
   -- Promotes player if necessary
   if(isPremium(cid)) then
       if(getPlayerStorageValue(cid, STORAGE_PROMOTION) == 1 and getPlayerVocation(cid) <= 4) then
           doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
           doPlayerRemoveSkillLossPercent(cid, 30)
           setPlayerStorageValue(cid, STORAGE_PROMOTION, -1)
       end
       if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == 1) then
           setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, -1)
       end
       return true
   end
   -- Player is not premium - remove premium privileges
   if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == -1) then
       -- Change outfit
       local outfit = getCreatureOutfit(cid)
       local lookType = outfit.lookType
       if (getPlayerSex(cid) == 0) then
           if lookType < 136 or lookType > 139 then
               lookType = 136
           end
       else
           if lookType < 128 or lookType > 131 then
               lookType = 128
           end
       end
       doCreatureChangeOutfit(cid, {lookType = lookType, lookHead = outfit.lookHead, lookBody = outfit.lookBody, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet})
       -- Clean house
       local house = House.getHouseByOwner(cid)
       if(house) and getBooleanFromString(getConfigInfo("house_only_premium"), true) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
    
       -- Make sure player moves to free account zone and has a free account temple
       if getPlayerTown(cid) == 11 then -- Rookgaard
           doTeleportThing(cid, getTownTemplePosition(11))
       elseif getPlayerTown(cid) >= 6 and getPlayerTown(cid) <= 9 then -- if player temple is a Premium town
           doPlayerSetTown(cid, 3) -- Thais
           doTeleportThing(cid, getTownTemplePosition(3))
       else
           doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
       end
    
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your premium account expired. You lost your Premium Account privileges.")
       setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, 1)
   end
   -- Remove promotion
   local isPromo = (getPlayerVocation(cid) > 4 and isPremium(cid) == false)
   if(isPromo) then
       doPlayerSetVocation(cid, getPlayerVocation(cid)-4)
       doPlayerRemoveSkillLossPercent(cid, -30)
       setPlayerStorageValue(cid, STORAGE_PROMOTION, 1)
   end
   return true
end
 
Solution
Hey. I've been trying to add a task system to my 7.72 open tibia project, and I'm encountering a problem with the task counter.

I got the task npc working
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="taskhole" script="taskhole.lua" walkinterval="500" floorchange="0">
   <health now="100" max="100"/>
   <look type="130" head="2" body="37" legs="35" feet="47" addons="3"/>
</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 = 5003
local monsters = {
   ["dragons"] = {storage = 5010, mstorage = 19000, amount = 10, exp = 5000, item = {2160, 3}},
   ["dragon lords"] = {storage = 5011, mstorage = 19001, amount = 10, exp = 10000, item = {2160, 10}},
   ["heros"] = {storage = 5012, mstorage = 19002, amount = 10, exp = 8000, item = {2160, 8}},
   ["dwarf guards"] = {storage = 5013, mstorage = 19003, amount = 10, exp = 7000, item = {2160, 7}}
}
function creatureSayCallback(cid, type, msg)
     if npcHandler.focus ~= 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
             local text, n = "",  0
             for k, x in pairs(monsters) do
                 if getPlayerStorageValue(cid, x.storage) == -1 then
                     n = n + 1
                     text = text .. ", "
                     text = text .. ""..x.amount.." {"..k.."}"
                 end
             end
             if n > 1 then
                 npcHandler:say("I have several tasks for you to kill"..text..", which one do you choose?")
                 talkState[talkUser] = 1
             elseif n == 1 then
                 npcHandler:say("I have one last task for you"..text..".")
                 talkState[talkUser] = 1
             else
                 npcHandler:say("You already did the missions.")
             end
         elseif getPlayerStorageValue(cid, storage) == 1 then
             for k, x in pairs(monsters) do
                 if getPlayerStorageValue(cid, x.storage) == 1 then
                     npcHandler:say("Did you kill "..x.amount.." "..k.."?")
                     talkState[talkUser] = 2
                     xmsg = k
                 end
             end
         end
     elseif monsters[msg:lower()] and talkState[talkUser] == 1 then
         if getPlayerStorageValue(cid, monsters[msg:lower()].storage) == -1 then
             npcHandler:say("Good luck, come back when you killed "..monsters[msg:lower()].amount.." "..msg..".")
             setPlayerStorageValue(cid, storage, 1)
             setPlayerStorageValue(cid, monsters[msg:lower()].storage, 1)
         else
            npcHandler:say("You already did the "..msg.." mission.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
         if getPlayerStorageValue(cid, monsters[xmsg].mstorage) == monsters[xmsg].amount then
             npcHandler:say("Good job, here is your reward.")
             doPlayerAddItem(cid, monsters[xmsg].item[1], monsters[xmsg].item[2])
             doPlayerAddExp(cid, monsters[xmsg].exp)
             setPlayerStorageValue(cid, monsters[xmsg].storage, 2)
             setPlayerStorageValue(cid, storage, -1)
         else
             npcHandler:say("You didn't kill them all.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         npcHandler:say("Ok then.")
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I added a task script in creaturescripts.lua called "Dragons"
Lua:
 local config = {
  ['dragon'] = {amount = 10, storage = 19000, startstorage = 5010, startvalue = 1},
  ['dragon lord'] = {amount = 10, storage = 19001, startstorage = 5011, startvalue = 1},
  ['hero'] = {amount = 10, storage = 19002, startstorage = 5012, startvalue = 1},
  ['dwarf guard'] = {amount = 10, storage = 19003, startstorage = 5013, 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 and (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

I added registerCreatureEvent(cid, "Dragons") in login.lua
Lua:
function onLogin(cid)

   local events = {
       "RemoveBlesses", --Register the kill/die event
       "Give_Bag_After_Death", --Register the Give_Bag_After_Death
       "lootMessage", --Register loot message
   }
 
   -- Register events
   for i = 1, #events do
       registerCreatureEvent(cid, events[i])
       registerCreatureEvent(cid, "Dragons")
   end

   -- Register the Stage event
   if getBooleanFromString(getConfigInfo("experience_stages"), false) then
       registerCreatureEvent(cid, "ExpStage")
       checkStageChange(cid)
   end
 
   -- Add a backpack if it is a relogin after a death
   if getPlayerStorageValue(cid, STORAGE_DEATH_BAG) == 1 then
       if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid == 0 and getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) ~= 1 then
           local item_bag = doCreateItemEx(ITEM_BAG, 1)
           doPlayerAddItemEx(cid, item_bag, false, CONST_SLOT_BACKPACK)
       end
       setPlayerStorageValue(cid, STORAGE_DEATH_BAG, -1)
   end

   --Handle character sent to newbie island from main
   if getPlayerStorageValue(cid, getConfigInfo("storage_sendrook")) == 1 then
       -- first items
       if (getPlayerSex(cid) == 0) then
           doPlayerAddItem(cid, 2651, 1)
       else
           doPlayerAddItem(cid, 2650, 1) -- jacket
       end
       local club = doCreateItemEx(2382, 1) -- club
       doPlayerAddItemEx(cid, club, true, CONST_SLOT_LEFT)
       local bp = doPlayerAddItem(cid, 1987, 1) -- bag
       doAddContainerItem(bp, 2050, 1) -- torch
       doAddContainerItem(bp, 2674, 2) -- apples
       -- remove house
       local house = House.getHouseByOwner(cid)
       if(house) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
       -- reset storage
       setPlayerStorageValue(cid, getConfigInfo("storage_sendrook"), -1)
   end

   -- Remove blesses if necessary
   if getPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES) == 1 then
       local i = 1
       while i <= 5 do
           doPlayerRemoveBless(cid, i)
           i = i + 1
       end
       setPlayerStorageValue(cid, STORAGE_REMOVE_BLESSES, -1)
   end

   -- Promotes player if necessary
   if(isPremium(cid)) then
       if(getPlayerStorageValue(cid, STORAGE_PROMOTION) == 1 and getPlayerVocation(cid) <= 4) then
           doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
           doPlayerRemoveSkillLossPercent(cid, 30)
           setPlayerStorageValue(cid, STORAGE_PROMOTION, -1)
       end
       if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == 1) then
           setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, -1)
       end
       return true
   end

   -- Player is not premium - remove premium privileges
   if(getPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT) == -1) then

       -- Change outfit
       local outfit = getCreatureOutfit(cid)
       local lookType = outfit.lookType
       if (getPlayerSex(cid) == 0) then
           if lookType < 136 or lookType > 139 then
               lookType = 136
           end
       else
           if lookType < 128 or lookType > 131 then
               lookType = 128
           end
       end
       doCreatureChangeOutfit(cid, {lookType = lookType, lookHead = outfit.lookHead, lookBody = outfit.lookBody, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet})

       -- Clean house
       local house = House.getHouseByOwner(cid)
       if(house) and getBooleanFromString(getConfigInfo("house_only_premium"), true) then
           house:setOwner(0) --Remove the house from the player, the server takes care of the rest
       end
     
       -- Make sure player moves to free account zone and has a free account temple
       if getPlayerTown(cid) == 11 then -- Rookgaard
           doTeleportThing(cid, getTownTemplePosition(11))
       elseif getPlayerTown(cid) >= 6 and getPlayerTown(cid) <= 9 then -- if player temple is a Premium town
           doPlayerSetTown(cid, 3) -- Thais
           doTeleportThing(cid, getTownTemplePosition(3))
       else
           doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
       end
     
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your premium account expired. You lost your Premium Account privileges.")
       setPlayerStorageValue(cid, STORAGE_PREMIUM_ACCOUNT, 1)
   end

   -- Remove promotion
   local isPromo = (getPlayerVocation(cid) > 4 and isPremium(cid) == false)
   if(isPromo) then
       doPlayerSetVocation(cid, getPlayerVocation(cid)-4)
       doPlayerRemoveSkillLossPercent(cid, -30)
       setPlayerStorageValue(cid, STORAGE_PROMOTION, 1)
   end

   return true
end

I added <event name="Dragons" type="kill" script="dragons.lua"/> in creaturescripts.xml
XML:
<?xml version="1.0"?>
<creaturescripts>
   <event name="PlayerLogin" type="login" script="login.lua"/>
   <event name="SendLoginInfo" type="login" script="sendlogininfo.lua"/>
   <event name="RemoveBlesses" type="die" script="removeblesses.lua"/>
   <event name="Give_Bag_After_Death" type="die" script="give_bag_after_death.lua"/>
   <event name="ExpStage" type="advance" script="exp_stage.lua"/>
   <event name="ServerRecord" type="login" script="record.lua"/>
   <event name="giveFirstItems" type="login" script="firstitems.lua" />
   <event name="lootMessage" type="kill" script="lootmessage.lua"/>
   <event name="addPremium" type="login" script="freepremium.lua" />
    <event name="Dragons" type="kill" script="dragons.lua"/>
</creaturescripts>


So the problem is that, when trying to complete a task, killing 1 creature in a task will give me 3 kills for the task, like this.
I kill 1 dragon:
1 out of 10 dragons killed.
2 out of 10 dragons killed.
3 out of 10 dragons killed.

Any help would be very much appreciated.


WHEN NPC PLAYER SAID "MISSION" or "TASK" I WANT TO OPEN BOOK "SHOW TEXT
 
Back
Top