Hi!
How can I call the entity (in init.lua) without being in a ENT function ?
[CODE]
function ENT:Initialize()
self:SetModel("models/props_lab/workspace001.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType( SIMPLE_USE )
self:SetColor( Color( 133, 133, 133, 230 ) )
deskpos = self:GetPos()
end
[/CODE]
[CODE]
net.Receive( "MakeEntity", function( len, ply )
local i = 1
newspaperquantity = net.ReadInt(32)
if ( newspaperquantity <= 0 ) then
else
while i <= newspaperquantity do
local newspaper_ent = ents.Create( "newspaper" )
if ( !IsValid( newspaper_ent ) ) then return end
newspaper_ent:SetModel( "models/props_junk/garbage_newspaper001a.mdl" )
newspaper_ent:SetPos( deskpos + Vector(0,-50,40))
newspaper_ent:SetNPTitle( net.ReadString() )
newspaper_ent:SetNPText( net.ReadString() )
newspaper_ent:SetNPHeadline( net.ReadString() )
newspaper_ent:Spawn()
newspaper_ent:PhysWake()
i = i + 1
end
end
end)
[/CODE]
I can't call "deskpos", it says that's a nil value.
I want the deskpos to be in the while loop.
Thanks.
[I](sorry for my poor grammar, english isn't my native language)[/I]
Couple errors, you are making deskpos a global var. Instead make it self.deskpos = GetPos.
Second off, you need to write the deskpos when sending it in a net message.
[CODE]net.Start("Blah")
net.WriteVector(deskpos)
net.Send()
net.Recieve( function()
local whatever = net.ReadVector()
end)[/CODE]
newspaper_ent:SetNWInt("MyProp",newspaper_ent)
And to call it:
local ent = geteyetraceandshit
local whichent:GetNWInt("MyProp")
print (whichent)
Sorry, you need to Log In to post a reply to this thread.