[CODE]function ENT:Use(activator, caller)
if activator:IsPlayer() then
self:EmitSound(Sound("weapons/pinpull.wav"),70,100)
activator:PrintMessage(HUD_PRINTTALK, "You pulled the smoke grenades pin, turns out this is a supply signal! (Please wait atleast 10 seconds!)")
timer.Create("SmokeSignal", 10, 1, function()
local ent = ents.Create( "ent_supplydrop" )
ent:SetModel( "models/Items/item_item_crate.mdl" )
ent:SetPos( Vector( 1298.589355 ,3084.306396 ,2745.632813 ) )
ent:Spawn()
end)
self:Remove()
end
end[/CODE]
I'd like to point out that these [CODE]ent:SetPos( Vector( 1298.589355 ,3084.306396 ,2745.632813 ) )[/CODE] cords. Are really annoying to play around with. On some maps they work, on others they don't. Because i am bad at lua (3x), i am asking you guys for help, again. Is there an alternative to SetPos, that would create the ent at the cords its activator was activated. To not confuse you, here is an example:
[CODE]Supply signal was activated with E, after 10 secs. the supply drop spawns at the same location the supply signal was activated.[/CODE]
[code]ent:SetPos( activator:GetPos() )[/code]
?
[QUOTE=MysticLlama;50472258][code]ent:SetPos( activator:GetPos() )[/code]
?[/QUOTE]
Might work, gonna check it out
[editline]7th June 2016[/editline]
[QUOTE=MysticLlama;50472258][code]ent:SetPos( activator:GetPos() )[/code]
?[/QUOTE]
It does work, but now for example i want to spawn it at the Supply Signal, that was spawned and activated, it got removed but the Supply Drop ent will spawn at it's last location before removal.
This is the code if you want to take a look.
[CODE]---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:Initialize()
self:SetModel("models/Items/grenadeAmmo.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetUseType(SIMPLE_USE)
self:SetColor( Color( 0, 0, 0, 255 ) )
local phys = self:GetPhysicsObject()
if phys and phys:IsValid() then
phys:Wake()
end
end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:PhysicsCollide(data, physobj)
end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:Use(activator, caller)
if activator:IsPlayer() then
self:EmitSound(Sound("weapons/pinpull.wav"),70,100)
activator:PrintMessage(HUD_PRINTTALK, "You pulled the smoke grenades pin, turns out this is a supply signal! (Please wait atleast 10 seconds!)")
timer.Create("SmokeSignal", 10, 1, function()
local ent = ents.Create( "ent_supplydrop" )
ent:SetPos( self:GetPos() )
ent:Spawn()
ent:Activate()
end)
self:Remove()
end
end
---------------------------------------------------------------------------------------------------------------------------------------------
function ENT:OnTakeDamage(dmginfo)
self:GetPhysicsObject():AddVelocity(dmginfo:GetDamageForce() * 0.1)
end
[/CODE]
[QUOTE=timmybo5;50472567][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url] ?[/QUOTE]
Could you show me on how this would look in the code? My stupid brain doesn't know where to put this...
No help?
sure haha, i thought it would be clear already.
[CODE]
-- get all ents from that class
local ents = ents.FindByClass(className)
--i am suspecting there is only 1 supply signal at a time
--so you could get the position of that ent by doing
local signalPos = ents[1]:GetPos()
[/CODE]
Sorry, you need to Log In to post a reply to this thread.