Use a variable to manipulate whether a loop should do its thing or not, like this:
while true do
if AreaGetVisible() == 59 and not ConstantinosSpawned then
X, Y, Z = PlayerGetPosXYZ()
Const = PedCreateXYZ(70, X, Y+1, Z)
PedWander(Const)
PedMakeAmbient(Const)
ConstantinosSpawned = true
repeat
Wait(0)
until AreaGetVisible() ~= 59
ConstantinosSpawned = false
end
Wait(0)
end
To spawn peds coming from doors, the game uses a multitude of functions.
I looked into them when
Cautious was making his dorm recreation.
I don't quite understand all the arguments in the functions, but you might get away by copying and altering this the way you need:
Guys1 = AreaAddAmbientSpawner(10, 3, 0, 1000)
AreaSpawnerSetSexGeneration(Guys1, false, true) -- Males only
AreaAddAmbientSpawnPeriod(Guys1, 7, 0, 125)
AreaAddAmbientSpawnPeriod(Guys1, 12, 30, 30)
AreaAddAmbientSpawnPeriod(Guys1, 16, 0, 300)
Guys2 = AreaAddDocker(10, 2)
AreaSetDockerSexReception(Guys2, false, true)
AreaAddDockPeriod(Guys2, 11, 30, 60)
AreaAddDockPeriod(Guys2, 15, 30, 900)
AreaSetDockerChanceToDock(Guys2, 10)
AreaAddSpawnLocation(Guys1, POINTLIST._BdrDoorDownstairs3, TRIGGER._BdrDoorDownstairs3) -- Pointlists and Triggers can be found in the .DAT files (obviously custom ones need to made yourself). Change the names accordingly.
I should point out that peds won't really do much on their own in these areas as they were never meant to have peds roaming around. You'd have to script all their behaviour yourself.