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 Character Name Prefix - How to set one?

Discussion in 'Development' started by Lockdown10, Feb 14, 2019.

  1. Lockdown10

    Lockdown10 Luke D R

    Hey guys.

    Just wandering what function would assign a "prefix" to a character based on their faction. For instance: the MPF faction sets the prefic to "MPF-RCT." what not, followed by the digits function(Which I DON'T WANT, mind you), that sets the characters name automatically to MPF-RCT.***** - However! I wish to have a prefix (In this case, "Rct. " Space included at the end), but then allow the player to then input their own characters name. Like you would when creating a Citizen character. But when spawning in on your character, we'll call him Ben Dover, the character will appear as "Rct. Ben Dover".

    Aforementioned; "Rct. " is the prefix I want, followed by the players inputted character name.

    Anyone got any idea how I'd be able to manipulate a function to do this?
    I am also aware of the following function:
    Code:
    function FACTION:GetName(player, character)
        return ""
    So would there be anything I can do to manipulate that in to outputting what I need?

    Thanks for any help provided!
     
  2. vexus

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

    with this i'd recommend using the PlayerCharacterCreated hook so that the name is only set once when the character is created. then you could do something along the lines of:
    Code:
    local PLUGIN = PLUGIN;
    
    function PLUGIN:PlayerCharacterCreated(player)
        local faction = player:GetFaction();
        local name = player:GetName();
    
        if (faction == YOUR_FACTION) then
            Clockwork.player:SetName(player, "Rct. " .. name, true);
        else
            return false;
        end
    end
    
    i'm not able to test this atm so some of this is probably wrong, but the concept is there.

    EDIT: cleaner way to do this.

    Code:
    function PLUGIN:PlayerAdjustCharacterCreationInfo(player, info)
       if (info.faction == YOUR_FACTION) then
           info.name = "Rct. " .. info.name;
       end
    end
    
     
    • Agree Agree x 1
    Last edited: Feb 14, 2019
  3. Lockdown10

    Lockdown10 Luke D R

    Thanks Vexus, I'll give it a go.
     

Previous Readers (Total: 0)