Working with ULX and player groups - How can I check if a player's ULX group begins with a certain string?

So currently I’m working on this donator menu for my server. I need to enable the window only for people who have donated.

I can do


ply:CheckGroup("donator")

, but (due to certain conditions) there are tens of ULX donator ranks - e.g. donator_player1, donator_player2

Is there a way I can check for ULX Groups that start with the string “donator” and will return TRUE.

Something like


ply:CheckGroup("donator_*")

with * as a wildcard?

Many thanks,

Arizard

https://dl.dropboxusercontent.com/u/141442260/beta%20testing%20baby.png



	local donors = {
		"donor1",
		"donor2",
		"donor3"
	}
	
	if not table.HasValue( donors, ply:GetNWString("usergroup") ) then
		ply:ChatPrint("Error: You're not a donor!")
		return
	else
		...
	end


Or to answer your question more specifically, string.match is what you’re looking for.

Untested:



if (string.match(ply:GetNWString("usergroup"), "(donor_%)$")) then
	ply:ChatPrint("Cool, you're a donor")
else
	ply:ChatPrint("Error: You're not a donor!")
end


Second bit of code didnt work quite as i wanted, but it got me on the right track.


if ( string.lower(string.sub(LocalPlayer():GetNWString("usergroup"), 1, 8)) == "donator_") or LocalPlayer():GetNWString("usergroup") == "owner" then
	//LocalPlayer():ChatPrint("Cool, you're a donor")
	allowed()
	else
	//LocalPlayer():ChatPrint("Error: You're not a donor!")
	disallowed()
	end

Thanks! Now i know ULX uses a networked string, this makes life much easier!