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

Lua Problem with getSlotItem (TFS 1.1)

Darkeyren

New Member
Joined
Oct 8, 2011
Messages
11
Reaction score
1
Hello guys, i'm doing my own Pet System and i can't pick the informations of CONST_SLOT_ARMOR, i don't know why... Any one can help me ?

Code:
function onDeath(player)

local pokeball = player:getSlotItem(CONST_SLOT_ARMOR)
local description = pokeball:getDescription(distance)
local pokename, health, maxhp, dead = string.match(description, "(%a+)/(%d+)/(%d+)/(%a+)")       

if #player:getSummons() == 0 then
    player:say("Your pokemon are fainted.", TALKTYPE_MONSTER_SAY)
    pokeball:setAttribute("description", ""..pokename.."/"..healthdead.."/"..maxhp.."/Dead/ Pertece a "..player:getName()..".")
end
end

Sorry for my english...
 
Any error?

Off the top of my head, it may not be called CONST_SLOT_ARMOR in tfs 1.1. Try using the slots number instead:
Code:
player:getSlotItem(4)
 
Any error?

Off the top of my head, it may not be called CONST_SLOT_ARMOR in tfs 1.1. Try using the slots number instead:
Code:
player:getSlotItem(4)

71SL5Ky.png


It is called CONST_SLOT_ARMOR, try checking if pokeball is an item
Code:
print(pokeball:isItem())
https://github.com/otland/forgottenserver/search?utf8=✓&q=CONST_SLOT_ARMOR

I tried using it but getSlotItem always returns null..
 
Code:
function onDeath(monster)
    local master = monster:getMaster()
    if not master then
        return true
    end

    local pokeball = master:getSlotItem(CONST_SLOT_ARMOR)
    if not pokeball then
        return true
    end

    local pokeName, pokeHealth, pokeMaxHealth, pokeDead = string.match(description, "(%a+)/(%d+)/(%d+)/(%a+)")
        master:say("Your pokemon are fainted.", TALKTYPE_MONSTER_SAY)
    pokeball:setAttribute("description", string.format("%s/%i/%i/Dead/ Pertece a %s", pokeName, pokeHealth, pokeMaxHealth, pokeDead))
    return true
end
 
Code:
function onDeath(monster)
    local master = monster:getMaster()
    if not master then
        return true
    end

    local pokeball = master:getSlotItem(CONST_SLOT_ARMOR)
    if not pokeball then
        return true
    end

    local pokeName, pokeHealth, pokeMaxHealth, pokeDead = string.match(description, "(%a+)/(%d+)/(%d+)/(%a+)")
        master:say("Your pokemon are fainted.", TALKTYPE_MONSTER_SAY)
    pokeball:setAttribute("description", string.format("%s/%i/%i/Dead/ Pertece a %s", pokeName, pokeHealth, pokeMaxHealth, pokeDead))
    return true
end

Work's, thank you... I just added
Code:
local description = pokeball:getDescription(distance)

:P
 
Back
Top