1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Uberfactory Supplement Dispensor Broke

Discussion in 'Requests' started by Wiz, Feb 16, 2018.

  1. Wiz

    Wiz Clockwork Customer

    Basically uberfactory dispenses water just not supplements, heres my code.

    Code:
    include("shared.lua");
    
    AddCSLuaFile("cl_init.lua");
    AddCSLuaFile("shared.lua");
    
    -- Called when the entity initializes.
    function ENT:Initialize()
        self:SetModel("models/MaxOfS2D/button_05.mdl");
       
        self:SetMoveType(MOVETYPE_VPHYSICS);
        self:PhysicsInit(SOLID_VPHYSICS);
        self:SetUseType(SIMPLE_USE);
        self:SetSolid(SOLID_VPHYSICS);
       
        self.tube = ents.Create("prop_dynamic");
        self.tube:DrawShadow(false);
        self.tube:SetAngles( self:GetAngles() + Angle(0,90,0));
        self.tube:SetParent(self);
        self.tube:SetModel("models/mechanics/solid_steel/box_beam_4.mdl");
        self.tube:SetMaterial("models/props_pipes/GutterMetal01a");
        self.tube:SetPos( self:GetPos() + Vector(-16,0,-6));
        self.tube:Spawn();
    
        self:DeleteOnRemove(self.tube);
           
        self:SetCollisionGroup(COLLISION_GROUP_WORLD);
       
        local phys = self:GetPhysicsObject()
        phys:SetMass( 120 )
       
        self:SetSpawnType(1);
    end;
    
    function ENT:SetSpawnType(entType)
        if (entType == TYPE_WATERCAN or entType == TYPE_CONSUMABLES) then
            self:SetDTInt(1,entType);
        end;
    end;
    
    function ENT:UpdateTransmitState()
        return TRANSMIT_ALWAYS;
    end;
    
    function ENT:EmitRandomSound()
        local randomSounds = {
            "ambient/machines/combine_terminal_idle2.wav",
            "buttons/button4.wav"
        };
       
        self:EmitSound( randomSounds[ math.random(1, #randomSounds) ] );
    end;
    
    function ENT:PhysicsUpdate(physicsObject)
        if (!self:IsPlayerHolding() and !self:IsConstrained()) then
            physicsObject:SetVelocity( Vector(0, 0, 0) );
            physicsObject:Sleep();
        end;
    end;
    
    function ENT:Use(activator, caller)
        if (activator:IsPlayer() and activator:GetEyeTraceNoCursor().Entity == self) then
            local curTime = CurTime();
           
            if (!self.nextUse or curTime >= self.nextUse) then
                self:EmitRandomSound();
               
                self:SpawnItem(activator);
               
                self.nextUse = curTime + 5;
            else
                self:EmitSound("buttons/button11.wav");
            end;
        end;
    end;
    
    function ENT:SpawnItem(activator)
        if (self:GetSpawnType() == TYPE_WATERCAN) then
            Clockwork.entity:CreateItem( activator, "breens_water", self.tube:GetPos());
        else
            Clockwork.entity:CreateItem( activator, "suppl_citizen", self:GetPos());
        end;
    end;
    
    function ENT:CanTool(player, trace, tool)
        return false;
    end;
    
     
  2. Wiz

    Wiz Clockwork Customer

    Yes it does but that didn’t work either
     
  3. Wiz

    Wiz Clockwork Customer

    Any ideas?
     
    • Good Coder Good Coder x 1
  4. Strange. Mine works fine, but I made a ton of modifications to it to fit my server. I presume it's the item IDs because that's all I changed with the supplement dispenser.
     

Previous Readers (Total: 0)