rebel1324 / NutScript

A free role-play framework for Garry's Mod.
http://nutscript.net
MIT License
65 stars 31 forks source link

Faction - Character Name Prefix Function #284

Closed LukeTheDamnBrit closed 5 years ago

LukeTheDamnBrit commented 5 years ago

Hey!

Just wondering what the function would be to set a prefix for a faction? Unlike Civil Protection where it calls three parts of a name, the cpPrefix, then cpDefaultRank and the digits; I want a function that simply adds "Rct. " to the beginning of a name, that someone can make themselves. For instance, when creating a new character of the "Lambda" faction, I want them to be able to create their own name, but it forces the "Rct. " prefix onto their name.

I've tried using such as function FACTION:onGetDefaultName(client, digits) local name = SCHEMA.lambdaPrefix so forth, so on. Having also identified the "SCHEMA.lambdaPrefix" in the config.lua along with the ota and cp ones also.

Anyone got any idea what the function could be?

ghost commented 5 years ago

SCHEMA.config.owPrefix = "C17.OTA." SCHEMA.config.owDigitsLen = 5 SCHEMA.config.owDivisions = {"ECHO", "SENTINEL", "HURRICANE", "APHELLION", "SHIELD", "SWORD", "RANGER", "SHELL", "PACE", "KING"} Ehhh?

ghost commented 5 years ago

function FACTION:onGetDefaultName(client) if (SCHEMA.config.owDigitsLen >= 1) then local digits = math.random(tonumber("1"..string.rep("0", SCHEMA.config.owDigitsLen - 1)), tonumber(string.rep("9", SCHEMA.config.owDigitsLen)))

    return SCHEMA.config.owPrefix..table.GetFirstValue(SCHEMA.config.owRanks.unitRanks).."."..digits, true
else
    return SCHEMA.config.owPrefix..table.GetFirstValue(SCHEMA.config.owRanks.unitRanks), true
end

end

LukeTheDamnBrit commented 5 years ago

SCHEMA.config.owPrefix = "C17.OTA." SCHEMA.config.owDigitsLen = 5 SCHEMA.config.owDivisions = {"ECHO", "SENTINEL", "HURRICANE", "APHELLION", "SHIELD", "SWORD", "RANGER", "SHELL", "PACE", "KING"} Ehhh?

Cheers, but I'm looking for a function that simply puts a prefix, in my case "Rct." is the prefix. So someone would create the character "David Barnes" and when he spawns, "Rct. " will be in front of his name. I don't want any digits, specified by the "config.owDigits" or "config.cpDigits" function. Just the first bit, before the name. hence prefix.

LukeTheDamnBrit commented 5 years ago

SCHEMA.config.owPrefix = "C17.OTA." SCHEMA.config.owDigitsLen = 5 SCHEMA.config.owDivisions = {"ECHO", "SENTINEL", "HURRICANE", "APHELLION", "SHIELD", "SWORD", "RANGER", "SHELL", "PACE", "KING"} Ehhh?

For instance; is there a function that can go in the faction file, in this case sh_lambda.lua, like "FUNCTION.prefix = "Rct. " or something like that?

LukeTheDamnBrit commented 5 years ago

Anyone?

SleepyMode commented 5 years ago

Could just add an hook to modify the name after the character was created?

LukeTheDamnBrit commented 5 years ago

Could just add an hook to modify the name after the character was created?

I could, but of course I'd need to know what to put IN the hook. What function and such, as I've tried stripping down the naming function in the Civil Protection faction which was in there, but to no avail.

SleepyMode commented 5 years ago

Could just add an hook to modify the name after the character was created?

I could, but of course I'd need to know what to put IN the hook. What function and such, as I've tried stripping down the naming function in the Civil Protection faction which was in there, but to no avail.

character:setName("Rct. " .. character:getName())
SleepyMode commented 5 years ago

You can put it down in CreateDefaultInventory I suppose, as it's the only hook that runs following character creation at 1.1-beta at the moment.

function SCHEMA:CreateDefaultInventory(character)
    if (character:getFaction() == FACTION_MPF) then
        character:setName("Rct. " .. character:getName())
    end
end

Or, if you're looking for prefixes for different factions:

local factionPrefixes = {
    [FACTION_MPF] = "Rct. ",
    [FACTION_CONSCRIPT] = "Pvt. "
}

function SCHEMA:CreateDefaultInventory(character)
    local factionPrefix = factionPrefixes[character:getFaction()]

    if (factionPrefix) then
        character:setName(factionPrefix .. character:getName())
    end
end