Skip to content
User Avatar
#4002
Auto-translated

Hello everyone, I've been reading information about the talkboxforplayer function on the forum and elsewhere. Everything seems to be working except for one thing: the function doesn't recognize the hero that triggers it. The dialog box with options appears, the response texts are there, and the buttons are there, but the hero isn't recognized, and the army isn't granted.
The idea is this: a random hero touches a building, chooses a response, and receives an army.

The code itself was taken from Jack_of_shadows' Manuals:
The green color highlights the correct code that I copied, and the red color highlights the code that I wrote myself, which, of course, contains an error somewhere.

function DialogBox(icon, title, text, mode, callback, ...)
hero = human
if arg.n==1 then
TalkBoxForPlayers(GetCurrentPlayer(), icon, nil, text, nil, callback, mode, title, nil, 0, arg[1])
elseif arg.n==2 then
TalkBoxForPlayers(GetCurrentPlayer(), icon, nil, text, nil, callback, mode, title, nil, 0, arg[1], arg[2])
elseif arg.n==3 then
TalkBoxForPlayers(GetCurrentPlayer(), icon, nil, text, nil, callback, mode, title, nil, 0, arg[1], arg[2], arg[3])
elseif arg.n==4 then
TalkBoxForPlayers(GetCurrentPlayer(), icon, nil, text, nil, callback, mode, title, nil, 0, arg[1], arg[2], arg[3], arg[4])
elseif arg.n==5 then
TalkBoxForPlayers(GetCurrentPlayer(), icon, nil, text, nil, callback, mode, title, nil, 0, arg[1], arg[2], arg[3], arg[4], arg[5])
end;
end

Trigger (OBJECT_TOUCH_TRIGGER, "pokrov1", "Talk1");

function Talk1()
DialogBox("/UI/MessageBox/Message.xdb#xpointer(/Texture)","/UI/MessageBox/TalkBox/text.txt", "/Maps/Multiplayer/arena/voenachalnik1.txt", 1, "Talk1Callback", "/Maps/Multiplayer/arena/voenachalnik2.txt", "/Maps/Multiplayer/arena/voenachalnik3.txt", "/Maps/Multiplayer/arena/voenachalnik4.txt")
end

function Talk1Callback(pl, ans)
if (ans==1) and HasHeroSkill (human, 57)
then
AddHeroCreatures (human, 106, 50);
elseif (ans==2) and HasHeroSkill (human, 57)
then
AddHeroCreatures (human, 107, 50);
elseif (ans==3) and HasHeroSkill (human, 57)
then
AddHeroCreatures (human, 108, 50);
end;
end;

Thank you for your help.