1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
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 Active Member

    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 Hey Pal, did you just blow in from stupid town? Active Member

    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 Active Member

    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 Active Member

    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 Active Member

    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 Active Member

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

    Viz Legend Clockwork Customer Active Member

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

    Gravity Cat Okay Clockwork Customer Active Member

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

Previous Readers (Total: 0)