• 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!

Promotion for Task

amoxicilina

Member
Joined
Jun 25, 2010
Messages
72
Reaction score
11
Hi everyone, I'm having problem with this promotion npc by task, I'm talking to npc, it does not respond to me and not from the error in the console.
I'm using tfs 1.x

NPC:
Lua:
local config = {
   monsters = {
     -- ["Name"] = {amount = quantidade}
     ["Demon"] = {amount = 30},
     ["Hydra"] = {amount = 10},
   },
   storage = 54661, -- Não mexer se não souber editar
   money = 100 -- Dinheiro
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:eek:nCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:eek:nCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:eek:nCreatureSay(cid, type, msg)        end
function onThink()        npcHandler:eek:nThink()        end

local function releasePlayer(cid)
   if not Player(cid) then
       return
   end

   npcHandler:releaseFocus(cid)
   npcHandler:resetNpc(cid)
end

local function creatureSayCallback(cid, type, msg)
   if not npcHandler:isFocused(cid) then
       return false
   end

     local player = Player(cid)
   if msgcontains(msg, "mission") then
       if player:getStorageValue(config.storage) < 1 then
           selfSay("A missão para promovido custa " .. config.money .. " você aceita fazer ?", cid)
           npcHandler.topic[cid] = 1
       elseif player:getStorageValue(config.storage) == (2 + #config.monsters) then
           selfSay("Você já cumpriu a missão peça pra ser {promovido}.", cid)
           npcHandler.topic[cid] = 2
       elseif player:getStorageValue(config.storage) == (3 + #config.monsters) then
           selfSay("Voce já terminou as missões, pode ir em embora!", cid)
           releasePlayer(cid)
       end
   elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
       if player:removeMoney(config.money) then
           local text = ""
           for monsters, v in pairs(config.monsters) do
               text = text .. ", "
               text = text .. v.amount .. " {" .. monsters .. "}"
           end
           npcHandler:say("A missão é matar esses monstros para mim" .. text .. ".", cid)
           for i, _ in pairs(config.monsters) do
               player:setStorageValue(i, 0)
           end
           player:setStorageValue(config.storage, 1)
       else
           selfSay("Você não tem money suficiente!", cid)
       end
       npcHandler.topic[cid] = 0
   elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 2 then
       selfSay("Até logo!", cid)
       npcHandler.topic[cid] = 0
   end

   if msgcontains(msg, "lista") and player:getStorageValue(config.storage) < (#config.monsters + 3) then
       local text, n = "", 0
       for monsters, v in pairs(config.monsters) do
           local sto = player:getStorageValue(monsters)
           if  sto < v.amount then
               n = n + 1
               text = text .. ", "
               text = text .. (tostring(sto) < tostring(1) and v.amount or (tostring(v.amount) - tostring(sto))) .. " {" .. monsters .. "}"
           end
       end
   elseif msgcontains(msg, "promovido") and npcHandler.topic[cid] == 2 then
       selfSay("Aqui está sua promoção jovem soldado!!", cid)
       player:setVocation(player:getVocation() + 4)
       player:setStorageValue(config.storage, (#config.monsters + 3))
       for monsters, _ in pairs(config.monsters) do
           player:setStorageValue(monsters, -1)
       end
       npcHandler.topic[cid] = 0
   end
   return true
end

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


CREATURESCRIPTS:
Lua:
local Config = {
   Monsters = {
     -- ["Name"] = {amount = quantidade}
     ["Amazon"] = {amount = 50},
     ["Hero"] = {amount = 30},
   },
   StoragePro = 54661, -- Não mexer se não souber editar
   Money = 20000 -- Dinheiro
}
function onKill(cid, target)
   if not isMonster
     
 
 
 
     
         
            cid, monster, (sto + 1))
           setPlayerStorageValue(cid, Config.StoragePro, (getPlayerStorageValue(cid, Config.StoragePro) + 1))
       end
   end
   return true
end
function onLogin(cid)
   registerCreatureEvent('taskNpc')
   return true
end

TAGS:
Lua:
 <!-- Promotion -->
   <event type="login" name="verf_taskNpc" event="script" value="promotion/EK.lua"/>
   <event type="kill" name="taskNpc" event="script" value="promotion/EK.lua"/>
 
Last edited:
Lua:
<event type="login" name="verf_taskNpc" script="promotion/EK.lua"/>
<event type="kill" name="taskNpc" script="promotion/EK.lua"/>

Also there are a lot of errors in the code you posted, also also doesn't check if you are killing any of the declared creatures.
Who wrote it?
 
Last edited:
Lua:
<event type="login" name="verf_taskNpc" script="promotion/EK.lua"/>
<event type="kill" name="taskNpc" script="promotion/EK.lua"/>

Also there are a lot of errors in the code you posted, also also doesn't check if you are killing any of the declared creatures.
Who wrote it?

who wrote was a friend of mine, who told this learning ".Lua".
Is it possible to fix the bugs so that it works?
 
Back
Top