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!

HL2RP Biolocked Box?

Discussion in 'Development' started by The Way Home, Oct 9, 2016.

  1. Code:
    local ITEM = Clockwork.item:New();
    ITEM.name = "CPF Uniform Case";
    ITEM.model = "models/props_c17/consolebox05a.mdl";
    ITEM.weight = 4;
    ITEM.access = false;
    ITEM.useText = "Open";
    ITEM.category = "Storage"
    ITEM.business = true;
    ITEM.description = "A biolocked and heavy container, with a union logo stamped on the front in black.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
        player:GiveItem(Clockwork.item:CreateInstance("civil_protection_uniform"));
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    How would I go about making this box unopenable by any other faction than the MPF?
    Basically, a biolocked container.
     
  2. Zig

    Zig Guest

    Look in an item like a ration to find out more about faction whitelisting for items.
     
  3. Ty, think I've got it working now.
    Code:
    local ITEM = Clockwork.item:New();
    ITEM.name = "CPF Starter Kit";
    ITEM.model = "models/props_c17/consolebox05a.mdl";
    ITEM.weight = 4;
    ITEM.access = false;
    ITEM.useText = "Open";
    ITEM.category = "Storage"
    ITEM.business = true;
    ITEM.description = "A biolocked and heavy container, with a union logo stamped on the front in black.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
        if (player:GetFaction() == FACTION_CITIZEN) then
            Clockwork.player:Notify(player, "*Beep* Unauthorized Access Detected");
            ITEM.useSound = "HL1/fvox/flatline.wav";
            Clockwork.player:Notify(player, "*Beep* Alerting CPF within close vicinity");
            ITEM.useSound = "HL1/fvox/fuzz.wav" * 10;
       
        elseif (player:GetFaction() == FACTION_CWU) then
            Clockwork.player:Notify(player, "*Beep* Unauthorized Access Detected");
            ITEM.useSound = "HL1/fvox/flatline.wav";
            Clockwork.player:Notify(player, "*Beep* Alerting CPF within close vicinity");
            ITEM.useSound = "HL1/fvox/fuzz.wav" * 10;
           
            return false;
        else
            Clockwork.player:GiveCash(player, 500, "CPF starter kit");
            player:GiveItem(Clockwork.item:CreateInstance("civil_protection_uniform"));
            player:GiveItem(Clockwork.item:CreateInstance("union_grade_filter"));
            player:GiveItem(Clockwork.item:CreateInstance("")
           
        end;
    end;
    
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    Btw, I was assuming that doing
    ITEM.useSound = "HL1/fvox/fuzz.wav" * 10;
    would repeat the same line 10 times right?
    Or does it not in LUA?
     
  4. Zig

    Zig Guest

    I don't think so, although I may be wrong but I've literally never seen that be done before.
     
  5. huh, I assumed because learning about Python code, doing anything and putting * etc after quotes would repeat that line by etc - and I generally thought it would pass over through most codes.
    Guess I'll just have to see.
     
  6. Zig

    Zig Guest

    I don't think that's the case with lua.
     

Previous Readers (Total: 0)