• Gmod Lua: Freezing all Players near Owner
    3 replies, posted
I have a weapon that uses player.GetAll() to freeze all players in the server for a few seconds: [CODE] for k, v in pairs( player.GetAll() ) do if v != self.Owner then v:Freeze( true ) v:SetMoveType(MOVETYPE_NOCLIP) end end [/CODE] However, I want that effect to instead freeze players that are near the owner and not all players
You'd need to add a distance check between v's position and self.Owner's position ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetPos]Entity:GetPos[/url]) using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Distance]Vector:Distance[/url].
[QUOTE=txike;52653664]You'd need to add a distance check between v's position and self.Owner's position ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetPos]Entity:GetPos[/url]) using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Distance]Vector:Distance[/url].[/QUOTE] Thank You, that helped me out
[QUOTE=txike;52653664]You'd need to add a distance check between v's position and self.Owner's position ([img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetPos]Entity:GetPos[/url]) using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Distance]Vector:Distance[/url].[/QUOTE] Would [img]http://wiki.garrysmod.com/favicon.ico[/img][URL="http://wiki.garrysmod.com/page/ents/FindInSphere"]ents.FindInSphere[/URL] not be easier?
Sorry, you need to Log In to post a reply to this thread.