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!

Third Person Flashlight & Entity Password problem.

Discussion in 'Development' started by DarkMind187, Jul 15, 2015.

  1. DarkMind187

    DarkMind187 Clockwork Customer

    Hello, Cloud Sixteen Developers!
    I'm newbie in Lua. And, I need in your wise advice!
    I'm sorry for grammar errors. I'm not good in English, but I'll try to describe my problems.

    Third Person Flashlight.
    I did download 'Third Person Flashlight' and put it in addons folder. Next I get that problem - my flashlight has 2 beams.
    How can I remove that down beam?
    [​IMG]

    Entity Password.
    I have entity which has function. I need to do password for entity before use. When I use 'setPassword' command for this entity - function don't work.
    My code:

    entity's init.lua
    Code:
    function ENT:Use(player)
        local entPW = self.cwPassword;
    
        if (!entPW) then
            -- function here --
        else
            Clockwork.datastream:Start(player, "cwEntityPassword", data);
        end;
    end;
    
    sh_entitysetpassword.lua
    Code:
    local COMMAND = Clockwork.command:New("EntitySetPassword");
    COMMAND.tip = "Set a entity's password.";
    COMMAND.text = "<string Pass>";
    COMMAND.flags = CMD_DEFAULT;
    COMMAND.access = "a";
    COMMAND.arguments = 1;
    
    -- Called when the command has been run.
    function COMMAND:OnRun(player, arguments)
        local trace = player:GetEyeTraceNoCursor();
       
        if (IsValid(trace.Entity)) then           
            trace.Entity.cwPassword = table.concat(arguments, " ");
       
            Clockwork.player:Notify(player, "This entity's password has been set to '"..trace.Entity.cwPassword.."'.");
        else
            Clockwork.player:Notify(player, "This is not a valid entity!");
        end;
    end;
    
    COMMAND:Register();
    
    cl_plugin.lua
    Code:
    Clockwork.datastream:Hook("cwEntityPassword", function(data)
        Derma_StringRequest("Password", "What is the password for this entity?", nil, function(text)
            Clockwork.datastream:Start("cwEntityPasswordReply", {text});
        end);
    end);
    
    sv_plugin.lua
    Code:
    Clockwork.datastream:Hook("cwEntityPasswordReply", function(data)
        local password = data[1] or "my_very_very_admin_sicret_password";
        local entPW = self.cwPassword;
           
        if (entPW and password == entPW) then
           -- function here --
        else
           return;
        end;
    end);
    

    What is wrong with this?
    Thanks in advance.
    I believe and hope that in future I'll become a good coder! =)
     
  2. DarkMind187

    DarkMind187 Clockwork Customer

    And I have new problem with my Hunger plugin.

    client console error
    Code:
    [Clockwork:Hunger]
    The 'GetBars' hook has failed to run.
    gamemodes/clockwork/plugins/hunger/plugin/cl_hooks.lua:39: attempt to concatenate local 'text' (a nil value)
    
    cl_hooks.lua
    Code:
    -- Called when the bars are needed.
    function PLUGIN:GetBars(bars)
        local hunger = Clockwork.Client:GetSharedVar("Hunger");
     
        if (!self.hunger) then
            self.hunger = hunger;
        else
            self.hunger = math.Approach(self.hunger, hunger, 1);
        end;
     
        if (self.hunger <= 100) then
            local text = text;
            local color = color;
    
            if ( (self.hunger <= 100) and (self.hunger > 50) ) then
                text = "Well fed";
                color = Color(34, 139, 34, 255);
    
            elseif ( (self.hunger <= 50) and (self.hunger > 35) ) then
                text = "I want to eat";
                color = Color(255, 255, 0, 255);
    
            elseif ( (self.hunger <= 35) and (self.hunger > 20) ) then
                text = "Really want eat";
                color = Color(255, 140, 0, 255);
    
            elseif ( (self.hunger <= 20) and (self.hunger > 0) ) then
                text = "Starving";
                color = Color(255, 0, 0, 255);
            end;
    
            bars:Add("HUNGER", color, "Hunger: "..text.." ("..math.Round(self.hunger).."%)", self.hunger, 100, self.hunger < 20);
        end;
    end;
    
     
  3. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    Hey this is kinda off-topic but were you the guy that was always in the old Russian sector in early 2014?
     
    • Friendly Friendly x 1
  4. DarkMind187

    DarkMind187 Clockwork Customer

    Yes, It's me! :)
    Russian sector fell, so I have nowhere else to turn. :(
     
  5. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    Oh haha, good to see you back ♥
     
  6. DarkMind187

    DarkMind187 Clockwork Customer

    You have a good memory for the nicknames! =)
     
    • Friendly Friendly x 1
  7. DarkMind187

    DarkMind187 Clockwork Customer

    Anybody can help me?
     
  8. DarkMind187

    DarkMind187 Clockwork Customer

    How do I may invite developers in my thread?
    I need just use "@<nickname>"? And who of them can help me?
     
  9. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

  10. duck

    duck Phant0m Legend

    On the server, the first argument to datastream callbacks is the player, not the data. Change
    Code:
    Clockwork.datastream:Hook("cwEntityPasswordReply", function(data)
    to
    Code:
    Clockwork.datastream:Hook("cwEntityPasswordReply", function(player, data)
    I skimmed the code, but that's what I found.
     

Previous Readers (Total: 0)