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

Solved Action Script needs quick edit please

shivaria

Active Member
Joined
Sep 2, 2009
Messages
158
Reaction score
36
TFS 1.1, or 10.77

Its showing no errors yet its not adding the skill level (I want it to increase it by 1)
I also want it to learn a random spell from the list (its not learning the spell)

SOLVED

Code:
local randomSpell = {"SPELL", "OTHER SPELL", "Better Spell", "Crappy Spell", "Spell Name Here Not Words"}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if player:getStorageValue(13529) == -1 then
                if player:removeItem(13529, 1) then
                local spell = math.random(#randomSpell)
                local skillId = SKILL_AXE
                player:addSkillTries(skillId, player:getVocation():getRequiredSkillTries(skillId, player:getSkillLevel(skillId) + 1) - player:getSkillTries(skillId))
                player:setStorageValue(13529, -1)
                player:learnSpell(randomSpell[spell])
                fromPosition:sendMagicEffect(CONST_ME_HOLY)
                player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You learned "..randomSpell[spell])
                player:popupFYI("You learned "..randomSpell[spell])
                end
        else
        player:removeItem(13529, 1)
        player:say("It turned to ashes..", TALKTYPE_MONSTER_SAY)
        fromPosition:sendMagicEffect(CONST_ME_POFF)
        end
      
return true
end
 
Last edited:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local randomSpell = {"Chain Lightning", "Back Stab", "Barrier", "Fire Wall", "Energy Beam"}
  if player:getStorageValue(13529) <= 0 then
  if player:getItemCount(13529) >= 1 then
       player:addSkillTries(SKILL_AXE, player:getSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE)))
       player:setStorageValue(13529, 1)
       player:learnSpell(cid, randomSpell[math.random(#randomSpell)])
       fromPosition:sendMagicEffect(CONST_ME_HOLY)
       player:popupFYI("You Have Learned "..randomSpell[math.random(1,#randomSpell)]..".")
  end
  else
     player:removeItem(13529, 1)
     player:say("It turned to ashes..", TALKTYPE_MONSTER_SAY)
     fromPosition:sendMagicEffect(CONST_ME_POFF)
  end
   return true
end

Try This,I Dont really Have Much Hope it will work But its more Organized,Not expert with tfs 1.0+
 
I guess that you're not learning the spell because the cid param doesn't exit.
Try this one (not tested):
Code:
local randomSpell = {"Chain Lightning", "Back Stab", "Barrier", "Fire Wall", "Energy Beam"}
 
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(13529) == -1 then
        if player:removeItem(13529, 1) then
            local spell = math.random(#randomSpell)

            player:addSkillTries(SKILL_AXE, player:getSkillTries(SKILL_AXE, player:getSkillLevel(SKILL_AXE) + 1) - player:getSkillTries(SKILL_AXE))
            player:setStorageValue(13529, 1)
            player:learnSpell(randomSpell[spell])
            fromPosition:sendMagicEffect(CONST_ME_HOLY)

            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You learned "..randomSpell[spell])
        end
    else
        player:removeItem(13529, 1)
        player:say("It turned to ashes..", TALKTYPE_MONSTER_SAY)
        fromPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
thanks guys! learning the spell works! fixed the rest myself, ill post working script above!
 
Last edited:
Back
Top