Skip to content
User Avatar
#3786
Auto-translated
A brief overview. `hero` is a variable. In order for something to be stored in it, something needs to be assigned to it! This is done by manually declaring the variable, or the game will assign something to it through its actions. To do this, arguments are specified in the sub-trigger function (the list is in the developer's manual under the Trigger function). That is:
function Test(hero)
if hero == "..." then

end
end
Trigger(OBJECT_TOUCH_TRIGGER, ...).

In your case, the code needs to be changed as follows:
function OPIT(hero)
number = GetCurrentPlayer() --I recommend replacing this with number=GetObjectOwner(hero)
local Gold = GetPlayerResource(number,6) --It's better to keep the variable local
if Gold >= 6000 then
QuestionBoxForPlayers(number,"Maps/Multiplayer/JoyPatriot/Teks/Vopros.txt", "yes([["..hero.."]])", "no")
else MessageBoxForPlayers(number,"Maps/Multiplayer/JoyPatriot/Teks/OP.txt", nil)
end
end

function yes(hero)
number = GetCurrentPlayer() --The same. It's better to use number=GetObjectOwner(hero)
local Gold = GetPlayerResource(number) --There's nothing wrong with repeating the operation, although it could be done better; but the main thing is that the error of overwriting something in the Gold variable has been eliminated
SetPlayerResource(number,6,Gold-6000)
LevelUpHero(hero)
return parse '' --We remove the machine error, which has no effect. Otherwise, a warning will be spammed in the console
end

SetObjectEnabled("OP",nil);
Trigger(OBJECT_TOUCH_TRIGGER,"OP","OPIT");

P.s. I recommend giving variables meaningful names. And objects too. For example, "ExperienceStone" and "ExperienceStoneTouch", respectively...

С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________