Then you will have to spawn them manually in Lua as I believe Cinema isn't Sandbox derived. :l
[url]http://wiki.garrysmod.com/page/ents/Create[/url]
So i have to know the coords?
And entity class, and angles, and model, and everything.
Shit... Sounds pretty hard. :D
Use getpos in console to get your position. (Go to the spot you want the entity to be placed at...)
Entity class is the folder name it's in, so for example "money_printer".
Entity model can be anything you want it to be.
I want to add a Playable Piano, how can i figure out it's Entity class and model? :o
Look at the lua file of the playable piano and paste it here
lua\effects\musicnotes\init.lua:
[CODE]function EFFECT:Init( data )
local pos = data:GetOrigin()
local grav = Vector(0, 0, math.random(50, 60))
local offset = Vector(0,0,10)
local emitter = ParticleEmitter( pos )
local particle = emitter:Add( "sprites/music", pos + offset )
particle:SetVelocity( ( Vector( 0, 0, 1 ) + ( VectorRand() * 0.1 ) ) * math.random( 15, 30 ) )
particle:SetDieTime( math.random( 0.5, 0.8 ) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 3 )
particle:SetEndSize( 1.5 )
particle:SetRoll( math.random(0.5, 10) )
particle:SetRollDelta( math.Rand(-0.2, 0.2) )
particle:SetColor( 255, 255, 255 )
particle:SetCollide( false )
particle:SetGravity( grav )
grav = grav + Vector(0, 0, math.random(-10, -5))
offset = offset + Vector( math.random(1, 5), math.random(.5, 5), math.random(1.5, 6))
emitter:Finish()
end
function EFFECT:Think( )
return false
end
function EFFECT:Render( )
end[/CODE]
lua\entities\gmt_instrument_base\cl_init.lua:
[CODE]include("shared.lua")
ENT.DEBUG = false
ENT.KeysDown = {}
ENT.KeysWasDown = {}
ENT.AllowAdvancedMode = false
ENT.AdvancedMode = false
ENT.ShiftMode = false
ENT.PageTurnSound = Sound( "GModTower/inventory/move_paper.wav" )
surface.CreateFont( "InstrumentKeyLabel", {
size = 22, weight = 400, antialias = true, font = "Impact"
} )
surface.CreateFont( "InstrumentNotice", {
size = 30, weight = 400, antialias = true, font = "Impact"
} )
// For drawing purposes
// Override by adding MatWidth/MatHeight to key data
ENT.DefaultMatWidth = 128
ENT.DefaultMatHeight = 128
// Override by adding TextX/TextY to key data
ENT.DefaultTextX = 5
ENT.DefaultTextY = 10
ENT.DefaultTextColor = Color( 150, 150, 150, 255 )
ENT.DefaultTextColorActive = Color( 80, 80, 80, 255 )
ENT.DefaultTextInfoColor = Color( 120, 120, 120, 150 )
ENT.MaterialDir = ""
ENT.KeyMaterials = {}
ENT.MainHUD = {
Material = nil,
X = 0,
Y = 0,
TextureWidth = 128,
TextureHeight = 128,
Width = 128,
Height = 128,
}
ENT.AdvMainHUD = {
Material = nil,
X = 0,
Y = 0,
TextureWidth = 128,
TextureHeight = 128,
Width = 128,
Height = 128,
}
ENT.BrowserHUD = {
URL = "http://www.gmtower.org/apps/instruments/piano.php",
Show = true, // display the sheet music?
X = 0,
Y = 0,
Width = 1024,
Height = 768,
}
function ENT:Initialize()
self:PrecacheMaterials()
end
function ENT:Think()
if !IsValid( LocalPlayer().Instrument ) || LocalPlayer().Instrument != self then return end
if self.DelayKey && self.DelayKey > CurTime() then return end
// Update last pressed
for keylast, keyData in pairs( self.KeysDown ) do
self.KeysWasDown[ keylast ] = self.KeysDown[ keylast ]
end
// Get keys
for key, keyData in pairs( self.Keys ) do
// Update key status
self.KeysDown[ key ] = input.IsKeyDown( key )
// Check for note keys
if self:IsKeyTriggered( key ) then
if self.ShiftMode && keyData.Shift then
self:OnRegisteredKeyPlayed( keyData.Shift.Sound )
elseif !self.ShiftMode then
self:OnRegisteredKeyPlayed( keyData.Sound )
end
end
end
// Get control keys
for key, keyData in pairs( self.ControlKeys ) do
// Update key status
self.KeysDown[ key ] = input.IsKeyDown( key )
// Check for control keys
if self:IsKeyTriggered( key ) then
keyData( self, true )
end
// was a control key released?
if self:IsKeyReleased( key ) then
keyData( self, false )
end
end
// Send da keys to everyone
//self:SendKeys()
end
function ENT:IsKeyTriggered( key )
return self.KeysDown[ key ] && !self.KeysWasDown[ key ]
end
function ENT:IsKeyReleased( key )
return self.KeysWasDown[ key ] && !self.KeysDown[ key ]
end
function ENT:OnRegisteredKeyPlayed( key )
// Play on the client first
local sound = self:GetSound( key )
self:EmitSound( sound, 100 )
// Network it
net.Start( "InstrumentNetwork" )
net.WriteEntity( self )
net.WriteInt( INSTNET_PLAY, 3 )
net.WriteString( key )
net.SendToServer()
// Add the notes (limit to max notes)
/*if #self.KeysToSend < self.MaxKeys then
if !table.HasValue( self.KeysToSend, key ) then // only different notes, please
table.insert( self.KeysToSend, key )
end
end*/
end
// Network it up, yo
function ENT:SendKeys()
if !self.KeysToSend then return end
// Send the queue of notes to everyone
// Play on the client first
for _, key in ipairs( self.KeysToSend ) do
local sound = self:GetSound( key )
if sound then
self:EmitSound( sound, 100 )
end
end
// Clear queue
self.KeysToSend = nil
end
function ENT:DrawKey( mainX, mainY, key, keyData, bShiftMode )
if keyData.Material then
if ( self.ShiftMode && bShiftMode && input.IsKeyDown( key ) ) ||
( !self.ShiftMode && !bShiftMode && input.IsKeyDown( key ) ) then
surface.SetTexture( self.KeyMaterialIDs[ keyData.Material ] )
surface.DrawTexturedRect( mainX + keyData.X, mainY + keyData.Y,
self.DefaultMatWidth, self.DefaultMatHeight )
end
end
// Draw keys
if keyData.Label then
local offsetX = self.DefaultTextX
local offsetY = self.DefaultTextY
local color = self.DefaultTextColor
if ( self.ShiftMode && bShiftMode && input.IsKeyDown( key ) ) ||
( !self.ShiftMode && !bShiftMode && input.IsKeyDown( key ) ) then
color = self.DefaultTextColorActive
if keyData.AColor then color = keyData.AColor end
else
if keyData.Color then color = keyData.Color end
end
// Override positions, if needed
if keyData.TextX then offsetX = keyData.TextX end
if keyData.TextY then offsetY = keyData.TextY end
draw.DrawText( keyData.Label, "InstrumentKeyLabel",
mainX + keyData.X + offsetX,
mainY + keyData.Y + offsetY,
color, TEXT_ALIGN_CENTER )
end
end
function ENT:DrawHUD()
surface.SetDrawColor( 255, 255, 255, 255 )
local mainX, mainY, mainWidth, mainHeight
// Draw main
if self.MainHUD.Material && !self.AdvancedMode then
mainX, mainY, mainWidth, mainHeight = self.MainHUD.X, self.MainHUD.Y, self.MainHUD.Width, self.MainHUD.Height
surface.SetTexture( self.MainHUD.MatID )
surface.DrawTexturedRect( mainX, mainY, self.MainHUD.TextureWidth, self.MainHUD.TextureHeight )
end
// Advanced main
if self.AdvMainHUD.Material && self.AdvancedMode then
mainX, mainY, mainWidth, mainHeight = self.AdvMainHUD.X, self.AdvMainHUD.Y, self.AdvMainHUD.Width, self.AdvMainHUD.Height
surface.SetTexture( self.AdvMainHUD.MatID )
surface.DrawTexturedRect( mainX, mainY, self.AdvMainHUD.TextureWidth, self.AdvMainHUD.TextureHeight )
end
// Draw keys (over top of main)
for key, keyData in pairs( self.Keys ) do
self:DrawKey( mainX, mainY, key, keyData, false )
if keyData.Shift then
self:DrawKey( mainX, mainY, key, keyData.Shift, true )
end
end
// Sheet music help
if !ValidPanel( self.Browser ) && self.BrowserHUD.Show then
draw.DrawText( "SPACE FOR SHEET MUSIC", "InstrumentKeyLabel",
mainX + ( mainWidth / 2 ), mainY + 60,
self.DefaultTextInfoColor, TEXT_ALIGN_CENTER )
end
// Advanced mode
if self.AllowAdvancedMode && !self.AdvancedMode then
draw.DrawText( "CONTROL FOR ADVANCED MODE", "InstrumentKeyLabel",
mainX + ( mainWidth / 2 ), mainY + mainHeight + 30,
self.DefaultTextInfoColor, TEXT_ALIGN_CENTER )
elseif self.AllowAdvancedMode && self.AdvancedMode then
draw.DrawText( "CONTROL FOR BASIC MODE", "InstrumentKeyLabel",
mainX + ( mainWidth / 2 ), mainY + mainHeight + 30,
self.DefaultTextInfoColor, TEXT_ALIGN_CENTER )
end
end
// This is so I don't have to do GetTextureID in the table EACH TIME, ugh
function ENT:PrecacheMaterials()
if !self.Keys then return end
self.KeyMaterialIDs = {}
for name, keyMaterial in pairs( self.KeyMaterials ) do
if type( keyMaterial ) == "string" then // TODO: what the fuck, this table is randomly created
self.KeyMaterialIDs
Only post file paths, not their contents.
But [QUOTE]Look at the lua file of the playable piano and paste it here[/QUOTE] D:
[QUOTE=xNiksu;45016940]But D:[/QUOTE]
Anyway, what you are looking for is: "gmt_instrument_piano" for entity class. You can forget about SetModel part too, since it is set by the entity itself.
Create the entity, set pos and angles, :Spawn() it and you should be done. And you gotta do all of this from serverside file, using InitPostEntity hook.
Im really new to hooks etc. So can you tell more specifically
Sorry, you need to Log In to post a reply to this thread.