[lua]function MoveToPosition( npc, ent )
if ( !IsValid( npc ) or !IsValid( ent ) ) then return end
npc:SetSaveValue( "m_vecLastPosition", ent:GetPos() )
npc:SetSchedule( SCHED_FORCED_GO_RUN )
end
function GM:EntityEmitSound( tbl )
if tbl.Entity:IsPlayer() then
for k, v in pairs( ents.GetAll() ) do
if v:IsNPC() then
MoveToPosition( v, tbl.Entity )
print( "NPC heard a sound!" )
end
end
end
end[/lua]
Hey there. I want to make Combine move towards players whenever a sound is played in a certain radius. However, this code doesn't seem to be working. "NPC has heard a sound!" is working fine, but the NPC isn't moving, and "NPC has heard a sound!" is played far beyond 100 units. What's going wrong?
[QUOTE=Robotboy655;48873489][url]https://github.com/Facepunch/garrysmod-issues/issues/1021[/url][/QUOTE]
What would the solution be, in that case? It confuses me a little.
There is no solution. It's a game bug.
[QUOTE=Robotboy655;48873612]There is no solution. It's a game bug.[/QUOTE]
is there an alternate way to do something like this?
Sorry, you need to Log In to post a reply to this thread.