• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Task system

beliar34

Member
Joined
Feb 28, 2012
Messages
307
Solutions
7
Reaction score
11
Hay i use task system on TFS 3.5.0 and this dosent work !! my scripts


Killinifofthename.lua in creatrue script's :

PHP:
local questCreatures =
{
	["Wolf"] = {questStarted = 1510, questStorage = 65000, creatureStorage = 15000, killsRequired = 50, raceName = "Wolfs"},
    ["Soul Wolf"] = {questStarted = 1511, questStorage = 65001, creatureStorage = 15001, killsRequired = 200, raceName = "Wolfs1"},
    ["Hollow Wolf"] = {questStarted = 1512, questStorage = 65002, creatureStorage = 15002, killsRequired = 200, raceName = "Wolfs2"},

    ["Bandit"] = {questStarted = 1513, questStorage = 65003, creatureStorage = 15003, killsRequired = 150, raceName = "Bandits"},
    ["Bandit SwordMan"] = {questStarted = 1514, questStorage = 65004, creatureStorage = 15004, killsRequired = 150, raceName = "Bandits1"},
    ["Pirate Bandit"] = {questStarted = 1515, questStorage = 65005, creatureStorage = 15005, killsRequired = 150, raceName = "Bandits"},
    ["Rungokai Bandit"] = {questStarted = 1516, questStorage = 65006, creatureStorage = 15006, killsRequired = 150, raceName = "Bandits"},


    ["Samurai"] = {questStarted = 1517, questStorage = 65007, creatureStorage = 15007, killsRequired = 300, raceName = "Samurais"},

    ["Judo Fighter"] = {questStarted = 1518, questStorage = 65008, creatureStorage = 15008, killsRequired = 500, raceName = "Judo Fighters"}


}
 
local msgType = MESSAGE_STATUS_CONSOLE_ORANGE
 
function onKill(cid, target, lastHit)
 
local creature = questCreatures[getCreatureName(target):lower()]
 
	if creature then
		if isPlayer(target) or isSummon(target) then return true end
 
		if getCreatureStorage(cid, creature.questStarted) > 0 then
			if getCreatureStorage(cid, creature.questStorage) < creature.killsRequired then
				if getCreatureStorage(cid, creature.questStorage) < 0 then
					doCreatureSetStorage(cid, creature.questStorage, 0)
				end
 
				if getCreatureStorage(cid, creature.creatureStorage) < 0 then
					doCreatureSetStorage(cid, creature.creatureStorage, 0)
				end
				doCreatureSetStorage(cid, creature.questStorage, getCreatureStorage(cid, creature.questStorage) + 1)
				doCreatureSetStorage(cid, creature.creatureStorage, getCreatureStorage(cid, creature.creatureStorage) + 1)
				doPlayerSendTextMessage(cid, msgType, getCreatureStorage(cid, creature.creatureStorage) .. " " .. getCreatureName(target) .. " defeated. Total [" .. getCreatureStorage(cid, creature.questStorage) .. "/" .. creature.killsRequired .. "] " .. creature.raceName .. ".")
			end
		end
	end
	return true
end

Script to npc :

PHP:
  local tasks =
{
        [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 50, raceName = "Wolfs", rewards = {first = {enable = true, type = "exp", values = 2000}, second = {enable = true, type = "money", values = 2000}, third = {enable = false, type = nil, values = {nil, nil}}}},

        [2] = {questStarted = 1511, questStorage = 65001, killsRequired = 150, raceName = "Bandits", rewards = {first = {enable = true, type = "exp", values = 300}, second = {enable = true, type = "money", values = 250}, third = {enable = false, type = nil, values = {nil, nil}}}},

        [3] = {questStarted = 1512, questStorage = 65002, killsRequired = 300, raceName = "Samurais", rewards = {first = {enable = true, type = "exp", values = 1000}, second = {enable = true, type = "money", values = 400}, third = {enable = false, type = nil, values = {nil, nil}}}},

        [4] = {questStarted = 1512, questStorage = 65002, killsRequired = 300, raceName = "Judo Fighters", rewards = {first = {enable = true, type = "exp", values = 1000}, second = {enable = true, type = "money", values = 400}, third = {enable = false, type = nil, values = {nil, nil}}}}
}

local storage = 64521

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}

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)

        local s = getPlayerStorageValue(cid, storage)

        if(not npcHandler:isFocused(cid)) then
                return false
        end
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
        if msgcontains(msg, 'task') then

                if(s < 1) then
                        doPlayerSetStorageValue(cid, storage, 1)
                end

                if tasks[s] then
                        if(getPlayerStorageValue(cid, tasks[s].questStarted) < 1) then
                                if(getPlayerStorageValue(cid, tasks[s].creatureStorage) < 0) then
                                        doPlayerSetStorageValue(cid, tasks[s].creatureStorage, 0)
                                end

                                if(getPlayerStorageValue(cid, tasks[s].questStorage) < 0) then
                                        doPlayerSetStorageValue(cid, tasks[s].questStorage, 0)
                                end

                                doPlayerSetStorageValue(cid, tasks[s].questStarted, 1)
                                selfSay('You have started the task number ' .. getPlayerStorageValue(cid, storage) .. ', in this task you need to kill ' .. tasks[s].killsRequired .. ' ' .. tasks[s].raceName .. '.', cid)
                        else
                                selfSay('You are currently making task about ' .. tasks[s].raceName .. '.', cid)
                        end
                else
                        print("[Warning - Error::Killing in the name of::Tasks config] Something is wrong.")
                end

        elseif msgcontains(msg, 'report') then
                if tasks[s] and tasks[s].questStarted > 0 then
                        if(getPlayerStorageValue(cid, tasks[s].creatureStorage) < 0) then
                                doPlayerSetStorageValue(cid, tasks[s].creatureStorage, 0)
                        end

                        if(getPlayerStorageValue(cid, tasks[s].questStorage) < 0) then
                                doPlayerSetStorageValue(cid, tasks[s].questStorage, 0)
                        end

                        if(getPlayerStorageValue(cid, tasks[s].questStorage) >= tasks[s].killsRequired) then
                                selfSay('Great!... you have finished the task number ' .. s .. '. Good job.', cid)
                                doPlayerSetStorageValue(cid, storage, s + 1)
                                if(tasks[s].rewards.first.enable) then
                                        if(tasks[s].rewards.first.type == "boss") then
                                                doTeleportThing(cid, tasks[s].rewards.first.values)
                                        elseif(tasks[s].rewards.first.type == "exp") then
                                                doPlayerAddExperience(cid, tasks[s].rewards.first.values)
                                        elseif(tasks[s].rewards.first.type == "item") then
                                                doPlayerAddItem(cid, tasks[s].rewards.first.values[1], tasks[s].rewards.first.values[2])
                                        elseif(tasks[s].rewards.first.type == "money") then
                                                doPlayerAddMoney(cid, tasks[s].rewards.first.values)
                                        elseif(tasks[s].rewards.first.type == "storage") then
                                                doPlayerSetStorageValue(cid, tasks[s].rewards.first.values[1], tasks[s].rewards.first.values[2])
                                        end
                                end
                                if(tasks[s].rewards.second.enable) then
                                        if(tasks[s].rewards.second.type == "boss") then
                                                doTeleportThing(cid, tasks[s].rewards.second.values)
                                        elseif(tasks[s].rewards.second.type == "exp") then
                                                doPlayerAddExperience(cid, tasks[s].rewards.second.values)
                                        elseif(tasks[s].rewards.second.type == "item") then
                                                doPlayerAddItem(cid, tasks[s].rewards.second.values[1], tasks[s].rewards.second.values[2])
                                        elseif(tasks[s].rewards.second.type == "money") then
                                                doPlayerAddMoney(cid, tasks[s].rewards.second.values)
                                        elseif(tasks[s].rewards.second.type == "storage") then
                                                doPlayerSetStorageValue(cid, tasks[s].rewards.second.values[1], tasks[s].rewards.second.values[2])
                                        end
                                end
                                if(tasks[s].rewards.third.enable) then
                                        if(tasks[s].rewards.third.type == "boss") then
                                                doTeleportThing(cid, tasks[s].rewards.third.values)
                                        elseif(tasks[s].rewards.third.type == "exp") then
                                                doPlayerAddExperience(cid, tasks[s].rewards.third.values)
                                        elseif(tasks[s].rewards.third.type == "item") then
                                                doPlayerAddItem(cid, tasks[s].rewards.third.values[1], tasks[s].rewards.third.values[2])
                                        elseif(tasks[s].rewards.third.type == "money") then
                                                doPlayerAddMoney(cid, tasks[s].rewards.third.values)
                                        elseif(tasks[s].rewards.third.type == "storage") then
                                                doPlayerSetStorageValue(cid, tasks[s].rewards.third.values[1], tasks[s].rewards.third.values[2])
                                        end
                                end                          
                        else
                                selfSay('Current ' .. getPlayerStorageValue(cid, tasks[s].questStorage) .. ' ' .. tasks[s].raceName .. ' killed, you need to kill ' .. tasks[s].killsRequired .. '.', cid)
                        end
                else
                        selfSay('You do not have started any task.', cid)
                end
        end
        return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Npc work good but if i kill wolf i still have 0 kills ;( i add it in the :

<script>
<event name="KillingInTheNameOf"/>
</script>

Wolf.xml and still dont working

I add registerCreatureEvent(cid, "KillingInTheNameOf") in to login.lua ;(

Why this dosent work ?

- - - Updated - - -

i got error in console :"unknown event type KillingInTheNameOf"
 
Back
Top