GetPlayerFromName

From GT-MP
Jump to: navigation, search
GetPlayerFromName
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

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

Syntax

In C#
Server-Side Function

API.getPlayerFromName(string name);

Required Arguments

  • name parameter input should be in string type.


NOTE: This function returns data in Client type.

Usage example

Kick the Player if their name exists.

In C#
Server-Side Function

string name = "Bob";
Client target = API.getPlayerFromName(name);
bool exists = target != null;
if (exists) API.kickPlayer(target, "Flock you Bob!");

Check if the name Bob exists.

In C#
Server-Side Function

bool exists = API.getPlayerFromName("Bob") != null;
if(exists) API.sendChatMessageToAll("BOB EXISTS!!!");

References