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

[TFS 1.0] Grizzly Adams: getTasksByPlayer

EvoSoft

Is Da Mapper
Joined
Mar 10, 2010
Messages
693
Reaction score
5
Location
Northen part of Sweden
7d146e2ea0c898f5b402bb3376b8be79.png


Script: Github - PrinterLUA
 
That's because not all servers use a file called global.lua as lib file.
TFS 1.0 uses global.lua as lib file, so you have to add the lib things there.
 
That's because not all servers use a file called global.lua as lib file.
TFS 1.0 uses global.lua as lib file, so you have to add the lib things there.
So I just add this to global:
Code:
RANK_NONE = 0
RANK_HUNTSMAN = 1
RANK_RANGER = 2
RANK_BIGGAMEHUNTER = 3
RANK_TROPHYHUNTER = 4
RANK_ELITEHUNTER = 5

REWARD_MONEY = 1
REWARD_EXP = 2
REWARD_ACHIEVEMENT = 3
REWARD_STORAGE = 4
REWARD_POINT = 5
REWARD_ITEM = 6

QUESTSTORAGE_BASE = 1500
KILLSSTORAGE_BASE = 65000
REPEATSTORAGE_BASE = 48950
POINTSSTORAGE = 2500
tasks =
{
--Tasks for level 6 to 49.
[1] = {killsRequired = 100, raceName = "Trolls", level = {6, 19}, premium = true, creatures = {"troll", "troll champion", "island troll", "swamp troll"}, rewards = {
{type = "exp", value = {200}},
{type = "money", value = {200}}
}},
[2] = {killsRequired = 150, raceName = "Goblins", level = {6, 19}, premium = true, creatures = {"goblin", "goblin assassin", "goblin leader"}, rewards = {
{type = "exp", value = {300}},
{type = "money", value = {250}}
}},
[3] = {killsRequired = 300, raceName = "Crocodiles", level = {6, 49}, premium = true, creatures = {"crocodile"}, rewards = {
{type = "exp", value = {800}},
{type = "achievement", value = {"Blood-Red Snapper"}},
{type = "storage", value = {35000, 1}},
{type = "points", value = {1}}
}},
[4] = {killsRequired = 300, raceName = "Badgers", level = {6, 49}, premium = true, creatures = {"badger"}, rewards = {
{type = "exp", value = {500}},
{type = "points", value = {1}}
}},
[5] = {killsRequired = 300, raceName = "Tarantulas", level = {6, 49}, premium = true, creatures = {"tarantula"}, rewards = {
{type = "exp", value = {1500}},
{type = "achievement", value = {"No More Hiding"}},
{type = "storage", value = {35001, 1}},
{type = "points", value = {2}}
}},
[6] = {killsRequired = 150, raceName = "Carniphilas", level = {6, 49}, premium = true, creatures = {"carniphila"}, rewards = {
{type = "exp", value = {2500}},
{type = "achievement", value = {"Rootless Behaviour"}},
{type = "storage", value = {35002, 1}},
{type = "points", value = {3}}
}},
[7] = {killsRequired = 200, raceName = "Stone Golems", level = {6, 49}, premium = true, creatures = {"stone golem"}, rewards = {
{type = "exp", value = {2000}},
{type = "points", value = {3}}
}},
[8] = {killsRequired = 300, raceName = "Mammoths", level = {6, 49}, premium = true, creatures = {"mammoth"}, rewards = {
{type = "exp", value = {4000}},
{type = "achievement", value = {"Meat Skewer"}},
{type = "storage", value = {35003, 1}},
{type = "points", value = {3}}
}},
[9] = {killsRequired = 300, raceName = "Gnarlhounds", level = {6, 49}, premium = true, creatures = {"gnarlhound"}, rewards = {
{type = "exp", value = {1000}},
{type = "points", value = {2}}
}},
[10] = {killsRequired = 300, raceName = "Terramites", level = {6, 49}, premium = true, creatures = {"terramite"}, rewards = {
{type = "exp", value = {1000}},
{type = "points", value = {2}}
}},
[11] = {killsRequired = 300, raceName = "Apes", level = {6, 49}, premium = true, creatures = {"kongra", "sibang", "merklin"}, rewards = {
{type = "exp", value = {1000}},
{type = "points", value = {2}}
}},
[12] = {killsRequired = 300, raceName = "Thornback Tortoises", level = {6, 49}, premium = true, creatures = {"thornback tortoise"}, rewards = {
{type = "exp", value = {1500}},
{type = "points", value = {2}}
}},
[13] = {killsRequired = 300, raceName = "Gargoyles", level = {6, 49}, premium = true, creatures = {"gargoyle"}, rewards = {
{type = "exp", value = {1500}}
}},

--Tasks for level 50 to 79.
(and more........)
 
EvoSoft,

The lack of Lua tag functionality makes it difficult for you to see what must be added.
You need to add all the functions to global.lua as well.

Copied from that thread:
Code:
tasksByPlayer = 3
repeatTimes = 3

function getPlayerRank(cid)
return (getPlayerStorageValue(cid, POINTSSTORAGE) >= 100 and RANK_ELITEHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 70 and RANK_TROPHYHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 40 and RANK_BIGGAMEHUNTER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 20 and RANK_RANGER or getPlayerStorageValue(cid, POINTSSTORAGE) >= 10 and RANK_HUNTSMAN or RANK_NONE)
end

function getTaskByName(name, table)
local t = (table and table or tasks)
for k, v in pairs(t) do
if v.name then
if v.name:lower() == name:lower() then
return k
end
else
if v.raceName:lower() == name:lower() then
return k
end
end
end
return false
end

function getTasksByPlayer(cid)
local canmake = {}
local able = {}
for k, v in pairs(tasks) do
if getCreatureStorage(cid, QUESTSTORAGE_BASE + k) < 1 and getCreatureStorage(cid, REPEATSTORAGE_BASE + k) < repeatTimes then
able[k] = true
if getPlayerLevel(cid) < v.level[1] or getPlayerLevel(cid) > v.level[2] then
able[k] = false
end
if v.storage and getCreatureStorage(cid, v.storage[1]) < v.storage[2] then
able[k] = false
end

if v.rank then
if getPlayerRank(cid) < v.rank then
able[k] = false
end
end

if v.premium then
if not isPremium(cid) then
able[k] = false
end
end

if able[k] then
table.insert(canmake, k)
end
end
end
return canmake
end


function canStartTask(cid, name, table)
local v = ""
local id = 0
local t = (table and table or tasks)
for k, i in pairs(t) do
if i.name then
if i.name:lower() == name:lower() then
v = i
id = k
break
end
else
if i.raceName:lower() == name:lower() then
v = i
id = k
break
end
end
end
if v == "" then
return false
end
if getCreatureStorage(cid, QUESTSTORAGE_BASE + id) > 0 then
return false
end
if (getCreatureStorage(cid, REPEATSTORAGE_BASE + id) >= repeatTimes) or (v.norepeatable and getCreatureStorage(cid, REPEATSTORAGE_BASE + id) > 0) then
return false
end
if getPlayerLevel(cid) >= v.level[1] and getPlayerLevel(cid) <= v.level[2] then
if v.premium then
if isPremium(cid) then
if v.rank then
if getPlayerRank(cid) >= v.rank then
if v.storage then 
if getCreatureStorage(cid, v.storage[1]) >= v.storage[2] then
return true
end
else
return true
end
end
else
return true
end
end
else
return true
end
end
return false
end

function getPlayerStartedTasks(cid)

local tmp = {}
for k, v in pairs(tasks) do
if getCreatureStorage(cid, QUESTSTORAGE_BASE + k) > 0 and getCreatureStorage(cid, QUESTSTORAGE_BASE + k) < 2 then
table.insert(tmp, k) 
end
end
return tmp
end

function isSummon(cid)
return getCreatureMaster(cid) ~= cid or false
end
 
You need to use 1.0 lua functions. getCreatureStorage() doesn't exist, you need to use Player:getStorageValue().
 
It really wasn't made for 1.0, there are a lot of changes needed to be made in order for it to work in 1.0.
We can't convert it all for you, but you are always welcome to come here for script conversion questions/help.
 
You can add compats so you won't have to change it in the script.

Add this in global.lua or at the bottom of compat.lua.
Code:
getCreatureStorage = getPlayerStorageValue
doCreatureSetStorage = setPlayerStorageValue
getThingPosition = getThingPos
 
Thanks, @Limos ! But it still won't count kills :/ Is there something wrong with my creaturescript?
Code:
function onKill(cid, target, lastHit)
   local started = getPlayerStartedTasks(cid)
   if isPlayer(target) or isSummon(target) then return true end
   if started and #started > 0 then
     for _, id in ipairs(started) do
       if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
         if getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
           setPlayerStorageValue(cid, KILLSSTORAGE_BASE + id, getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) + 1)
         end
       end
     end
   end
   return true
end

(No errors in the console)
 
Thanks, @Limos ! But it still won't count kills :/ Is there something wrong with my creaturescript?
Code:
function onKill(cid, target, lastHit)
   local started = getPlayerStartedTasks(cid)
   if isPlayer(target) or isSummon(target) then return true end
   if started and #started > 0 then
     for _, id in ipairs(started) do
       if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
         if getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
           setPlayerStorageValue(cid, KILLSSTORAGE_BASE + id, getPlayerStorageValue(cid, KILLSSTORAGE_BASE + id) + 1)
         end
       end
     end
   end
   return true
end

(No errors in the console)
try this one!
Code:
function onKill(cid, target, lastHit)
    local started = getPlayerStartedTasks(cid)
    if isPlayer(target) or isSummon(target) then return true end
    if started and #started > 0 then
        for _, id in ipairs(started) do
            if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < 0 then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, 0)
                end
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) .. "/" .. tasks[id].killsRequired .. " " .. tasks[id].raceName .. " already killed.")
                end
            end
        end
    end
    return true
end
 
try this one!
Code:
function onKill(cid, target, lastHit)
    local started = getPlayerStartedTasks(cid)
    if isPlayer(target) or isSummon(target) then return true end
    if started and #started > 0 then
        for _, id in ipairs(started) do
            if isInArray(tasks[id].creatures, getCreatureName(target):lower()) then
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < 0 then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, 0)
                end
                if getCreatureStorage(cid, KILLSSTORAGE_BASE + id) < tasks[id].killsRequired then
                    doCreatureSetStorage(cid, KILLSSTORAGE_BASE + id, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getCreatureStorage(cid, KILLSSTORAGE_BASE + id) .. "/" .. tasks[id].killsRequired .. " " .. tasks[id].raceName .. " already killed.")
                end
            end
        end
    end
    return true
end
Doesn't work :/

Now I get these errors, dunno if it's this script though
ba57be7316920b12dbc34ae8cb45505f.png
 
Back
Top