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 Being able to use flashlight without holding it as a Citizen

Discussion in 'Development' started by Gravity Cat, Apr 1, 2018.

  1. Gravity Cat

    Gravity Cat Okay Clockwork Customer

    I want Citizens to be able to use a flashlight without holding it.
    I want the flashlight to not be equip able, just in your inventory.
    Basically, what CPs have, but you actually have to have the flashlight in your inventory as citizen to make it work.

    If anyone could help me, that'd be great! :)
     
  2. Aspect

    Aspect =) Legend Clockwork Customer

    Check the flashlight plugin
    I think
    I'll tell you for sure when I get on my computer.
     
    • Like Like x 1
  3. Viz

    Viz Legend Clockwork Customer

    Modify the function 'PlayerHasFlashlight' in 'cwhl2rp\plugins\flashlight\plugin\sv_plugin.lua' to the following:
    Code:
    -- A function to get whether a player has a flashlight.
    function PLUGIN:PlayerHasFlashlight(player)
        if (Schema:PlayerIsCombine(player) or player:GetFaction() == FACTION_CITIZEN) then
            return true;
        end;
      
        local weapon = player:GetActiveWeapon();
      
        if (IsValid(weapon)) then
            local itemTable = Clockwork.item:GetByWeapon(weapon);
          
            if (weapon:GetClass() == "cw_flashlight" or (itemTable and itemTable("hasFlashlight"))) then
                return true;
            end;
        end;
    end;
    
     
    • Good Coder Good Coder x 1
  4. Gravity Cat

    Gravity Cat Okay Clockwork Customer

    Thanks for your responce, but I mean I still want the Citizens to have to have the flashlight in their inventory to be able to use it.
     
  5. Viz

    Viz Legend Clockwork Customer

    My apologies, I didn't properly read your first message.
    Try this code in the same place instead:
    Code:
    -- A function to get whether a player has a flashlight.
    function PLUGIN:PlayerHasFlashlight(player)
        if (Schema:PlayerIsCombine(player) or Clockwork.inventory:HasItemByID(player:GetInventory(), "cw_flashlight")) then
            return true;
        end;
     
        local weapon = player:GetActiveWeapon();
     
        if (IsValid(weapon)) then
            local itemTable = Clockwork.item:GetByWeapon(weapon);
         
            if (weapon:GetClass() == "cw_flashlight" or (itemTable and itemTable("hasFlashlight"))) then
                return true;
            end;
        end;
    end;
    
     
    • Good Coder Good Coder x 1
    Last edited: Apr 1, 2018
  6. Gravity Cat

    Gravity Cat Okay Clockwork Customer

    Seems to be giving me script errors.
    [​IMG]
     
  7. Viz

    Viz Legend Clockwork Customer

    Edited my previous post, should work now.
     
  8. Gravity Cat

    Gravity Cat Okay Clockwork Customer

    Thanks, it worked!
    An admin can close this if they want.
     

Previous Readers (Total: 0)