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!

Other Auto-setting a title before a name for a specific faction

Discussion in 'Development' started by TacticalToaster, Dec 26, 2017.

  1. TacticalToaster

    TacticalToaster Clockwork Customer

    So, I got a quick question, as I'm not entirely sure how to do this. Basically, I'm making a military faction, and whenever someone creates a new character for it I want a title (Rct. for recruit) automatically added to the beginning of their name. I've been snooping through the framework, specifically cl_character.lua in the client folder of the libraries folder, and I found a part where it starts a datastream called "CreateCharacter" and gives the info given from the character creation process. I don't know how CW datastreams work, but I'm assuming if I can "hook" the datastream when it starts, I can just concatenate "Rct." onto the name with the passed info before the character creation process in the framework. I would hope there would be a way to do this with a schema file, but I guess I'm okay with editing the framework in a little way like this. Anyways, here's the section of the code where I found the datastream if you need more context:


    Code:
    function Clockwork.character:OpenNextCreationPanel()
        local activePanel = self:GetActivePanel();
        local nextPanel = self:GetNextCreationPanel();
        local panel = self:GetPanel();
        local info = self:GetCreationInfo();
       
        if (info.index > 0 and activePanel and activePanel.OnNext
        and activePanel:OnNext() == false) then
            return;
        end;
       
        if (!nextPanel) then
            Clockwork.plugin:Call(
                "PlayerAdjustCharacterCreationInfo", self:GetActivePanel(), info
            );
           
            Clockwork.datastream:Start("CreateCharacter", info);
        else
            info.index = nextPanel.index;
            panel:OpenPanel(nextPanel.vguiName, info);
        end;
    end;
     
  2. duck

    duck Phant0m Legend

    This is where plugins come into play. Make a plugin with an sv_hooks file and put this in it.
    Code:
    function PLUGIN:PlayerAdjustCharacterCreationInfo(player, info)
       if info.faction == FACTION_WHATEVER then
         local title = "Rct."
    
         info.name = ("%s %s"):format(title, info.name)
       end
    end
     
  3. TacticalToaster

    TacticalToaster Clockwork Customer

    Dude, you're a life saver! I didn't even know that a function like that exists. Beats having to do a bunch of crap with datastreams and modifying the framework. BTW, would this work with a schema instead by just replacing PLUGIN? I'm assuming so from what I know of clockwork
     
  4. duck

    duck Phant0m Legend

    Yes. Anywhere you see Clockwork.plugin:Call it means that clockwork is about to do something, and you can interact with it in a plugin or schema. If you are making a schema, you can simply replace PLUGIN, yeah.
     
  5. Aspect

    Aspect =) Legend Clockwork Customer

    Unless I am retarded, you could look into the HL2RP combine core hooks too to get an idea of how to do things.
     

Previous Readers (Total: 0)