Vice City: Multiplayer

Server Development => Scripting and Server Management => Script and Content Requests => Topic started by: Xmair on Aug 13, 2017, 12:39 PM

Title: Find something by using an alphabet of it
Post by: Xmair on Aug 13, 2017, 12:39 PM
As the topic states, I'm searching for a function like FindPlayer, if a player's name is "Xmair" you just use "ma" and it'd find the instance. Help is appreciated.
Title: Re: Find something by using an alphabet of it
Post by: . on Aug 13, 2017, 12:55 PM
In my plugin there would be string masks. Like:
SqFind.Player.NameMatches(false, false, "*ma*");
Where it would search anything that contains `ma`. The `*` simply specifies: "I don't care what comes before it or after it." While `?` would take the place of any character. The first boolean would negate the result such that it finds someone where the name doesn't contain `ma`. And the second boolean controls case sensitivity.

But that would be in my plugin. In the official plugin, I have no idea what builtin method you would use because I'm not aware of one. Probably you'll have to do it manually through some regex.
Title: Re: Find something by using an alphabet of it
Post by: EK.IceFlake on Aug 13, 2017, 02:02 PM
FindPlayer("ma"); finds Xmair
:edit: If you just want to check if a string contains something:
local string = "TestingString";
if (string.find("ngSt") != null) print("This gets printed");
else if (string.find("ma") != null) print("This doesn't get printed");
Title: Re: Find something by using an alphabet of it
Post by: Xmair on Aug 13, 2017, 05:12 PM
Solved. Thank you everyone and @Doom_Kill3R