Hey guys,
So a few weeks ago I posted something about Haax (Shoot though Con command) But now for a project, I want to make something like the Hax but On hit it needs to disslove Props, players, npc's etc. (Like the AR2 Secondary Fire (combine ball)) but you need to look at it and then it dissloves the thing you look at.
Code:
[lua]
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')
function ENT:Initialize()
self.DieTime = CurTime() + 9
local pl = self.Entity:GetOwner()
local aimvec = pl:GetAimVector()
self.Entity.Team = pl:Team()
self.Entity:SetPos(pl:GetShootPos() + pl:GetAimVector() * 30)
self.Entity:SetAngles(pl:GetAimVector():Angle()* math.random(1,45))
self.Entity:SetModel("models/props_lab/monitor01a.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
local phys = self.Entity:GetPhysicsObject()
if phys:IsValid() then
phys:SetMass(200)
end
self.Touched = {}
self.OriginalAngles = self.Entity:GetAngles()
end
function ENT:Think()
if CurTime() > self.DieTime then
self.Entity:Remove()
end
end
function ENT:PhysicsCollide(data, phys)
local hitEnt = data.HitEntity
if (self.Entity.Hit) then return end
self.Entity.Hit = true
self.HitTime = CurTime()
hitEnt:TakeDamage(9999, self:GetOwner(), self.Disslove())
self.Entity:EmitSound("physics/metal/metal_box_break"..math.random(1,2)..".wav")
function self:PhysicsCollide() end
end
[/lua]
The Model etc. Ill change later but first i need to get working that when this "monitor" hits something, that thing dissloves, Maybe is there a way to do it witout shooting something? It just dissloves?
Hope this is Understandable.
[QUOTE=PortalGod;28916590][url=http://developer.valvesoftware.com/wiki/Env_entity_dissolver]Env_entity_dissolver[/url][/QUOTE]
Sorry but this is not really clear for me :l
[code]local diss = ents.Create("env_entity_dissolver")
npc:SetName(tostring(npc))
diss:SetPos(npc:GetPos())
diss:SetKeyValue("target", npc:GetName())
diss:Spawn()
diss:Fire("Dissolve", "", 0)
diss:Fire("kill", "", 0.1)
[/code]
npc is the entity you want to dissolve
[QUOTE=Lexsym;28921750][code]local diss = ents.Create("env_entity_dissolver")
npc:SetName(tostring(npc))
diss:SetPos(npc:GetPos())
diss:SetKeyValue("target", npc:GetName())
diss:Spawn()
diss:Fire("Dissolve", "", 0)
diss:Fire("kill", "", 0.1)
[/code]
npc is the entity you want to dissolve[/QUOTE]
Cool trick:
[code]diss:SetEntity( "target", npc )[/code]
If you need to dissolve a bunch of things, don't spawn a new entity for each entity you're dissolving, don't kill a single one until the end.
Tried it, and it didn't work.
[QUOTE=PortalGod;28922055]If you need to dissolve a bunch of things, don't spawn a new entity for each entity you're dissolving, don't kill a single one until the end.[/QUOTE]
There is actolly no need for specific entity (npc, players, props etc.) just disslove something where you look at so it would be something with this diss:SetPos(npc:GetPos()) but i'm not sure of that.
[QUOTE=Ranger1201;28927104]There is actolly no need for specific entity (npc, players, props etc.) just disslove something where you look at so it would be something with this diss:SetPos(npc:GetPos()) but i'm not sure of that.[/QUOTE]
I'm pretty sure that won't work.
[QUOTE=PortalGod;28929343]I'm pretty sure that won't work.[/QUOTE]
Yeah true, but is there a way how we can make it work?
Untested. I doubt it will work, but you can get the idea:
[lua]
function ENT:Touch(Entity)
if(Entity:IsPlayer()) then return end
if not(IsValid(self.Dissolver)) then
self.Dissolver = ents.Create("env_entity_dissolver")
self.Dissolver:SetKeyValue("dissolvetype", 1)
self.Dissolver:Spawn()
end
local rand = math.random(1, 10^5)
Entity:SetName("Dissolve"..rand)
timer.Simple(0, function(self)
self.Dissolver:Fire("dissolve", "Dissolve"..rand)
end, self)
end
[/lua]
[QUOTE=PortalGod;28930307]Untested. I doubt it will work, but you can get the idea:
[lua]
function ENT:Touch(Entity)
if(Entity:IsPlayer()) then return end
if not(IsValid(self.Dissolver)) then
self.Dissolver = ents.Create("env_entity_dissolver")
self.Dissolver:SetKeyValue("dissolvetype", 1)
self.Dissolver:Spawn()
end
local rand = math.random(1, 10^5)
Entity:SetName("Dissolve"..rand)
timer.Simple(0, function(self)
self.Dissolver:Fire("dissolve", "Dissolve"..rand)
end, self)
end
[/lua][/QUOTE]
Hmm well I still dont have quite a Idea how it would exacly work.. sorry :l
Btw with No idea I mean how to make above code up into my Monitor ent I posted before
I pretty much wrote the code for you, it might even work if you copy/paste it.
[QUOTE=PortalGod;29021795]I pretty much wrote the code for you, it might even work if you copy/paste it.[/QUOTE]
Tried it, doesnt work, monitors gets stuck in the air and it doesnt shoot it. Also I tried to use it at a prop then they just fall down but nothing happens.
Bump, help?
I feel bad for this guy, he has been trying to modify the HAAX SWep for like a month now. Please help him
[b][u][i]BUMP![/b][/u][/i]
[QUOTE=cis.joshb;29308802]I feel bad for this guy, he has been trying to modify the HAAX SWep for like a month now. Please help him
[b][u][i]BUMP![/b][/u][/i][/QUOTE]
17 hours doesn't need a bump. And I've already spoon fed him the code.
[QUOTE=cis.joshb;29308802]I feel bad for this guy, he has been trying to modify the HAAX SWep for like a month now. Please help him
[b][u][i]BUMP![/b][/u][/i][/QUOTE]
:dumb:
How it doesnt work?
[QUOTE=PortalGod;29309311]17 hours doesn't need a bump. And I've already spoon fed him the code.[/QUOTE]
But it does not work like I posted before, thats why I ask again for help "monitors gets stuck in the air and it doesnt shoot it. Also I tried to use it at a prop then they just fall down but nothing happens. "
Bump
Have you set the owner?
Well.. the hax itself works, it knows that I shoot it. Only on touch it doesnt disslove Dont know if you mean that
[QUOTE=cis.joshb;29357849]Have you set the owner?[/QUOTE]
[QUOTE=cis.joshb;29362356][/QUOTE]
I did.. I think..
Im useing Portal's code:
[lua]
function ENT:Touch(Entity)
if(Entity:IsPlayer()) then return end
if not(IsValid(self.Dissolver)) then
self.Dissolver = ents.Create("env_entity_dissolver")
self.Dissolver:SetKeyValue("dissolvetype", 1)
self.Dissolver:Spawn()
end
local rand = math.random(1, 10^5)
Entity:SetName("Dissolve"..rand)
timer.Simple(0, function(self)
self.Dissolver:Fire("dissolve", "Dissolve"..rand)
end, self)
end
[/lua]
Edit: If you need the hax command ill post it
I just realized I forgot to put rand as an argument for the timer in my code. You should do that.
Setting the owner disables collision for some things:
Does not work:
Code:
[lua]function ENT:Touch(Entity)
if(Entity:IsPlayer()) then return end
if not(IsValid(self.Dissolver)) then
self.Dissolver = ents.Create("env_entity_dissolver")
self.Dissolver:SetKeyValue("dissolvetype", 1)
self.Dissolver:Spawn()
end
local rand = math.random(rand,1, 10^5)
Entity:SetName("Dissolve"..rand)
timer.Simple(0, function(self)
self.Dissolver:Fire("dissolve", "Dissolve"..rand)
end, self)
end
[/lua]
I said to use it as an argument for the timer, not math.random.
Sorry, you need to Log In to post a reply to this thread.