I'm trying to make a script get all active spells on the selected target and report their names to me. Everything else about it except cycling through all the spells works. The loop refuses to advance to the next effect, and instead just reports the first one over and over. Why does this function hate my script? Here's the whole thing:
void main()
{
object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
effect eEffect = GetFirstEffect(oTarget);
int nSpellId = GetEffectSpellId(eEffect);
while (GetIsEffectValid(eEffect))
{
SendMessageToPC(OBJECT_SELF, Get2DAString("spells", "Label", nSpellId));
eEffect = GetNextEffect(oTarget);
}
}
Retrieving active spell names
Débuté par
manageri
, sept. 12 2013 02:56
#1
Posté 12 septembre 2013 - 02:56
#2
Posté 13 septembre 2013 - 12:03
You're not resetting nSpellId in the loop:
void main()
{
object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
effect eEffect = GetFirstEffect(oTarget);
int nSpellId;
while (GetIsEffectValid(eEffect))
{
nSpellId = GetEffectSpellId(eEffect);
SendMessageToPC(OBJECT_SELF, Get2DAString("spells", "Label", nSpellId));
eEffect = GetNextEffect(oTarget);
}
}
void main()
{
object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
effect eEffect = GetFirstEffect(oTarget);
int nSpellId;
while (GetIsEffectValid(eEffect))
{
nSpellId = GetEffectSpellId(eEffect);
SendMessageToPC(OBJECT_SELF, Get2DAString("spells", "Label", nSpellId));
eEffect = GetNextEffect(oTarget);
}
}
#3
Posté 13 septembre 2013 - 12:04
Duplicado Deleto
Modifié par DannJ, 13 septembre 2013 - 12:07 .
#4
Posté 13 septembre 2013 - 04:19
Of course, thank you. Now I just gotta fix all the duplicate spell names it throws at me.
Modifié par manageri, 13 septembre 2013 - 04:20 .





Retour en haut






