Donut Team is a labor of love, built and maintained by a small group of passionate developers. We invest our own time and resources to offer our tools, mods, and web services completely free of charge.

We don't run ads, and we will never sell your data - period.

If you've enjoyed anything we've created, please consider supporting our work with a one-time or monthly donation via our Ko-fi page . Every contribution helps us continue building great experiences for the community.

Dismiss
  • Modding Tools
  • Simpsons Hit & Run Multiplayer Server
  • Lua API Reference
  • Server Functions
  • Server.Players Functions

Server.Players.GetPlayersWhere

Available since Version 1.0.

Returns a filtered table of currently connected players matching the given filter criteria. If no filters are provided, all players are returned.

Syntax

Server.Players.GetPlayersWhere( filters, [ caseInsensitive ] )

Arguments

  • filters (table, optional): A table of key-value pairs to filter players by. Supported keys are:
    • name (string): Matches players by their name.
    • discriminator (string): Matches players by their discriminator.
    • mainMod (MainMod): Matches players by their selected main mod.
    • session (Session): Matches players by their session.
  • caseInsensitive (boolean, optional): Whether string filters should be matched in a case-insensitive manner. Defaults to true.

Return Values

  • (table): A table of Player objects matching all provided filters.

Examples

local filters = { name = "loren" }
local players = Server.Players.GetPlayersWhere(filters, false)
for i = 1, #players do
    local player = players[i]
    player:Kick("Get back to work on Donut Mod, " .. player.Name .. "!")
end