During my endeavors trying to accomplish this entity, it's checking for money printers and then adds them to a variable to figure out the total entities in the given radius... The problem is it's activating and adding when there aren't specific entities of the given classname, thus ruining the plan.
Here's the code.
function ENT:Think()
self:SetNWInt("addedPrinters",0)
-- resets the addedprinters variable since this is the think variable
-- SpawnedMoneyPickup is the radius of which the findsphere is
for k,v in pairs(ents.FindInSphere(self:GetPos(),SpawnedMoneyPickup)) do
if v:GetClass() == "spawned_money" then
self:SetNWInt("stored",self:GetNWInt("stored") + v:Getamount())
-- Adds spawned_money value to the collecter
v:Remove() -- removes spawned_money entity
end
end
for k,v in pairs(ents.FindInSphere(self:GetPos(),SpawnedMoneyPickup)) do
if v:GetClass() == "money_printer" or "vrondakis_printer" then
--self:SetNWInt("stored",self:GetNWInt("stored") + v:Getamount())
self:SetNWInt("addedPrinters",self:GetNWInt("addedPrinters") + 1)
end
end
end
I've thought of trying to add a variable which would just hold all the printers as entities and i could just look through it and add , but i'm not sure how you can specifically add these and check if the same printer is already added to the list... Any help would be appreciated <3
(With Printers)
https://files.facepunch.com/forum/upload/134032/8d4380db-3a5b-4100-b6bb-393701a5ac71/image.png
(Without)
https://files.facepunch.com/forum/upload/134032/124b5667-2e64-473a-9436-456b32c99614/image.png
if v:GetClass() == "money_printer" or "vrondakis_printer" then
to
if v:GetClass() == "money_printer" or v:GetClass() == "vrondakis_printer" then
Thank you very much I'm confused why it considers everything as true still even if its just the string
nvm realized after thinking about it, its just setting the thing to that instantly making it true. (at least i'm assuming)
A variable whose value is not nil will always evaluate to true when used in an if statement like that. Imagine the string being replaced with true and anything that's equal to nil being replaced by false.
Sorry, you need to Log In to post a reply to this thread.