Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is it possible to kick a player from your game if their name contains a set word?

Asked by
in_sin 2
6 years ago

So if a player had 'Xx' in there name, anywhere in there name, they'd get kicked when'd they try to join the game. Is this possible or not?

1 answer

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago
Edited 6 years ago

Yes. Not sure of this purpose though... Kind of discrimination...

function check(p)
    local maxCombo = string.len(p.Name)  - 1 -- How many possible combinations where 'Xx' could be
    local i = 0 -- Current combo
    while true do -- A loop, to go through all combos
        if i == maxCombo then -- Searched all possible combinations, stop trying
            return false
        end
        local current = string.sub(p.Name, i + 1, i + 3)  -- Grab combo that we are checking
        if string.lower(current) == "xx" then -- If our current combo matches, stop checking, return positive
            return true
        end
        i = i + 1 -- Move to the next combo
    end
end

check(game.Players.XxNamexX) -- > true
check(game.Players.H4X0MSYT) -- > false
0
Thank you, much appreciated. Also, Xx was just the first example that popped into my head. I was just planning on using this to kick people who have sort clan names. Such as EXAMPLE_Doggo, so on.. But, once again thank you in_sin 2 — 6y
0
Would string.contains() or string.find("Hello my friend":lower(), "hello") not be a much simpler job than rolling-your-own string search? A good string search is pretty hard to write. fredfishy 833 — 6y
Ad

Answer this question