rebel1324 / NutScript

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

Faction Player Limit #287

Closed PaXo0 closed 5 years ago

PaXo0 commented 5 years ago

When i set a limit to 1 on the Civil protection and I am in the job role and a friend tries to join the role it allows him in when the limit is set as 1 and there are no console errors (using 1.1)

`FACTION.name = "fCopName" FACTION.desc = "fCopDesc" FACTION.color = Color(25, 30, 180) FACTION.isDefault = false FACTION.limit = 1 FACTION.models = { "models/police.mdl" } FACTION.weapons = {"nut_stunstick"} FACTION.pay = 25 FACTION.isGloballyRecognized = true

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

    local name = SCHEMA.cpPrefix
        ..table.GetFirstValue(SCHEMA.rctRanks)
        .."."
        ..digits
    return name, true
else
    return SCHEMA.cpPrefix..table.GetFirstValue(SCHEMA.rctRanks), true
end

end

function FACTION:onTransfered(client, oldFaction) local digits

if (oldFaction.index == FACTION_CITIZEN) then
    local inventory = client:getChar():getInv()
    if (inventory) then
        for _, item in pairs(inventory:getItems()) do
            if (item.uniqueID == "cid" and item:getData("id")) then
                digits = item:getData("id")
                break
            end
        end
    end
elseif (oldFaction.index == FACTION_OW) then
    digits = client:getDigits()
elseif (oldFaction.index == FACTION_CP) then
    return
end

client:getChar():setName(self:onGetDefaultName(client, digits))
hook.Run("PlayerLoadout", client)

end

FACTION_CP = FACTION.index `

brianhang commented 5 years ago

Limit only works for 1.1-beta.