• Medic Entity + weapon
    9 replies, posted
Hey FP! I need someone to make me a quick entity. Its an entity for my new gamemode. The entity would heal all players within a radius over time, maybe 5HP per second? This entity can only heal players on the same team as the person who placed it. That would be awesome! I also have another request. I need a SWEP to go along with that entity that spawns the entity as a model and freezes it on spawn. One last thing, a person may only have one at a time! That would be so awesome! Thanks in advance Facepunch!
It might be worth your trouble to either learn lua or get a job. You have like 30 posts in the requests section from the past 2 weeks.
[QUOTE=c-unit;27184926]It might be worth your trouble to either learn lua or get a job. You have like 30 posts in the requests section from the past 2 weeks.[/QUOTE] I do need to learn lua. I need so many small things done, but can never do them myself.
Then read the pil, and the tutorials.
Nothing says it's wrong posting 30 posts the last 2 weeks. Why not try helping him instead?
[lua] function ENT:Initialize() timer.Create("HealPlayers",1,0,self.HealPlayers,self) end function ENT:HealPlayers() for _,ply in pairs(player.GetAll()) do if (self:GetPos():Distance(ply:GetPos()) <= 256) and (ply:Team() == self.Owner:Team()) then ply:SetHealth(math.Clamp(ply:Health() + 5, 0, 100)) end end end [/lua] util.FindEntityInSphere would be also useful for that, but Garry didn't add this in Gmod.
ents.FindInSphere?
[lua] function ENT:Initialize() timer.Create("HealPlayers",1,0,self.HealPlayers,self) end function ENT:HealPlayers() for _,ply in pairs(ents.FindInSphere(self:GetPos(),256)) do if (ply:IsPlayer()) and (ply:Team() == self.Owner:Team()) then ply:SetHealth(math.Clamp(ply:Health() + 5, 0, 100)) end end end [/lua]
[QUOTE=SiPlus666;27306355][lua] function ENT:Initialize() timer.Create("HealPlayers",1,0,self.HealPlayers,self) end function ENT:HealPlayers() for _,ply in pairs(ents.FindInSphere(self:GetPos(),256)) do if (ply:IsPlayer()) and (ply:Team() == self.Owner:Team()) then ply:SetHealth(math.Clamp(ply:Health() + 5, 0, 100)) end end end [/lua][/QUOTE] This would be shared.lua for the entity? Can you also make a weapon that deploys this?
[QUOTE=Dwatring;27312644]This would be shared.lua for the entity? Can you also make a weapon that deploys this?[/QUOTE] It's serverside code. If you're limited to one file, put this into "if SERVER then" block. Weapon code: [lua] function SWEP:PrimaryAttack() for _,hkit in pairs(ents.FindByClass("Insert medkit classname here")) do if hkit.Owner == self.Owner then return end end local canspawn = util.TraceLine({ start = self.Owner:GetPos() + Vector(0,0,16); endpos = self.Owner:GetPos() + (self.Owner:GetForward()*32) + Vector(0,0,16); filter = self.Owner} if canspawn.Hit then return end local newkit = ents.Create("Insert medkit classname here") newkit:SetPos(self.Owner:GetPos() + self.Owner:GetForward()*32 + Vector(0,0,16) newkit:SetAngles(0,self.Owner:GetAngles().y,0) newkit:Spawn() newkit:SetMoveType(MOVETYPE_NONE) end [/lua]
Sorry, you need to Log In to post a reply to this thread.