GetPlayerFromName

From RAGE Multiplayer Wiki
Revision as of 13:22, 27 November 2019 by Muphy (talk | contribs) (Created page with "This method returns a Player param from a given player name, returns '''null''' if the player name does not exist. ==Syntax== <syntaxhighlight lang="C#" >Client NAPI.Player.G...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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!");