So I have been working on money printers for DarkRP and I am trying to fix a bug that occurs when you have two printers close to each other and you drop in one of the entities that use the StartTouch function, like the batteries, health cell, and silencer upgrade. What happens is you will drop the entity in the printer and if two printers are too close, the StartTouch effects can apply to both printers when I just want it to apply to one of them. This is a major issue since some of these entities cost a lot and when the player only has to buy one to apply to two printers, it can be abusive.
This is some of the code in my StartTouch:
function ENT:StartTouch( hitEnt )
if hitEnt.IsCell then
if self.Power <= 80 then
self.Cell= hitEnt;
self.Power = 100;
self:SetNWInt( "Power", self.Power );
self.Cell:Remove();
else
return
end
end
end
P.s. What the hell is this code containment block ^ It fucked up all my code
Thanks for the help!
Set a variable on `hitEnt`, e.g.
hitEnt.hasBeenConsumed = true
Then check if it has the variable in your function, if it does then it has already been consumed by another printer.
Wow, I am quite stupid for not trying this. Thanks for the help.
Sorry, you need to Log In to post a reply to this thread.