-- ver. 0.1
local c = {
[1ItemId1] = "Spell name1",
[2ItemId2] = "Spell name2"
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local spell = c[item.id]
if spell then
if getPlayerLearnedInstantSpell(cid, spell) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already know this spell.")
doSendMagicEffect(fromPosition, CONST_ME_POFF)
else
doPlayerLearnInstantSpell(cid, spell)
end
else
return false
end
return true
end
--[[ todo
- check vocation
- if premium
- remove item?
]]
something like this?Lua:-- ver. 0.1 local c = { [1ItemId1] = "Spell name1", [2ItemId2] = "Spell name2" } function onUse(cid, item, fromPosition, itemEx, toPosition) local spell = c[item.id] if spell then if getPlayerLearnedInstantSpell(cid, spell) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already know this spell.") doSendMagicEffect(fromPosition, CONST_ME_POFF) else doPlayerLearnInstantSpell(cid, spell) end else return false end return true end --[[ todo - check vocation - if premium - remove item? ]]
<action actionid="1234" event="script" value="spell.lua"/>
local spellName = "SPELLNAMEHERE" -- replace spellnamehere with ur spell
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.actionid == 1234 then -- 1234 should be as same aid in actions.xml
if not getPlayerLearnedInstantSpell(cid, spellName) then
doPlayerLearnInstantSpell(cid, spellName)
doPlayerPopupFYI(cid, You just learnt a new spell)
else
doPlayerSendCancel(cid, "You cannot learn this spell twice.")
end
end
return true
end
XML:<action actionid="1234" event="script" value="spell.lua"/>
spell.lua
Lua:local spellName = "SPELLNAMEHERE" -- replace spellnamehere with ur spell function onUse(cid, item, fromPosition, itemEx, toPosition) if item.actionid == 1234 then -- 1234 should be as same aid in actions.xml if not getPlayerLearnedInstantSpell(cid, spellName) then doPlayerLearnInstantSpell(cid, spellName) doPlayerPopupFYI(cid, You just learnt a new spell) else doPlayerSendCancel(cid, "You cannot learn this spell twice.") end end return true end
local t = {
[5000] = {"Light Healing"},
[5001] = {"Haste"},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.actionid]
if v then
if getPlayerLearnedInstantSpell(cid, v[1]) then
return doPlayerSendCancel(cid, "You already know this spell."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
end
doPlayerLearnInstantSpell(cid, v[1])
doSendMagicEffect(getThingPos(cid), CONST_ME_WRAPS)
doCreatureSay(cid, "You just learnt a new spell!", TALKTYPE_ORANGE_1)
end
return true
end
Yes, you can do that.
- - - Edited - - -
Haven't tested this, but please give it a try.
Lua:local t = { [5000] = {"Light Healing"}, [5001] = {"Haste"}, } function onUse(cid, item, fromPosition, itemEx, toPosition) local v = t[item.actionid] if v then if getPlayerLearnedInstantSpell(cid, v[1]) then return doPlayerSendCancel(cid, "You already know this spell."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end doPlayerLearnInstantSpell(cid, v[1]) doSendMagicEffect(getThingPos(cid), CONST_ME_WRAPS) doCreatureSay(cid, "You just learnt a new spell!", TALKTYPE_ORANGE_1) end return true end
local item = doPlayerAddItem(cid,5952,1)
doSetItemActionId(item, 5000)
Lua:local item = doPlayerAddItem(cid,5952,1) doSetItemActionId(item, 5000)
doCreatureSay(cid, "You just learnt a new spell!", TALKTYPE_ORANGE_1)
local item = doPlayerAddItem(cid,5952,1)
doSetItemActionId(item, 5000)
doSetItemSpecialDescription(item, "Your text here.")
yes im using mystic spirit 2.1.4Still using Mystic Spirit?
It won't create 2 items because you have doPlayerAddItem(cid,5952,1) only 1x.Lua:local item = doPlayerAddItem(cid,5952,1) doSetItemActionId(item, 5000) doSetItemSpecialDescription(item, "Your text here.")