Code:
-- A function to check if a player is a Combine rank.
function Schema:IsPlayerCombineRank(player, rank, realRank)
local name = player:Name();
local faction = player:GetFaction();
if (self:IsCombineFaction(faction)) then
if (type(rank) == "table") then
for k, v in ipairs(rank) do
if (self:IsPlayerCombineRank(player, v, realRank)) then
return true;
end;
end;
elseif (rank == "EpU" and !realRank) then
if (string.find(name, "%pSeC%p") or string.find(name, "%pDvL%p")
or string.find(name, "%pEpU%p")) then
return true;
end;
else
return string.find(name, "%p"..rank.."%p");
end;
end;
end;
IsPlayerCombineRank() will fetch a string out of the player's name using string.find(name, "%p"..rank.."%p"); and then return the rank if it finds it in their name.
So doing IsPlayerCombineRank(player, "HELIX.DvL") will search that player's name for the string "HELIX.DvL" and, if it finds it, the function will return true.
Code:
-- A function to check if a string is a Combine rank.
function Schema:IsStringCombineRank(text, rank)
if (type(rank) == "table") then
for k, v in ipairs(rank) do
if (self:IsStringCombineRank(text, v)) then
return true;
end;
end;
elseif (rank == "EpU") then
if (string.find(text, "%pSeC%p") or string.find(text, "%pDvL%p")
or string.find(text, "%pEpU%p")) then
return true;
end;
else
return string.find(text, "%p"..rank.."%p");
end;
end;
IsStringCombineRank() does the same thing as the IsPlayerCombineRank() function, except it searches the string you provide instead of a player for a rank.
So doing IsStringCombineRank(".RCT.", "RCT") would return true, whereas IsStringCombineRank("jimbo", "RCT") would return false. I think. I could be wrong.
For what you're trying to do, you'll want to use IsPlayerCombineRank()
EDIT: Also, forgot to add, %p is checking for any punctuation before or after the rank you provide.