[DiscordArchive] Hi there anyone know how to prevent NPC spawnin...
[DiscordArchive] Hi there anyone know how to prevent NPC spawnin...
Archived author: Needle • Posted: 2025-09-09T15:02:21.560000+00:00
Original source
Archived author: Needle • Posted: 2025-09-09T15:02:22.239000+00:00
Original source
Thread automatically created by dr3amforg3 in <#415944535718494208>
Archived author: Hex • Posted: 2025-09-09T15:57:02.633000+00:00
Original source
By default, player:SpawnCreature(entry, x, y, z, o, spawnType, despawnTime) will happily spawn inside geometry if you feed it raw player coordinates. To avoid that, you can
Archived author: Hex • Posted: 2025-09-09T15:57:49.374000+00:00
Original source
```
local x, y, z, o = player:GetLocation()
local dist = 2 -- how far in front of player
local nx = x + math.cos(o) * dist
local ny = y + math.sin(o) * dist
local nz = player:GetMap():GetHeight(nx, ny, z) -- adjust height to ground
player:SpawnCreature(12345, nx, ny, nz, o, 3, 60000)
```
Archived author: Hex • Posted: 2025-09-09T15:58:11.200000+00:00
Original source
Offset the spawn point a little in front of the player
Archived author: Hex • Posted: 2025-09-09T15:58:38.708000+00:00
Original source
or you can just check the line of sight before spawning it
Archived author: Hex • Posted: 2025-09-09T15:58:45.767000+00:00
Original source
something like that
Archived author: Hex • Posted: 2025-09-09T15:58:58.285000+00:00
Original source
```
if player:IsWithinLoS(nx, ny, nz) then
player:SpawnCreature(12345, nx, ny, nz, o, 3, 60000)
else
player:SendBroadcastMessage("Can't spawn here, too close to wall!")
end
```
Archived author: Hex • Posted: 2025-09-09T15:59:30.172000+00:00
Original source
disocrd disorder the code but you can copy paste it somewhere else and see it cleanly
Archived author: dr3amforg3 • Posted: 2025-09-09T19:47:39.652000+00:00
Original source
Thanks Man