gmstrikker
Well-Known Member
- Joined
- Jul 30, 2014
- Messages
- 458
- Solutions
- 1
- Reaction score
- 50
I was helped on this topic TFS 0.X - ML up show new spell from spells.xml (https://otland.net/threads/ml-up-show-new-spell-from-spells-xml.270306/) to edit my source so a script like this work:
It shows all spells you from your magic level when u get magic level up (from spells.xml)
But there is a problem...
It show all spells, it not verify your vocation, so for example when paladins get mlvls it shows mages spells
Is anyone know how to put a vocation condition to when players get mlvl up it shows only your vocation spells?
creaturescript script:
sources changes:
spells.cpp
added:
spells.h
obs1: i need to show spells with needlearn="1" (because i put spells to buy in my server)
obs2: i have a lot of custom spells and i want to do so much more, so
obs3: source Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/src)
Screenshot-from-2020-05-10-14-32-19 hosted at ImgBB
Image Screenshot-from-2020-05-10-14-32-19 hosted in ImgBB
ibb.co
But there is a problem...
It show all spells, it not verify your vocation, so for example when paladins get mlvls it shows mages spells
Is anyone know how to put a vocation condition to when players get mlvl up it shows only your vocation spells?
creaturescript script:
Code:
--[[------------------------------------------------<|]
|* * * * * * * * * * * * * * * * * * * * * * * * * * *|
|* * * * * * * [SpellUp! Script] * * * * * * * * * * |
|* * * * * * * * By: Cybermaster * * * * * * * * * * *|
|* * * Tested on: The Forgotten Server 0.3.6pl1 * * *|
|* * * * * * * * * * * * * * * * * * * * * * * * * * *|
|>---------------------------------------------------]]
local s = { --SETUP
repeatAfterDeath = true, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
-- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
Storage = 10000,
messageType = 'popUp', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
channelClass = MESSAGE_EVENT_ORANGE
}
function onAdvance(cid, skill, oldlevel, newlevel)
if skill ~= 7 or not s.repeatAfterDeath and getCreatureStorage(cid, s.Storage) >= newlevel then
return true
end
local t = {}
for i = 0, getPlayerInstantSpellCount(cid) - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if(spell.mlevel ~= 0) and spell.mlevel == newlevel then
if(spell.manapercent > 0) then
spell.mana = spell.manapercent .. '%'
end
table.insert(t, spell)
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local tmpStr = ''
local Str = ''
for i, spell in ipairs(t) do
tmpStr = 'NEW SPELL:\n['..spell.name..'] "'..spell.words..'"\n\n'
Str = Str .. tmpStr
end
if Str == '' then
return true
end
doCreatureSetStorage(cid, s.Storage, newlevel)
if s.messageType == 'popUp' then
doShowTextDialog(cid, 2175, Str)
elseif s.messageType == 'channel' then
doPlayerSendTextMessage(cid, s.channelClass, Str)
end
return true
end
sources changes:
spells.cpp
added:
Code:
InstantSpell* Spells::getInstantSpellByIndexCustom(const Player* player, uint32_t index)
{
uint32_t count = 0;
for(InstantsMap::iterator it = instants.begin(); it != instants.end(); ++it)
{
InstantSpell* instantSpell = it->second;
if(count == index)
return instantSpell;
++count;
}
return NULL;
}
spells.h
Code:
InstantSpell* getInstantSpellByIndexCustom(const Player* player, uint32_t index);
obs1: i need to show spells with needlearn="1" (because i put spells to buy in my server)
obs2: i have a lot of custom spells and i want to do so much more, so
obs3: source Fir3element/3777 (https://github.com/Fir3element/3777/tree/master/src)