• Landmine activation
    8 replies, posted
Hey, i'm planning on making a landmine SENT which activates when someone gets within a range of 21 yards/20 meters. What command can i use to make the SENT activate when someone gets in range?
[url=http://wiki.garrysmod.com/?title=Ents.FindInSphere]ents.FindInSphere[/url]
Thanks, but how do i make it trigger like that? I.E let's say it explodes if someone enters sphere?
[url]http://www.garrysmod.org/downloads/?a=view&id=56872[/url] This should help.
Sorry, that's not what i'm looking for. I'm looking for some way to make the mine explode when someone gets near it.
[QUOTE=Kriller1612;18716662]Sorry, that's not what i'm looking for. I'm looking for some way to make the mine explode when someone gets near it.[/QUOTE] He just told you it would help, which means it does exactly what you're looking for. Just open it and see how overv did it, a working example is the best explanation you can get.
In a Think (or similar) hook of the entity, use ents.FindInSphere to get all the entities in a specific range. Filter out all but players (or, if you want prop activation or something, filter out all but players and prop_physics). If there's any players (or props) in that filtered table, then that means there's something inside the range of the ents.FindInSphere that's a player. Which means you can explode it from there.
[QUOTE=Disseminate;18716962]In a Think (or similar) hook of the entity, use ents.FindInSphere to get all the entities in a specific range. Filter out all but players (or, if you want prop activation or something, filter out all but players and prop_physics). If there's any players (or props) in that filtered table, then that means there's something inside the range of the ents.FindInSphere that's a player. Which means you can explode it from there.[/QUOTE] Which means : [code]local radius = 32 function ENT:Think() for k,v in pairs(ents.FindInSphere(self:GetPos(),radius)) do if v:IsPlayer() then self:Explode() end end end function ENT:Explode() --Explosion code end[/code]
Thanks alot guys, i hope this'll work.
Sorry, you need to Log In to post a reply to this thread.