What I want to do is stop people from spawning/putting props in a certain area. I've never done anything with Hammer or Ents in GMod really, so I'm not sure where to start.
Is this even possible?
Make a trigger in Hammer, this could be done with.. trigger_multiple/once or other triggers just. Name it, and make sure that the output is linked to a (commandbox) not really sure of the name but it makes u run a command. Could be kick. So like whenever they trigger the box they get kicked. You would then make a lua code saying that if a prop is in the area name of the trigger box. Then it should trigger.
lua_run entity your thinking of i think
I'm not mapping, I'm adding this to a map to stop retarded people from spawning props.
[editline]2nd November 2010[/editline]
So it has to be done in Lua, thanks though.
well create the entity VIA LUA and then set its values >.>
Well, I know that, I meant setting the spawn args. Sorry.
Oh, ok, i think there was a hook once, one sec
[editline]2nd November 2010[/editline]
[b][url=wiki.garrysmod.com/?title=ENT.KeyValue]ENT.KeyValue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=Entity.SetKeyValue]Entity.SetKeyValue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=Entity.GetKeyValues]Entity.GetKeyValues [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
LOL
thanks <3
You cant create triggers in real time (afaik) with Lua, as they are brush entities.
You can however do an ents.FindInBox(vecmin, vecmax) in the area, and if the players are within that box, disallow spawning or whatever you don't want to happen.
Sidenote: the args to FindInBox are opposite corners, and to get those, you can go to where you want a corner to be, and type in console (singleplayer):
lua_run_cl print(Entity(1):GetPos())
(Sorry for obvious information, I just don't recognize your name so I don't know how familiar you are with GMod Lua.)
yea pretty much what Feihc said, but this in lua/autorun/server (not tested)
function GM:OnPlayerSpawnProp( ply )
local ifyouspawnnosoupforyou = ents.FindInBox(vecmin, vecmax) -- replace vecmin and vecmax with the proper vectors, [b][url=http://wiki.garrysmod.com/?title=Ents.FindInBox]Ents.FindInBox [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
if ply:GetPos() == ifyouspawnnosoupforyou then -- Not sure if this line will work =S
print("NO SOUP FOR YOU")
return 0
end
end
[lua]
local limits = ents.FindInBox(blah,blah)
for k,v in pairs(limits) do
v:Remove()
local owner = v.GetOwner()
owner:Kick("You are not aloud to spawn props there:)
end
[/lua]
[lua]
local vecmin = Vector(0,0,0)
local vecmax = Vector(0,0,0)
hook.Add('PlayerSpawnProp', 'SpawnRestrictions', function(ply)
return(!ply.NSP)
end)
hook.Add('Think', 'SpawnRestrictions', function()
for k, v in ipairs(player.GetAll()) do
v.NSP = false
end
for k, v in ipairs(ents.FindInBox(vecmin, vecmax)) do
if(v:IsPlayer()) then
v.NSP = true
elseif(v:GetClass() == "prop_physics") then
v:Remove()
end
end
end)
[/lua]
Thanks guys.
This is my only account...actually, I had another, but it was a half account, half guest account. It was epic.
Anyway, I'm no toooooo good at Lua, and I really don't work with entities in Lua, well, creating them that is.
Sorry, you need to Log In to post a reply to this thread.