• Cinema + Entity Help
    1 replies, posted
Hey All, I've been battling with a bit of an issue regarding having the Playable Piano to load on server start and be available to play in the lobby. I've used the following lua code (which was also found on the forums), and have it as a lua file in lua->autorun->server: [CODE]local MapData = { cinema_theatron = { {model="models/fishy/furniture/piano.mdl", pos=Vector(-62.541210,-380.070343,64.031250), ang=Angle(0,0,0)} }, } local function AutospawnProps() local mapName = game.GetMap() --Get the name of the map local mapData = MapData[mapName] --Check we have data for this map if mapData then --If we have data for this map --Loop through the stuff for _,v in pairs(mapData) do --get the type of entity, or default to a physics prop local entType = "gmt_instrument_piano" --spawn it local newEnt = ents.Create(entType) if v.model then newEnt:SetModel(v.model) end --set model if v.ang then newEnt:SetAngles(v.ang) end --set angle if v.pos then newEnt:SetPos(v.pos) end --set position newEnt:Spawn() newEnt:Activate() end --End of for-loop end --End of check for map data end hook.Add("InitPostEntity", "Autospawn Props On Load", AutospawnProps)[/CODE] The problem is that nothing appears when in the cinema gamemode, but when i fiddle around and get the server to start in sandbox (in the same cinema_theatron map), its right there and good to go. Can anyone please offer some insight as to what i might be doing wrong? Is there something i need to add somewhere to allow it to spawn? Thanks very much! EDIT: I could very well be overcomplicating things. Has anyone got a stock-standard way of adding an on-start entity in a certain location to any gamemode? I've seen it done on heaps of servers so I daresay its either an addon or a simple script?
Figured it out myself. For those wondering, there is a simple way to add the entity using the following as an autorun server .lua file: [CODE]function SpawnEntity() local ent = ents.Create("gmt_instrument_piano") ent:SetPos( Vector( -20.000000, -380.070343, -0.500000) ) ent:SetAngles( Angle(0, 0, 0) ) ent:Spawn() ent:SetMoveType(MOVETYPE_NONE) - end hook.Add( "InitPostEntity", "SpawnEntity", SpawnEntity) [/CODE] Hopefully this helps others who are pondering the same issue.
Sorry, you need to Log In to post a reply to this thread.