Skip to main content

GetPlayerFromName

This method returns a Player param from a given player name, returns null if the player name does not exist.

Syntax

```csharp Player NAPI.Player.GetPlayerFromName(string name); ```

Required Arguments

  • name: parameter input should be in string type.

NOTE: This function returns data in Player type.

Usage example

Check if the name Bob exists.

```csharp

   bool exists = NAPI.Player.GetPlayerFromName("Bob") != null;
   if(exists) NAPI.Chat.SendChatMessageToAll("BOB EXISTS!!!");

```

Kick the Player if their name exists.

```csharp

   string name = "Bob";
   Player target = NAPI.Player.GetPlayerFromName(name);
   bool exists = target != null;
   if (exists) NAPI.Player.KickPlayer(target, "Flock you Bob!");

```