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

Task npc for 8.7

I believe it should work on your TFS 8.7. Why don't you use TFS 1.5 8.6 Nekiro? It's much better than TFS 8.7. Was it because you wanted the mount system, right?

 
a
Post automatically merged:

I believe it should work on your TFS 8.7. Why don't you use TFS 1.5 8.6 Nekiro? It's much better than TFS 8.7. Was it because you wanted the mount system, right?

don't work
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/login.lua:eek:nLogin
luaRegisterCreatureEvent(). Creature not found
stack traceback:
[C]: in function 'registerCreatureEvent'
data/creaturescripts/scripts/login.lua:107: in function <data/creaturescripts/scripts/login.lua:41>
 
a
Post automatically merged:


don't work
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/login.lua:eek:nLogin
luaRegisterCreatureEvent(). Creature not found
stack traceback:
[C]: in function 'registerCreatureEvent'
data/creaturescripts/scripts/login.lua:107: in function <data/creaturescripts/scripts/login.lua:41>
post your login.lua
 
post your login.lua
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000

function onLogin(cid)
if(InitShopComunication == 0) then
local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
InitShopComunication = eventServ
end
if(InitHistory == 0) then
local historyPage = addEvent(historyPage, 60000, {})
InitHistory = historyPage
end
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "BountyHunter")
registerCreatureEvent(cid, "Castle")
registerCreatureEvent(cid, "mageBomb")
registerCreatureEvent(cid, "KillingInTheNameOf") -- Dodane wydarzenie
return TRUE
end

function historyPage(parameters)
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
local historyPage = addEvent(historyPage, 60000, {})
if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
assert(con:execute("UPDATE players SET onlinetime7=players.onlinetime6, onlinetime6=players.onlinetime5, onlinetime5=players.onlinetime4, onlinetime4=players.onlinetime3, onlinetime3=players.onlinetime2, onlinetime2=players.onlinetime1, onlinetime1=players.onlinetimetoday, onlinetimetoday=0;"))
assert(con:execute("UPDATE players SET exphist7=players.exphist6, exphist6=players.exphist5, exphist5=players.exphist4, exphist4=players.exphist3, exphist3=players.exphist2, exphist2=players.exphist1, exphist1=players.experience-players.exphist_lastexp, exphist_lastexp=players.experience;"))
end
assert(con:execute("UPDATE players SET onlinetimetoday=players.onlinetimetoday+60, onlinetimeall=players.onlinetimeall+60 WHERE online = 1;"))
con:close()
env:close()
end

function sql_communication(parameters)
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE type = 'login';"))
todo = result_plr:fetch({}, "a")
while todo do
id = tonumber(todo.id)
action = tostring(todo.action)
delete = tonumber(todo.delete_it)
cid = getPlayerByName(tostring(todo.name))
if isPlayer(cid) == TRUE then
local itemtogive_id = tonumber(todo.param1)
local itemtogive_count = tonumber(todo.param2)
local container_id = tonumber(todo.param3)
local container_count = tonumber(todo.param4)
local add_item_type = tostring(todo.param5)
local add_item_name = tostring(todo.param6)
local received_item = 0
local full_weight = 0
if add_item_type == 'container' then
container_weight = getItemWeight(container_id, 1)
if isItemRune(itemtogive_id) == TRUE then
items_weight = container_count * getItemWeight(itemtogive_id, 1)
else
items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
end
full_weight = items_weight + container_weight
else
full_weight = getItemWeight(itemtogive_id, itemtogive_count)
if isItemRune(itemtogive_id) == TRUE then
full_weight = getItemWeight(itemtogive_id, 1)
else
full_weight = getItemWeight(itemtogive_id, itemtogive_count)
end
end
local free_cap = getPlayerFreeCap(cid)
if full_weight <= free_cap then
if add_item_type == 'container' then
local new_container = doCreateItemEx(container_id, 1)
local iter = 0
while iter ~= container_count do
doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
iter = iter + 1
end
received_item = doPlayerAddItemEx(cid, new_container)
else
local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
received_item = doPlayerAddItemEx(cid, new_item)
end
if received_item == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Otrzymales: >> '.. add_item_name ..' << ze sklepiku OTS!')
delete = assert(con:execute("DELETE FROM z_ots_comunication WHERE id = " .. id .. ";"))
assert(con:execute("UPDATE z_shop_history_item SET trans_state='realized', trans_real=" .. os.time() .. " WHERE id = " .. id .. ";"))
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Zrob miejsce w plecaku i poczekaj '.. SQL_interval ..' sekund na niego.')
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Wazy '.. full_weight ..' oz., masz tylko '.. free_cap ..' oz. wolnego cap. Zwolnic miejsce i poczekaj '.. SQL_interval ..' sekund na niego.')
end
end
todo = result_plr:fetch (todo, "a")
end
con:close()
env:close()
local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
registerCreatureEvent(cid, "KilledMonstersCounter")
end
 
Hello i looking for task npc i Have visum ots 8.7 thanks for help
What is visum ots 8.7? You should write your TFS/OTX/Canary version next time, that will make it easier to help you and provide as much information as possible.
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000

function onLogin(cid)
if(InitShopComunication == 0) then
local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
InitShopComunication = eventServ
end
if(InitHistory == 0) then
local historyPage = addEvent(historyPage, 60000, {})
InitHistory = historyPage
end
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "BountyHunter")
registerCreatureEvent(cid, "Castle")
registerCreatureEvent(cid, "mageBomb")
registerCreatureEvent(cid, "KillingInTheNameOf") -- Dodane wydarzenie
return TRUE
end

function historyPage(parameters)
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
local historyPage = addEvent(historyPage, 60000, {})
if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
assert(con:execute("UPDATE players SET onlinetime7=players.onlinetime6, onlinetime6=players.onlinetime5, onlinetime5=players.onlinetime4, onlinetime4=players.onlinetime3, onlinetime3=players.onlinetime2, onlinetime2=players.onlinetime1, onlinetime1=players.onlinetimetoday, onlinetimetoday=0;"))
assert(con:execute("UPDATE players SET exphist7=players.exphist6, exphist6=players.exphist5, exphist5=players.exphist4, exphist4=players.exphist3, exphist3=players.exphist2, exphist2=players.exphist1, exphist1=players.experience-players.exphist_lastexp, exphist_lastexp=players.experience;"))
end
assert(con:execute("UPDATE players SET onlinetimetoday=players.onlinetimetoday+60, onlinetimeall=players.onlinetimeall+60 WHERE online = 1;"))
con:close()
env:close()
end

function sql_communication(parameters)
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE type = 'login';"))
todo = result_plr:fetch({}, "a")
while todo do
id = tonumber(todo.id)
action = tostring(todo.action)
delete = tonumber(todo.delete_it)
cid = getPlayerByName(tostring(todo.name))
if isPlayer(cid) == TRUE then
local itemtogive_id = tonumber(todo.param1)
local itemtogive_count = tonumber(todo.param2)
local container_id = tonumber(todo.param3)
local container_count = tonumber(todo.param4)
local add_item_type = tostring(todo.param5)
local add_item_name = tostring(todo.param6)
local received_item = 0
local full_weight = 0
if add_item_type == 'container' then
container_weight = getItemWeight(container_id, 1)
if isItemRune(itemtogive_id) == TRUE then
items_weight = container_count * getItemWeight(itemtogive_id, 1)
else
items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
end
full_weight = items_weight + container_weight
else
full_weight = getItemWeight(itemtogive_id, itemtogive_count)
if isItemRune(itemtogive_id) == TRUE then
full_weight = getItemWeight(itemtogive_id, 1)
else
full_weight = getItemWeight(itemtogive_id, itemtogive_count)
end
end
local free_cap = getPlayerFreeCap(cid)
if full_weight <= free_cap then
if add_item_type == 'container' then
local new_container = doCreateItemEx(container_id, 1)
local iter = 0
while iter ~= container_count do
doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
iter = iter + 1
end
received_item = doPlayerAddItemEx(cid, new_container)
else
local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
received_item = doPlayerAddItemEx(cid, new_item)
end
if received_item == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Otrzymales: >> '.. add_item_name ..' << ze sklepiku OTS!')
delete = assert(con:execute("DELETE FROM z_ots_comunication WHERE id = " .. id .. ";"))
assert(con:execute("UPDATE z_shop_history_item SET trans_state='realized', trans_real=" .. os.time() .. " WHERE id = " .. id .. ";"))
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Zrob miejsce w plecaku i poczekaj '.. SQL_interval ..' sekund na niego.')
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Wazy '.. full_weight ..' oz., masz tylko '.. free_cap ..' oz. wolnego cap. Zwolnic miejsce i poczekaj '.. SQL_interval ..' sekund na niego.')
end
end
todo = result_plr:fetch (todo, "a")
end
con:close()
env:close()
local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
registerCreatureEvent(cid, "KilledMonstersCounter")
end
 
What is visum ots 8.7? You should write your TFS/OTX/Canary version next time, that will make it easier to help you and provide as much information as possible.

propably tfs 0.4
Lua:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000

function onLogin(cid)
    if(InitShopComunication == 0) then
        local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
        InitShopComunication = eventServ
    end
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
    end
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "BountyHunter")
    registerCreatureEvent(cid, "Castle")
    registerCreatureEvent(cid, "mageBomb")
    registerCreatureEvent(cid, "KillingInTheNameOf") -- Dodane wydarzenie
    return TRUE
end

function historyPage(parameters)
    dofile("./config.lua")
    env = assert(luasql.mysql())
    con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
    local historyPage = addEvent(historyPage, 60000, {})
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        assert(con:execute("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;"))
        assert(con:execute("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;"))
    end
    assert(con:execute("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;"))
    con:close()
    env:close()
end 

function sql_communication(parameters)
    dofile("./config.lua")
    env = assert(luasql.mysql())
    con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
    result_plr = assert(con:execute("SELECT * FROM z_ots_comunication WHERE `type` = 'login';"))
    todo = result_plr:fetch({}, "a")
    while todo do
        id = tonumber(todo.id)
        action = tostring(todo.action)
        delete = tonumber(todo.delete_it)
        cid = getPlayerByName(tostring(todo.name))
        if isPlayer(cid) == TRUE then
            local itemtogive_id = tonumber(todo.param1)
            local itemtogive_count = tonumber(todo.param2)
            local container_id = tonumber(todo.param3)
            local container_count = tonumber(todo.param4)
            local add_item_type = tostring(todo.param5)
            local add_item_name = tostring(todo.param6)
            local received_item = 0
            local full_weight = 0
            if add_item_type == 'container' then
                container_weight = getItemWeight(container_id, 1)
                if isItemRune(itemtogive_id) == TRUE then
                    items_weight = container_count * getItemWeight(itemtogive_id, 1)
                else
                    items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
                end
                full_weight = items_weight + container_weight
            else
                full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                if isItemRune(itemtogive_id) == TRUE then
                    full_weight = getItemWeight(itemtogive_id, 1)
                else
                    full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                end
            end
            local free_cap = getPlayerFreeCap(cid)
            if full_weight <= free_cap then
                if add_item_type == 'container' then
                    local new_container = doCreateItemEx(container_id, 1)
                    local iter = 0
                    while iter ~= container_count do
                        doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                        iter = iter + 1
                    end
                    received_item = doPlayerAddItemEx(cid, new_container)
                else
                    local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                    received_item = doPlayerAddItemEx(cid, new_item)
                end
                if received_item == RETURNVALUE_NOERROR then
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'Otrzymales: >> '.. add_item_name ..' << ze sklepiku OTS!')
                    delete = assert(con:execute("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";"))
                    assert(con:execute("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";"))
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Zrob miejsce w plecaku i poczekaj '.. SQL_interval ..' sekund na niego.')
                end
            else
                doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << ze sklepiku OTS czeka na Ciebie! Wazy '.. full_weight ..' oz., masz tylko '.. free_cap ..' oz. wolnego cap. Zwolnic miejsce i poczekaj  '.. SQL_interval ..' sekund na niego.')
            end
        end
        todo = result_plr:fetch (todo, "a")
    end
    con:close()
    env:close()
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
    registerCreatureEvent(cid, "KilledMonstersCounter")
end
Post automatically merged:

i don't know where find my tfs version
 
Last edited:
yeah thats definetly 0.x

move this
Lua:
registerCreatureEvent(cid, "KilledMonstersCounter")

to line after this
Lua:
registerCreatureEvent(cid, "KillingInTheNameOf") -- Dodane wydarzenie

You have pasted register creature in function where is no parameter cid, this line supposed to be in onLogin function
 
yeah thats definetly 0.x

move this
Lua:
registerCreatureEvent(cid, "KilledMonstersCounter")

to line after this
Lua:
registerCreatureEvent(cid, "KillingInTheNameOf") -- Dodane wydarzenie

You have pasted register creature in function where is no parameter cid, this line supposed to be in onLogin function
ok i do this and...
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/login.lua:eek:nLogin
luaRegisterCreatureEvent(). Creature not found
stack traceback:
[C]: in function 'registerCreatureEvent'
data/creaturescripts/scripts/login.lua:108: in function <data/creaturescripts/scripts/login.lua:42>

Lua Script Error: [Npc interface]
data/npc/scripts/KillingInTheNameOf.lua:eek:nCreatureSay
data/npc/scripts/KillingInTheNameOf.lua:42: attempt to call global 'canStartTask' (a nil value)
stack traceback:
[C]: in function 'canStartTask'
data/npc/scripts/KillingInTheNameOf.lua:42: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:379: in function 'onCreatureSay'
data/npc/scripts/KillingInTheNameOf.lua:8: in function <data/npc/scripts/KillingInTheNameOf.lua:8>
where i can find onlogin function?
 
first error: remove 108 line probably contains registerCreatureEvent(cid, "KilledMonstersCounter")

i said "move" not copy

second, probably lib missing that author of this system provided but you did something wrong or not even included this file into your data/libs folder
 
first error: remove 108 line probably contains registerCreatureEvent(cid, "KilledMonstersCounter")

i said "move" not copy

second, probably lib missing that author of this system provided but you did something wrong or not even included this file into your data/libs folder
ok my fault i do this and
Lua Script Error: [Npc interface]
data/npc/scripts/KillingInTheNameOf.lua:eek:nCreatureSay
data/npc/scripts/KillingInTheNameOf.lua:42: attempt to call global 'canStartTask' (a nil value)
stack traceback:
[C]: in function 'canStartTask'
data/npc/scripts/KillingInTheNameOf.lua:42: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:379: in function 'onCreatureSay'
data/npc/scripts/KillingInTheNameOf.lua:8: in function <data/npc/scripts/KillingInTheNameOf.lua:8>
 
make a lua file in directory data/lib name it i dont know Task System.lua and paste a lib code that author of this system provided in his post

ps. if you have problems to implement code that its literaly ready to copy paste you should start your journey from something easier to understand what you are doing and where you are doings changes and why you are doing these changes / apply the new code
 
Last edited:
make a lua file in directory data/lib name it i dont know Task System.lua and paste a lib code that author of this system provided in his post

ps. if you have problems to implement code that its literaly ready to copy paste you should start your journey from something easier to understand what you are doing and where you are doings changes and why you are doing these changes / apply the new code
Only lib folder i Have is in data/npc/lib data/action/lib etc i dont have folder lib in dat folder
Post automatically merged:

Only lib folder i Have is in data/npc/lib data/action/lib etc i dont have folder lib in dat folder I send screanshot when i Wake up
 
I'm going to explain to you, so pay attention! Servers larger than TFS do have a 'lib' directory as usual. Let's add it to your TFS. Your server has 'data/lib/', so add this here.

103-killinginthenameof.lua
 

Attachments

  • 103-killinginthenameof.lua
    25.2 KB · Views: 1 · VirusTotal
I dont know what tfs is this
Simply can't download to check this OT... Honestly, it's better if you use a more updated mechanism like TFS 1.5 Nekiro 8.6, which is much better than your server... Just abandon the inferior TFS 0.4x and migrate to TFS 1.x Nekiro, it's already solved!!!... Many scripts and systems you're looking for are always found here on Otland!🤷‍♂️
Post automatically merged:

See what I found on another old forum... It seems like we don't need "lib", just add the NPC and CreatureScript and it's already solved!!!... Let's do it here.

Now in Data/NPC/Scripts create a file called Billie.xml and insert the code inside:
XML:
<?xml version="1.0" encoding="UTF-8"?>

<npc name="Billie" script="Billie.lua" walkinterval="10000" floorchange="0" speed="100">
<health now="150" max="150"/>
<look type="136" head="114" body="119" legs="114" feet="114" corpse="2212"/>

<parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME|, I need a service... Say {help} or {task} to more informations."/>
</parameters>
</npc>

Now in Data/NPC/Scripts create a file called Billie.lua and insert the code inside:
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

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


-- VARIABLES --
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
msg = string.lower(msg)

local id_item = 2160 -- ITEM YOU WILL EARN WHEN COMPLETING THE TASK
local quantidade_item = 1 -- NUMBER OF ITEMS YOU WILL WIN
local exp = 500000 -- EXPERIENCE YOU WILL GAIN

local monstro = "Magmar" -- MONSTER NAME
local quantidade_monstro = 50 -- NUMBER OF MONSTERS

local storage = 32500 --NPC STORAGE
local storage_npc = 34900 -- STORAGE THAT THE NPC GIVES TO THE PLAYER TO START THE TASK
local storage_quantidade = 32510 --STORAGE THAT CONTAINS THE NUMBER OF MONSTERS DEFEATED BY THE PLAYER
local storage_task = 32600 -- TASK COMPLETION STORAGE
local storage_mensagem = 32505 -- STORAGE TO MAKE DIALOGUE MORE BEAUTIFUL
local restante = (quantidade_monstro - getPlayerStorageValue(cid, storage_quantidade)) + 1

----------------------------------- [ DIALOGUE WITH NPC] -----------------------------------
 
if msgcontains(msg, 'task') then
 
   if getPlayerStorageValue(cid, storage) == 1 then
      selfSay("You have already done my task.", cid)
      talkState[talkUser] = 0
   return true
 
   else
      if getPlayerStorageValue(cid, storage_npc) < 1 then
         selfSay("I need you kill " ..quantidade_monstro.. " " ..monstro.. ". Do you accept my task?", cid)
      else
         selfSay("Have you already finished my task?", cid)
     end
   talkState[talkUser] = 1
   return true
   end
 

elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[talkUser] == 1 then

  if getPlayerStorageValue(cid, storage_mensagem) < 1 and getPlayerStorageValue(cid, storage_npc) < 1 then
    selfSay("Ok, go to complete my task.", cid)
    talkState[talkUser] = 0
    setPlayerStorageValue(cid, storage_mensagem, 1)
    setPlayerStorageValue(cid, storage_npc, 1)
    setPlayerStorageValue(cid, storage_quantidade, 1)
  return true
  end

  if getPlayerStorageValue(cid, storage_task) < 1 then
       selfSay("You don't finish my task yet. You need to kill " ..restante.. " " ..monstro.. " yet." , cid)
    talkState[talkUser] = 0
  return true
 
  else
    selfSay("Congratulations! You finished my task! Receive your reward.", cid)
    doSendMagicEffect(getThingPos(cid), 27)
    doPlayerAddExp(cid, exp)
    doPlayerAddItem(cid, id_item, quantidade_item)
    setPlayerStorageValue(cid, storage, 1)
    talkState[talkUser] = 0
  return true
  end

end
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Now go to Data/Creaturescripts/Scripts and create a file called task_billie and add the code inside:
Lua:
local monstro = "Magmar" -- MONSTER NAME
local quantidade = 50 -- MONSTER QUANTITY
local storage_npc = 34900 -- DON'T MOVE
local storage_quantidade = 32510 -- DON'T MOVE
local storage_task = 32600 -- DON'T MOVE

function onKill(cid, target, lasthit)

if getPlayerStorageValue(cid, storage_npc) > 0 then
   if getPlayerStorageValue(cid, storage_task) < 1 then
      if getPlayerStorageValue(cid, storage_quantidade) < quantidade then
         if isPlayer(cid) and getCreatureName(target) == monstro then             
            local restantes = quantidade - getPlayerStorageValue(cid, storage_quantidade)
            doPlayerSendTextMessage(cid, 27, "Billie: " ..restantes.. " " ..monstro.. " restantes para derrotar." ) 
    setPlayerStorageValue(cid, storage_quantidade, getPlayerStorageValue(cid, storage_quantidade) + 1)
         return true
         end
    
      elseif getPlayerStorageValue(cid, storage_quantidade) == quantidade then
         doPlayerSendTextMessage(cid, 27, "Billie: You don't have more " ..monstro.. " to defeat. Come back to get your reward.")
         setPlayerStorageValue(cid, storage_quantidade, -1)
         setPlayerStorageValue(cid, storage_task, 1)
      return true
      end

   else
     return true
   end

else
  return true
end

end
Still in Data/Creaturescripts/Scripts, open the login.lua file and look for the part where the event records are located in the code, and add the following line under the last event:
Lua:
registerCreatureEvent(cid, "task_billie")
And finally, in Data/Creaturescripts open creaturescripts.xml and add the tag:
XML:
<event type="kill" name="task_billie" script="task_billie.lua"/>
But I'm not sure if it will work... Let's take advantage and test it there.
 
Last edited:
Back
Top