Can anyone help me identify the error in my code? Everything works except for the line that adds a stat to the hero. I wrote the code based on the Heroes of Might and Magic guide:
function arena1F()
gold = GetPlayerResource(1, 6);
if gold >= 2000
then
QuestionBox("/Maps/Multiplayer/arena/napadenie1.txt", "yes", "no");
else MessageBox("/Maps/Multiplayer/arena/napadenie1nexvatka.txt");
end;
end;
function yes()
SetPlayerResource(1, 6, gold-2000);
ChangeHeroStat(heroname, STAT_ATTACK, 1);
end;
Trigger(OBJECT_TOUCH_TRIGGER, "arena1", "arena1F");
All the messages work, the gold amount checks work, deducting 2000 gold works, but the attack bonus isn't applied to the hero.
I tried adding sleep(1) after the gold deduction line, I tried adding/removing heroname, I changed the name of "yes" to something else to avoid conflicts with other "yes" functions (there are many such objects on the map), I wrote the code to add attack as the first line and without the second line deducting gold, but it still doesn't work.
What could be the problem?