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

Summons familiars

lopez65

Member
Joined
May 10, 2012
Messages
289
Solutions
1
Reaction score
14
Location
Barcelona
hello
I am trying to create a few second family summons and I get this error:

C++:
The Demon Helmet Server - Version: (TFS 1.4)
Compiled with: Microsoft Visual C++ version 14.2
x64
Linked with LuaJIT 2.0.5 for Lua support

A server developed by Mark Samman and The Forgotten Server Developers

>> Client Version: 12.70

C++:
Lua Script Error: [Scripts Interface]
C:\otserv\data\scripts\creaturescripts\others\familia.lua:callback
C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: attempt to call method 'getfamiliaLooktype' (a nil value)
stack traceback:
        [C]: in function 'getfamiliaLooktype'
        C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: in function <C:\otserv\data\scripts\creaturescripts\others\familia.lua:35>
ADM has logged out. | Client: 12.61


I admit that I am very green, but on another server I did get it,
I changed all the related files called familiars by family, I have also changed the looktype ids for others and you can see the result, also because of this error I cannot enter with the GM, I am using TFS 1.4, server 12.70.
someone who understands can help me
Thank you

edit: here the familia.lua that gives the error

Lua:
local familia = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 133, name = "Sorcerer familia"},
    [VOCATION.CLIENT_ID.DRUID] = {id = 58, name = "Druid familia"},
    [VOCATION.CLIENT_ID.PALADIN] = {id = 152, name = "Paladin familia"},
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 131, name = "Knight familia"}
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiaStorage = Storage.PetSummon

local familiaLogin = CreatureEvent("familiaLogin")

function familiaLogin.onLogin(player)
    local vocation = familia[player:getVocation():getClientId()]
    local familiaName
    local petTimeLeft = player:getStorageValue(familiaStorage) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasfamilia(vocation.id)) or player:getLevel() < 100 then
                player:removefamilia(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 100 then
            if petTimeLeft > 0 then
                familiaName = vocation.name
            end
            if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
            end
            if not player:hasfamilia(vocation.id) then
                player:addfamilia(vocation.id)
            end
        end
    end

    if familiaName then
        position = player:getPosition()
        local familiaMonster = Game.createMonster(familiaName, position, true, false)
        player:addSummon(familiaMonster)
        familiaMonster:setOutfit({lookType = player:getfamiliaLooktype()})
        --familiaMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiaMonster:getSpeed(), 0)
        familiaMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiaStorage, os.time() + petTimeLeft)
        familiaMonster:registerEvent("familiaDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiaMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiaLogin:register()

local advancefamilia = CreatureEvent("Advancefamilia")

function advancefamilia.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familia[player:getVocation():getClientId()]
    if newLevel >= 100 and isPremium(player) then
        if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
        end
        if not player:hasfamilia(vocation.id) then
            player:addfamilia(vocation.id)
        end
    end
    return true
end

advancefamilia:register()

local familiaDeath = CreatureEvent("familiaDeath")

function familiaDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familia[player:getVocation():getClientId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiaStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiaDeath:register()
 
hello
I am trying to create a few second family summons and I get this error:

C++:
The Demon Helmet Server - Version: (TFS 1.4)
Compiled with: Microsoft Visual C++ version 14.2
x64
Linked with LuaJIT 2.0.5 for Lua support

A server developed by Mark Samman and The Forgotten Server Developers

>> Client Version: 12.70

C++:
Lua Script Error: [Scripts Interface]
C:\otserv\data\scripts\creaturescripts\others\familia.lua:callback
C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: attempt to call method 'getfamiliaLooktype' (a nil value)
stack traceback:
        [C]: in function 'getfamiliaLooktype'
        C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: in function <C:\otserv\data\scripts\creaturescripts\others\familia.lua:35>
ADM has logged out. | Client: 12.61


I admit that I am very green, but on another server I did get it,
I changed all the related files called familiars by family, I have also changed the looktype ids for others and you can see the result, also because of this error I cannot enter with the GM, I am using TFS 1.4, server 12.70.
someone who understands can help me
Thank you

edit: here the familia.lua that gives the error

Lua:
local familia = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 133, name = "Sorcerer familia"},
    [VOCATION.CLIENT_ID.DRUID] = {id = 58, name = "Druid familia"},
    [VOCATION.CLIENT_ID.PALADIN] = {id = 152, name = "Paladin familia"},
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 131, name = "Knight familia"}
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiaStorage = Storage.PetSummon

local familiaLogin = CreatureEvent("familiaLogin")

function familiaLogin.onLogin(player)
    local vocation = familia[player:getVocation():getClientId()]
    local familiaName
    local petTimeLeft = player:getStorageValue(familiaStorage) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasfamilia(vocation.id)) or player:getLevel() < 100 then
                player:removefamilia(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 100 then
            if petTimeLeft > 0 then
                familiaName = vocation.name
            end
            if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
            end
            if not player:hasfamilia(vocation.id) then
                player:addfamilia(vocation.id)
            end
        end
    end

    if familiaName then
        position = player:getPosition()
        local familiaMonster = Game.createMonster(familiaName, position, true, false)
        player:addSummon(familiaMonster)
        familiaMonster:setOutfit({lookType = player:getfamiliaLooktype()})
        --familiaMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiaMonster:getSpeed(), 0)
        familiaMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiaStorage, os.time() + petTimeLeft)
        familiaMonster:registerEvent("familiaDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiaMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiaLogin:register()

local advancefamilia = CreatureEvent("Advancefamilia")

function advancefamilia.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familia[player:getVocation():getClientId()]
    if newLevel >= 100 and isPremium(player) then
        if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
        end
        if not player:hasfamilia(vocation.id) then
            player:addfamilia(vocation.id)
        end
    end
    return true
end

advancefamilia:register()

local familiaDeath = CreatureEvent("familiaDeath")

function familiaDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familia[player:getVocation():getClientId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiaStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiaDeath:register()
nil value means that the function does not exist.

You either need to create/add the function or remove that function from your script.
 
Hello sir
Could you be a little more explicit, that is, how to add or remove it.
thanks for your answer.
To remove, delete these 3 lines (47, 48, 49)
Lua:
            if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
            end
 
To remove, delete these 3 lines (47, 48, 49)
Lua:
            if player:getfamiliaLooktype() == 0 then
                player:setfamiliaLooktype(vocation.id)
            end
I have deleted those three lines from family.lua and now I get this error:

C++:
Lua Script Error: [Scripts Interface]
C:\otserv\data\scripts\creaturescripts\others\familia.lua:callback
C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: attempt to call method 'hasfamilia' (a nil value)
stack traceback:
        [C]: in function 'hasfamilia'
        C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: in function <C:\otserv\data\scripts\creaturescripts\others\familia.lua:35>

but just to ask you, I also have to delete the 3 lines of the original?, that is, the one that already comes with the server.
thanks
 
I have deleted those three lines from family.lua and now I get this error:

C++:
Lua Script Error: [Scripts Interface]
C:\otserv\data\scripts\creaturescripts\others\familia.lua:callback
C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: attempt to call method 'hasfamilia' (a nil value)
stack traceback:
        [C]: in function 'hasfamilia'
        C:\otserv\data\scripts\creaturescripts\others\familia.lua:47: in function <C:\otserv\data\scripts\creaturescripts\others\familia.lua:35>

but just to ask you, I also have to delete the 3 lines of the original?, that is, the one that already comes with the server.
thanks
Wherever you got your script from, I'd re-check that you got all the code.

I can guess what it's checking, but I don't know how or what else it ties into.
 
Wherever you got your script from, I'd re-check that you got all the code.

I can guess what it's checking, but I don't know how or what else it ties into.
the scripts is the one for summoning the pets at level 200 and that one comes on all the servers and it is this:

Lua:
local familiar = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 994, name = "Sorcerer familiar"}, -->Thundergiant
    [VOCATION.CLIENT_ID.DRUID] = {id = 993, name = "Druid familiar"}, -->Grovebeast
    [VOCATION.CLIENT_ID.PALADIN] = {id = 992, name = "Paladin familiar"}, -->Emberwing
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 991, name = "Knight familiar"} -->Skullfrost
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiarStorage = Storage.PetSummon

local familiarLogin = CreatureEvent("FamiliarLogin")

function familiarLogin.onLogin(player)
    local vocation = familiar[player:getVocation():getClientId()]
    local familiarName
    local petTimeLeft = player:getStorageValue(familiarStorage) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasFamiliar(vocation.id)) or player:getLevel() < 200 then
                player:removeFamiliar(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 200 then
            if petTimeLeft > 0 then
                familiarName = vocation.name
            end
            if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
            end
            if not player:hasFamiliar(vocation.id) then
                player:addFamiliar(vocation.id)
            end
        end
    end

    if familiarName then
        position = player:getPosition()
        local familiarMonster = Game.createMonster(familiarName, position, true, false)
        player:addSummon(familiarMonster)
        familiarMonster:setOutfit({lookType = player:getFamiliarLooktype()})
        --familiarMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiarMonster:getSpeed(), 0)
        familiarMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiarStorage, os.time() + petTimeLeft)
        familiarMonster:registerEvent("FamiliarDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiarMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiarLogin:register()

local advanceFamiliar = CreatureEvent("AdvanceFamiliar")

function advanceFamiliar.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familiar[player:getVocation():getClientId()]
    if newLevel >= 200 and isPremium(player) then
        if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
        end
        if not player:hasFamiliar(vocation.id) then
            player:addFamiliar(vocation.id)
        end
    end
    return true
end

advanceFamiliar:register()

local familiarDeath = CreatureEvent("FamiliarDeath")

function familiarDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familiar[player:getVocation():getClientId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiarStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiarDeath:register()
 
the scripts is the one for summoning the pets at level 200 and that one comes on all the servers and it is this:

Lua:
local familiar = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 994, name = "Sorcerer familiar"}, -->Thundergiant
    [VOCATION.CLIENT_ID.DRUID] = {id = 993, name = "Druid familiar"}, -->Grovebeast
    [VOCATION.CLIENT_ID.PALADIN] = {id = 992, name = "Paladin familiar"}, -->Emberwing
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 991, name = "Knight familiar"} -->Skullfrost
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiarStorage = Storage.PetSummon

local familiarLogin = CreatureEvent("FamiliarLogin")

function familiarLogin.onLogin(player)
    local vocation = familiar[player:getVocation():getClientId()]
    local familiarName
    local petTimeLeft = player:getStorageValue(familiarStorage) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasFamiliar(vocation.id)) or player:getLevel() < 200 then
                player:removeFamiliar(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 200 then
            if petTimeLeft > 0 then
                familiarName = vocation.name
            end
            if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
            end
            if not player:hasFamiliar(vocation.id) then
                player:addFamiliar(vocation.id)
            end
        end
    end

    if familiarName then
        position = player:getPosition()
        local familiarMonster = Game.createMonster(familiarName, position, true, false)
        player:addSummon(familiarMonster)
        familiarMonster:setOutfit({lookType = player:getFamiliarLooktype()})
        --familiarMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiarMonster:getSpeed(), 0)
        familiarMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiarStorage, os.time() + petTimeLeft)
        familiarMonster:registerEvent("FamiliarDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiarMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiarLogin:register()

local advanceFamiliar = CreatureEvent("AdvanceFamiliar")

function advanceFamiliar.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familiar[player:getVocation():getClientId()]
    if newLevel >= 200 and isPremium(player) then
        if player:getFamiliarLooktype() == 0 then
                player:setFamiliarLooktype(vocation.id)
        end
        if not player:hasFamiliar(vocation.id) then
            player:addFamiliar(vocation.id)
        end
    end
    return true
end

advanceFamiliar:register()

local familiarDeath = CreatureEvent("FamiliarDeath")

function familiarDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familiar[player:getVocation():getClientId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiarStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiarDeath:register()
Think I see the issue.

all of your code has lowercase F's

getfamilia -> should be normal camelcase getFamilia
and all the other one's add/remove/get

I updated your original code with that change in mind.
try this
Lua:
local familia = {
    [VOCATION.CLIENT_ID.SORCERER] = {id = 133, name = "Sorcerer familia"},
    [VOCATION.CLIENT_ID.DRUID] = {id = 58, name = "Druid familia"},
    [VOCATION.CLIENT_ID.PALADIN] = {id = 152, name = "Paladin familia"},
    [VOCATION.CLIENT_ID.KNIGHT] = {id = 131, name = "Knight familia"}
}

local timer = {
    [1] = {storage=Storage.PetSummonEvent10, countdown=10, message = "10 seconds"},
    [2] = {storage=Storage.PetSummonEvent60, countdown=60, message = "one minute"}
}

local function sendMessageFunction(pid, message)
    if Player(pid) then
        Player(pid):sendTextMessage(MESSAGE_LOOT, "Your summon will disappear in less than " .. message)
    end
end

local function removePet(creatureId, playerId)
    local creature = Creature(creatureId)
    local player = Player(playerId)
    if not creature or not player then
        return true
    end
    creature:remove()
    for sendMessage = 1, #timer do
        player:setStorageValue(timer[sendMessage].storage, -1)
    end
end

local familiaStorage = Storage.PetSummon

local familiaLogin = CreatureEvent("familiaLogin")

function familiaLogin.onLogin(player)
    local vocation = familia[player:getVocation():getClientId()]
    local familiaName
    local petTimeLeft = player:getStorageValue(familiaStorage) - player:getLastLogout()
    
    if vocation then
        if (not isPremium(player) and player:hasFamilia(vocation.id)) or player:getLevel() < 100 then
                player:removeFamilia(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 100 then
            if petTimeLeft > 0 then
                familiaName = vocation.name
            end
            if player:getFamiliaLooktype() == 0 then
                player:setFamiliaLooktype(vocation.id)
            end
            if not player:hasFamilia(vocation.id) then
                player:addFamilia(vocation.id)
            end
        end
    end
    
    if familiaName then
        position = player:getPosition()
        local familiaMonster = Game.createMonster(familiaName, position, true, false)
        player:addSummon(familiaMonster)
        familiaMonster:setOutfit({lookType = player:getFamiliaLooktype()})
        --familiaMonster:reload()
        local deltaSpeed = math.max(player:getSpeed() - familiaMonster:getSpeed(), 0)
        familiaMonster:changeSpeed(deltaSpeed)
        player:setStorageValue(familiaStorage, os.time() + petTimeLeft)
        familiaMonster:registerEvent("familiaDeath")
        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(removePet, petTimeLeft*1000, familiaMonster:getId(), player:getId())
        for sendMessage = 1, #timer do
            if player:getStorageValue(timer[sendMessage].storage) == -1 and petTimeLeft >= timer[sendMessage].countdown then
                player:setStorageValue(timer[sendMessage].storage, addEvent(sendMessageFunction, (petTimeLeft-timer[sendMessage].countdown)*1000, player:getId(), timer[sendMessage].message))
            end
        end
    end
    return true
end

familiaLogin:register()

local advancefamilia = CreatureEvent("Advancefamilia")

function advancefamilia.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = familia[player:getVocation():getClientId()]
    if newLevel >= 100 and isPremium(player) then
        if player:getFamiliaLooktype() == 0 then
                player:setFamiliaLooktype(vocation.id)
        end
        if not player:hasFamilia(vocation.id) then
            player:addFamilia(vocation.id)
        end
    end
    return true
end

advancefamilia:register()

local familiaDeath = CreatureEvent("familiaDeath")

function familiaDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified,
                                                                                                mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end
    local vocation = familia[player:getVocation():getClientId()]
    
    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(familiaStorage, os.time())
        for sendMessage = 1, #timer do
            stopEvent(player:getStorageValue(timer[sendMessage].storage))
            player:setStorageValue(timer[sendMessage].storage, -1)
        end
    end
    return true
end

familiaDeath:register()
 

Xikini


Having forgotten everything else, looking for what you told me to add or create them, I found these three scripts in an OTBr 12.86 version:

now the error is in Onlogin.lua:

C++:
Lua Script Error: [Scripts Interface]
C:\otserv\data\scripts\creaturescripts\familia\on_login.lua:callback
C:\otserv\data\scripts\creaturescripts\familia\on_login.lua:8: attempt to call method 'getBaseId' (a nil value)
stack traceback:
        [C]: in function 'getBaseId'
        C:\otserv\data\scripts\creaturescripts\familia\on_login.lua:8: in function <C:\otserv\data\scripts\creaturescripts\familia\on_login.lua:3>

I guess this will help you to help me, sorry for the redundancy xDD.
Thank you


Lua:
local familiaOnLogin = CreatureEvent("FamiliaLogin")

function familiaOnLogin.onLogin(player)
    if not player then
        return false
    end

    local vocation = FAMILIA_ID[player:getVocation():getBaseId()]

    local familiaName
    local familiaTimeLeft = player:getStorageValue(Storage.FamiliaSummon) - player:getLastLogout()

    if vocation then
        if (not isPremium(player) and player:hasFamilia(vocation.id)) or player:getLevel() < 100 then
            player:removeFamilia(vocation.id)
        elseif isPremium(player) and player:getLevel() >= 100 then
            if familiaTimeLeft > 0 then
                familiaName = vocation.name
            end
            if player:getFamiliaLooktype() == 0 then
                player:setFamiliaLooktype(vocation.id)
            end
            if not player:hasFamilia(vocation.id) then
                player:addFamilia(vocation.id)
            end
        end
    end

    if familiaName then
        local position = player:getPosition()
        local familiaMonster = Game.createMonster(familiaName, position, true, false, player)
        if familiarMonster then

            familiaMonster:setOutfit({lookType = player:getFamiliaLooktype()})
            familiaMonster:registerEvent("FamiliaDeath")
            position:sendMagicEffect(CONST_ME_MAGIC_BLUE)

            local deltaSpeed = math.max(player:getSpeed() - familiaMonster:getSpeed(), 0)
            familiaMonster:changeSpeed(deltaSpeed)

            player:setStorageValue(Storage.FamiliaSummon, os.time() + familiaTimeLeft)
            addEvent(RemoveFamilia, familiaTimeLeft*1000, familiaMonster:getId(), player:getId())

            for sendMessage = 1, #FAMILIA_TIMER do
                if player:getStorageValue(FAMILIA_TIMER[sendMessage].storage) == -1
                and familiaTimeLeft >= FAMILIA_TIMER[sendMessage].countdown then
                    player:setStorageValue(
                        -- Storage key param
                        FAMILIA_TIMER[sendMessage].storage,
                        -- Storage value param start
                        addEvent(
                            SendMessageFunction,
                            (familiaTimeLeft-FAMILIA_TIMER[sendMessage].countdown) * 1000,
                            player:getId(),
                            FAMILIA_TIMER[sendMessage].message
                        )
                        -- Storage value param end
                    )
                end
            end
        end
    end
    return true
end

familiaOnLogin:register()

Code:
local familiaOnAdvance = CreatureEvent("AdvanceFamilia")

function familiaOnAdvance.onAdvance(player, skill, oldLevel, newLevel)
    local vocation = FAMILIA_ID[player:getVocation():getBaseId()]
    if vocation and newLevel >= 100 and isPremium(player) then
        if player:getFamiliaLooktype() == 0 then
                player:setFamiliaLooktype(vocation.id)
        end
        if not player:hasFamilia(vocation.id) then
            player:addFamilia(vocation.id)
        end
    end
    return true
end

familiaOnAdvance:register()
Code:
local familiaOnDeath = CreatureEvent("FamiliaDeath")

function familiaOnDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local player = creature:getMaster()
    if not player then
        return false
    end

    local vocation = FAMILIA_ID[player:getVocation():getBaseId()]

    if table.contains(vocation, creature:getName()) then
        player:setStorageValue(Storage.FamiliaSummon, os.time())
        for sendMessage = 1, #FAMILIA_TIMER do
            stopEvent(player:getStorageValue(FAMILIA_TIMER[sendMessage].storage))
            player:setStorageValue(FAMILIA_TIMER[sendMessage].storage, -1)
        end
    end
    return true
end

familiaOnDeath:register()
 
Last edited:

Similar threads

Back
Top