function onStepIn(creature, item, position, fromPosition)
local skillToTrain = SKILL_SWORD -- Substitua SKILL_SWORD pela habilidade que você deseja treinar
local minSkill = 10 -- Substitua 10 pelo valor mínimo da habilidade para começar a treinar
local gainChance = 50 -- Chance de ganhar skill, em porcentagem
local requiredItemID = 1234 -- Substitua 1234 pelo ID do item necessário para treinar
if creature:isPlayer() then
local player = creature:getPlayer()
-- Verifica se o jogador está equipado com o item necessário
if player:getSlotItem(CONST_SLOT_RIGHT) and player:getSlotItem(CONST_SLOT_RIGHT):getId() == requiredItemID then
local skillLevel = player:getSkillLevel(skillToTrain)
if skillLevel >= minSkill then
-- Verifica se o jogador ganha skill
if math.random(100) <= gainChance then
player:addSkillTries(skillToTrain, 1)
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você ganhou experiência em " .. getSkillName(skillToTrain) .. ".")
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você não ganhou experiência em " .. getSkillName(skillToTrain) .. ".")
end
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você não tem a habilidade necessária para treinar aqui.")
end
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você precisa estar equipado com o item necessário para treinar aqui.")
end
end
return true
end
Ou pra cada vocação
function onStepIn(creature, item, position, fromPosition)
if creature:isPlayer() then
local player = creature:getPlayer()
local vocation = player:getVocation():getId()
-- Defina as habilidades correspondentes para cada vocação
local skillsToTrain = {
[VOCATION_NONE] = {SKILL_SWORD, SKILL_SHIELD}, -- Vocação sem classe
[VOCATION_KNIGHT] = {SKILL_SWORD, SKILL_SHIELD}, -- Cavaleiro
[VOCATION_PALADIN] = {SKILL_DISTANCE}, -- Paladino
[VOCATION_SORCERER] = {SKILL_MAGLEVEL}, -- Sorcerer
[VOCATION_DRUID] = {SKILL_MAGLEVEL}, -- Druida
[VOCATION_MASTER_SORCERER] = {SKILL_MAGLEVEL}, -- Mestre dos Sorcerer
[VOCATION_ELDER_DRUID] = {SKILL_MAGLEVEL} -- Mestre dos Druid
}
local minSkill = 10 -- Substitua 10 pelo valor mínimo da habilidade para começar a treinar
local gainChance = 50 -- Chance de ganhar skill, em porcentagem
local requiredItemID = 1234 -- Substitua 1234 pelo ID do item necessário para treinar
if skillsToTrain[vocation] then
for _, skillToTrain in ipairs(skillsToTrain[vocation]) do
local skillLevel = player:getSkillLevel(skillToTrain)
if skillLevel >= minSkill then
-- Verifica se o jogador está equipado com o item necessário
if player:getSlotItem(CONST_SLOT_RIGHT) and player:getSlotItem(CONST_SLOT_RIGHT):getId() == requiredItemID then
-- Verifica se o jogador ganha skill
if math.random(100) <= gainChance then
player:addSkillTries(skillToTrain, 1)
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você ganhou experiência em " .. getSkillName(skillToTrain) .. ".")
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você não ganhou experiência em " .. getSkillName(skillToTrain) .. ".")
end
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você precisa estar equipado com o item necessário para treinar aqui.")
end
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Você não tem a habilidade necessária para treinar aqui.")
end
end
else
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "Esta vocação não pode treinar aqui.")
end
end
return true
end