This site has been archived and made available for preservation purposes. No edits can be made.

OnClientAuthenticate

(Difference between revisions)
Return to current revision
Current Revision 09-09-2012, 12:07 PM
  1.  
    Gets called when a client attempts to connect to the server.
  2. -

    == Declaration ==
    <code cpp>
    VAULTSCRIPT bool OnClientAuthenticate(std::string, std::string);
  3. +
    [h="2"] Declaration [/h]
    [highlight=cpp]
    VAULTSCRIPT VAULTSPACE State OnClientAuthenticate(VAULTSPACE cRawString, VAULTSPACE cRawString) _CPP(noexcept);
    [/highlight]
    [highlight=c]
  4.  
    forward OnClientAuthenticate(const name{}, const pwd{});
  5. -
    </code>
    == Parameters ==

    [[File:Authenticate.png|right|thumb|This is what gets passed to the callback]]

    '''name''' - the name of the client (guaranteed to be at least 3 and at maximum [[MAX_PLAYER_NAME]] characters long)

    '''pwd''' - the password of the client (guaranteed to be at maximum [[MAX_PASSWORD_SIZE]] characters long)

    == Return value ==

    The C++ version returns a std::string containing the name. The PAWN version has no return value.

    == Usage example (C++) ==

    <code cpp>
    std::string name;
    name = GetName(object);
    </code>

    == Usage example (PAWN) ==

    <code c>
    new name{MAX_PLAYER_NAME};
    GetName(player, name);
    </code>
  6. +
    [/highlight]
    [h="2"] Parameters [/h]
    [image]Authenticate.png|right|thumb|This is what gets passed to the callback[/image]
    [b][wiki]cRawString[/wiki][/b] - the name of the client (guaranteed to be at least 3 and at maximum [wiki]MAX_PLAYER_NAME[/wiki] characters long)
    [b][wiki]cRawString[/wiki][/b] - the password of the client (guaranteed to be at maximum [wiki]MAX_PASSWORD_SIZE[/wiki] characters long)
    [h="2"] Return value [/h]
    If returned [wiki]True[/wiki], the client is allowed to connect and play on this server. If returned [wiki]False[/wiki], the client gets kicked (authentication denied).
    [h="2"] Usage examples[/h]
    [highlight=cpp]
    State VAULTSCRIPT OnClientAuthenticate(cRawString name, cRawString pwd)
    {
    return True; // Everybody is allowed to connect
    }
    [/highlight]
    [highlight=c]
    public OnClientAuthenticate(const name {}, const pwd {})
    {
    return true; // Everybody is allowed to connect
    }
    [/highlight]
    [category]VaultMP interface[/category]
    [category]Scripting callbacks[/category]