GetPlayerFromName

From GTA Network Wiki
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

Client NAPI.Player.GetPlayerFromName(string name);

Required Arguments

  • name: parameter input should be in string type.

NOTE: This function returns data in Client type.

Usage example

Check if the name Bob exists.

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

Kick the Player if their name exists.

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

Changelog

Version Description
1.0 Release.

References