• Create a entity which automaticly places itself near an other entity
    3 replies, posted
Is where a way to automaticly place an entity under an other entity without setting positions by hand? So after map loading I'd like that a dummy entity automaticly places itself under an specific map entity.
Nope
[QUOTE=markusmarkusz;50816722]Is where a way to automaticly place an entity under an other entity without setting positions by hand? So after map loading I'd like that a dummy entity automaticly places itself under an specific map entity.[/QUOTE] Yep Go look at the entity in the map in singleplayer, open console and type [code]lua_run print(Entity(1):GetEyeTrace().Entity:MapCreationID())[/code] You'll get a number in console, then use this code in the server domain [code] local mapentid = the_number_you_got_above local entname = "the_entity_you_want_to_spawn" local mapname = "the_name_of_the_map_wihout_extension_ex_gm_flatgrass_not_gm_flatgrass.bsp" local dist = the_distance_under_the_entity_it_should_spawn hook.Add( "InitPostEntity", "CreateMyEnt", function() if game.GetMap() ~= mapname then return end local mapent = ents.GetMapCreatedEntity(mapentid) local dummyent = ents.Create(entname) dummyent:SetPos(mapent:GetPos() + Vector(0,0,-dist)) dummyent:Spawn() end ) [/code] If every map you use will have an entity, you can replace the ents.GetMapCreatedEntity() with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url] or something. *Code is untested
I solved my problem another way. So I don't need my dummy entity. Anyway thanks for your help.
Sorry, you need to Log In to post a reply to this thread.