Skip to content
User Avatar
#3578
Auto-translated
There's a simpler option.
function GarrisonBlock()
while 1 do
if GetObjectOwner("Castle2")==GetObjectOwner("Castle1") then --Your condition is true only if both castles belong to the same player
SetObjectEnabled("Garrison", 1, GetObjectOwner("Castle1")) --Unlock the garrison for the owner of both castles
while not IsObjectEnabled("Garrison") do sleep(1) end
end
for i=1,8 do
if GetPlayerState(i)==PLAYER_ACTIVE and i~=GetObjectOwner("Castle1") and i~=GetObjectOwner("Castle2") and IsObjectEnabled("Garrison") then --If the player is active and is not the owner of both castles, but the garrison is unlocked for him, then
SetObjectEnabled("Garrison", nil, i) --Lock the garrison for him
end
end
sleep(1)
end

startThread(GarrisonBlock)

Yes, the script isn't very elegant; you could have put the names in variables to avoid writing it 5 times, and even better, put them in function arguments. You could also use a trigger for changing the castle owner and a check at the start of the map to avoid an unnecessary loop.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: Фёдор Фёдорович