• 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 How make Spell Scroll and lever !!

foulla

Member
Joined
Jun 26, 2016
Messages
78
Solutions
1
Reaction score
6
Hello
Can anyone tell me how make spell Scroll and lever when use Scroll add this spell "exevo gran ico" level 100 only vocation 3 . 4
Tfs 0.4
 
Last edited:
Solution
data\actions\scripts add a script with the name you choose granico.lua then add this to it.
Lua:
local spell = "gran ico"
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getPlayerLearnedInstantSpell(cid, spell) then
        doPlayerLearnInstantSpell(cid, spell)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned spell " .. spell .. "!")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doRemoveItem(item.uid, 1)
    else
        doCreatureSay(cid, "You already know this spell!", TALKTYPE_ORANGE_1, nil, cid, getThingPos(cid))
    end
    return true
end
and in data\actions\actions.xml add
XML:
<action itemid="5957" event="script" value="granico.lua"/>
...
Just add a scroll which gives player a storage on your actions.
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    end
end
Then on the spell add a storage check like this one
Lua:
local SpellStorage = 6667

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 10)

local area = createCombatArea(AREA_CROSS6X6)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    if getCreatureStorage(cid, SpellStorage) >= 1 then
    return doCombat(cid, combat, var)
    end
end
 
Just add a scroll which gives player a storage on your actions.
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    end
end
Then on the spell add a storage check like this one
Lua:
local SpellStorage = 6667

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 10)

local area = createCombatArea(AREA_CROSS6X6)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    if getCreatureStorage(cid, SpellStorage) >= 1 then
    return doCombat(cid, combat, var)
    end
end
What about spells.xml
 
Show me how you added the scripts above, First one should be added to actions folder and actions.xml, Second one is just a spell example because I don't have your exevo gran ico spell.
 
Show me how you added the scripts above, First one should be added to actions folder and actions.xml, Second one is just a spell example because I don't have your exevo gran ico spell.
Spells.xml
XML:
    <instant name="gran ico" words="exevo gran ico" lvl="150000" mana="3000" aggressive="0" selftarget="1" exhaustion="800" needlearn="1" event="script" value="healing/gran ico.lua">
    <vocation id="8"/>
    </instant>
Action.xml
XML:
    <action itemid="5957" event="script" value="granico.lua"/>
and in action/script/granico.lua
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    end
end
and in spells/scrpit/healing/gran ico.lua

Lua:
local SpellStorage = 6667

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 41902) > 0 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendCancel(cid, "You cannot use healing spells/runes during the event.")
   return false
  end
    local formule = (getCreatureMaxHealth(cid) / 100) * math.random(67, 85)
    doCreatureAddHealth(cid, formule)
    return doCombat(cid, combat, var)
end
Post automatically merged:

TFS 0.4
Post automatically merged:

Probably wrong in
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    end
end
 
Last edited:
Lua:
local SpellStorage = 6667

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 41902) > 0 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendCancel(cid, "You cannot use healing spells/runes during the event.")
   return false
  end
  if getCreatureStorage(cid, SpellStorage) >= 1 then
    local formule = (getCreatureMaxHealth(cid) / 100) * math.random(67, 85)
    doCreatureAddHealth(cid, formule)
    return doCombat(cid, combat, var)
    end
    return true
end
 
Lua:
local SpellStorage = 6667

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 41902) > 0 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendCancel(cid, "You cannot use healing spells/runes during the event.")
   return false
  end
  if getCreatureStorage(cid, SpellStorage) >= 1 then
    local formule = (getCreatureMaxHealth(cid) / 100) * math.random(67, 85)
    doCreatureAddHealth(cid, formule)
    return doCombat(cid, combat, var)
    end
    return true
end
Still wrong "you cannot use this object" This means that there is something wrong with me Action,xml in this
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    end
end
 
I think it happens because you already used the scroll or the item
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    else
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have already used this item.")
    end
    return true
end
I tested it and it works.
testscroll.gif
 
I think it happens because you already used the scroll or the item
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    else
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have already used this item.")
    end
    return true
end
I tested it and it works.
View attachment 52252
I will try again
 
Why using Storage instead of learn spell?
I was working a little with spells and adding/testing some storages last few days so this is the fastest idea I got in mind but yeah learn spells would be better, Feel free to post a script for it or if you didn't then I will do it later tonight.
 
I think it happens because you already used the scroll or the item
Lua:
local SpellStorage = 6667

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getCreatureStorage(cid, SpellStorage) < 1 then
    doCreatureSetStorage(cid, SpellStorage, 1)
    doRemoveItem(item.uid, 1)
    doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
    doCreatureSay(cid, "You have learnt a new spell.", TALKTYPE_ORANGE_1)
    else
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You have already used this item.")
    end
    return true
end
I tested it and it works.
View attachment 52252
ok bro solve but it need be needlearn="0" no needlearn="1" in spells.xml
Post automatically merged:

@M0ustafa
Spell can be obtained by any player as soon as he reaches the level without using Scroll
 
Last edited:
data\actions\scripts add a script with the name you choose granico.lua then add this to it.
Lua:
local spell = "gran ico"
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getPlayerLearnedInstantSpell(cid, spell) then
        doPlayerLearnInstantSpell(cid, spell)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned spell " .. spell .. "!")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doRemoveItem(item.uid, 1)
    else
        doCreatureSay(cid, "You already know this spell!", TALKTYPE_ORANGE_1, nil, cid, getThingPos(cid))
    end
    return true
end
and in data\actions\actions.xml add
XML:
<action itemid="5957" event="script" value="granico.lua"/>
and in data\spells\spells.xml add this
XML:
    <instant name="gran ico" words="exevo gran ico" lvl="150000" mana="3000" aggressive="0" selftarget="1" exhaustion="800" needlearn="1" event="script" value="healing/gran ico.lua">
    <vocation id="8"/>
    </instant>
then in data\spells\scripts\healing add the script with name gran ico.lua and paste this to it
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 41902) > 0 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendCancel(cid, "You cannot use healing spells/runes during the event.")
   return false
  end
    local formule = (getCreatureMaxHealth(cid) / 100) * math.random(67, 85)
    doCreatureAddHealth(cid, formule)
    return doCombat(cid, combat, var)
end
 
Solution
data\actions\scripts add a script with the name you choose granico.lua then add this to it.
Lua:
local spell = "gran ico"
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getPlayerLearnedInstantSpell(cid, spell) then
        doPlayerLearnInstantSpell(cid, spell)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned spell " .. spell .. "!")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doRemoveItem(item.uid, 1)
    else
        doCreatureSay(cid, "You already know this spell!", TALKTYPE_ORANGE_1, nil, cid, getThingPos(cid))
    end
    return true
end
and in data\actions\actions.xml add
XML:
<action itemid="5957" event="script" value="granico.lua"/>
and in data\spells\spells.xml add this
XML:
    <instant name="gran ico" words="exevo gran ico" lvl="150000" mana="3000" aggressive="0" selftarget="1" exhaustion="800" needlearn="1" event="script" value="healing/gran ico.lua">
    <vocation id="8"/>
    </instant>
then in data\spells\scripts\healing add the script with name gran ico.lua and paste this to it
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 41902) > 0 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   doPlayerSendCancel(cid, "You cannot use healing spells/runes during the event.")
   return false
  end
    local formule = (getCreatureMaxHealth(cid) / 100) * math.random(67, 85)
    doCreatureAddHealth(cid, formule)
    return doCombat(cid, combat, var)
end
Solve ;)🥴👍
Happy Dog GIF by Puglie Pug

Post automatically merged:

@M0ustafa
what about action when need add in lever
 
Last edited:
Back
Top