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

Lua npc

alcapone

Member
Joined
Jan 13, 2021
Messages
246
Reaction score
19
I have a doubt in this part

each item the player gets 1 achievement but I don't know how to check this

local IDS = {
DREAM_MATTER = 22397,
CLUSTER_OF_SOLACE = 22396,

--weapons
CRUDE_UMBRAL_BLADE = 22398,
UMBRAL_BLADE = 22399,
UMBRAL_MASTER_BLADE = 22400,

CRUDE_UMBRAL_SLAYER = 22401,
UMBRAL_SLAYER = 22402,
UMBRAL_MASTER_SLAYER = 22403,

CRUDE_UMBRAL_AXE = 22404,
UMBRAL_AXE = 22405,
UMBRAL_MASTER_AXE = 22406,

CRUDE_UMBRAL_CHOPPER = 22407,
UMBRAL_CHOPPER = 22408,
UMBRAL_MASTER_CHOPPER = 22409,

CRUDE_UMBRAL_MACE = 22410,
UMBRAL_MACE = 22411,
UMBRAL_MASTER_MACE = 22412,

CRUDE_UMBRAL_HAMMER = 22413,
UMBRAL_HAMMER = 22414,
UMBRAL_MASTER_HAMMER = 22415,

CRUDE_UMBRAL_BOW = 22416,
UMBRAL_BOW = 22417,
UMBRAL_MASTER_BOW = 22418,

CRUDE_UMBRAL_CROSSBOW = 22419,
UMBRAL_CROSSBOW = 22420,
UMBRAL_MASTER_CROSSBOW = 22421,

CRUDE_UMBRAL_SPELLBOOK = 22422,
UMBRAL_SPELLBOOK = 22423,
UMBRAL_MASTER_SPELLBOOK = 22424
}

local TYPES = {
SWORD = 1,
AXE = 2,
CLUB = 3,
BOW = 4,
CROSSBOW = 5,
SPELLBOOK = 6
}

local SUB_TYPES = {
BLADE = 1,
SLAYER = 2,
AXE = 3,
CHOPPER = 4,
MACE = 5,
HAMMER = 6,
BOW = 7,
CROSSBOW = 8,
SPELLBOOK = 9
}

local ACTION = {
CREATE = 1,
IMPROVE = 2,
TRANSFORM = 3
}
Lua:
elseif action[cid] == ACTION.TRANSFORM then --transform

            local oldItemId = (weapon[cid] == TYPES.SWORD and (weapon_sub[cid] == SUB_TYPES.BLADE and IDS.UMBRAL_BLADE or IDS.UMBRAL_SLAYER) or weapon[cid] == TYPES.AXE and (weapon_sub[cid] == SUB_TYPES.AXE and IDS.UMBRAL_AXE or IDS.UMBRAL_CHOPPER) or weapon[cid] == TYPES.CLUB and (weapon_sub[cid] == SUB_TYPES.MACE and IDS.UMBRAL_MACE or IDS.UMBRAL_HAMMER) or weapon[cid] == TYPES.BOW and IDS.UMBRAL_BOW or weapon[cid] == TYPES.CROSSBOW and IDS.UMBRAL_CROSSBOW or weapon[cid] == TYPES.SPELLBOOK and IDS.UMBRAL_SPELLBOOK or false)

            local newItemId =  (oldItemId and oldItemId + 1 or false)

            if player:getItemCount(IDS.CLUSTER_OF_SOLACE) >= Config.Transform.Clusters then

                if newItemId and oldItemId then

                    if player:getItemCount(oldItemId) > 0 then

                        if math.random(100) <= Config.Transform.Chance then

                            player:removeItem(oldItemId, 1)

                            player:addItem(newItemId)

                            player:removeItem(IDS.CLUSTER_OF_SOLACE, Config.Transform.Clusters)

                         

                             -- player:addAchievement('Umbral Archer')

                            --player:addAchievement('Umbral Berserker')

                            --player:addAchievement('Umbral Bladelord')

                            --player:addAchievement('Umbral Brawler')

                        --    player:addAchievement('Umbral Executioner')

                        --    player:addAchievement('Umbral Harbringer')

                        --    player:addAchievement('Umbral Headsman')

                        --    player:addAchievement('Umbral Marksman')

                        --    player:addAchievement('Umbral Master')

                        --    player:addAchievement('Umbral Swordsman')

                         

                            npcHandler:say("Your dreams are strong, the transforming was successful. Take your " .. ItemType(newItemId):getName() .. ".", cid)

                        else

                            npcHandler:say("Oh no! The process failed.", cid)

                            local rand = math.random(100)

                            if Config.Transform.BreakChance <= rand then

                                player:removeItem(oldItemId, 1)

                            else

                                player:removeItem(oldItemId, 1)

                                player:addItem(oldItemId - 1, 1)

                                player:removeItem(IDS.CLUSTER_OF_SOLACE, Config.Transform.Clusters / 2)

                            end

                        end

                    else

                        npcHandler:say("You do not have " .. ItemType(oldItemId):getArticle() .. " " .. ItemType(oldItemId):getName() .. " with you.", cid)

                    end

                else

                    npcHandler:say("Something weird happened! You should contact a gamemaster.", cid)

                end

            end

        end

        npcHandler:releaseFocus(cid)

        npcHandler:resetNpc()

    end

end
 
I have a hard time to understand what you're trying to accomplish.
And which TFS version are you using?

Is the issue that you want to check if the player have a certain item and if so give them an achievement?
If thats the case you could use something like item onMove, however the item could just be passed around to other players, if that matters.
 
I have a hard time to understand what you're trying to accomplish.
And which TFS version are you using?

Is the issue that you want to check if the player have a certain item and if so give them an achievement?
If thats the case you could use something like item onMove, however the item could just be passed around to other players, if that matters.
npc Eruaran (https://tibia.fandom.com/wiki/Eruaran)

I'm using TFS, the npc file is too big but the main part is above
if he transforms the item the player will get the achievement
he will transform the sword into a master if he succeeds he will win the achievement
 
npc Eruaran (https://tibia.fandom.com/wiki/Eruaran)

I'm using TFS, the npc file is too big but the main part is above
if he transforms the item the player will get the achievement
he will transform the sword into a master if he succeeds he will win the achievement
Here use Pastebin.com - #1 paste tool since 2002! (https://pastebin.com/) to paste entire script.
Ok then I understand what you want, are you having problem with both transforming the item and giving the achievement?
 
Here use Pastebin.com - #1 paste tool since 2002! (https://pastebin.com/) to paste entire script.
Ok then I understand what you want, are you having problem with both transforming the item and giving the achievement?
the part of transforming the item is right but the achievement does not exist that part that I am not able to do
 
Are you even trying?

Lua:
local achievements = {
    [IDS.UMBRAL_MASTER_BLADE] = "Umbral Bladelord"
}

player:addAchievement(achievements[newItemId])

Paste the achievements table after IDS table
You dont have to worry about sending an achievement multiple times (in case the item gets downgraded), the function will take care of this
 
Are you even trying?

Lua:
local achievements = {
    [IDS.UMBRAL_MASTER_BLADE] = "Umbral Bladelord"
}

player:addAchievement(achievements[newItemId])

Paste the achievements table after IDS table
You dont have to worry about sending an achievement multiple times (in case the item gets downgraded), the function will take care of this
it worked I was thinking that I would need to check if the player already had the achievement I was trying something completely opposite
 
Back
Top