[Include] OnPlayerRconLoginAttempt
#1

Hi, I'm releasing my first include, it's named " OnPlayerRconLoginAttempt "
This is simple, and self explained.

It's a callback, these are the parameters
pawn Код:
public OnPlayerRconLoginAttempt( playerid, password[ ], success )

/*
    playerid = the playerID
    password = the password that is entered
    success = if success, it returns 1 and if failed it returns 0
*/
- What's the requirements

You only need foreach ( Optional though, you can still use the include without foreach ).

- Okay, where is the code?

Here :

pawn Код:
/*
    [ INC ] OnPlayerRconLoginAttempt
*/


#tryinclude < foreach >

#if defined _OPRLA_included
    #endinput
#endif

#define _OPRLA_included

forward OnPlayerRconLoginAttempt( playerid, password[ ], success );

public OnPlayerConnect( playerid )
{
    new
        szIP[ 16 ]
    ;
   
    GetPlayerIp( playerid, szIP, 16 );
   
    SetPVarString( playerid, "PVar_IP", szIP );
   
    CallLocalFunction( "my_OnPlayerConnect", "i", playerid );
   
    return 1;
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif

#define OnPlayerConnect my_OnPlayerConnect

forward my_OnPlayerConnect( playerid );

public OnRconLoginAttempt( ip[ ], password[ ], success )
{
    #if defined _foreach_included
   
        foreach (Player, i)
        {
                    new
                szIP[ 16 ]
            ;
           
            GetPVarString( i, "PVar_IP", szIP, 16 );
           
            if ( !strcmp( ip, szIP, false ) && strlen( ip ) == strlen( szIP ) )
            {
                CallLocalFunction( "OnPlayerRconLoginAttempt", "isi", i, password, success );
            }
        }
       
    #else
   
        for ( new j = GetMaxPlayers( ), i; i < j; i ++ )
        {
                    if ( !IsPlayerConnected( i ) )
                        continue;
               
                        new
                           szIP[ 16 ]
            ;

            GetPVarString( i, "PVar_IP", szIP, 16 );

            if ( !strcmp( ip, szIP, false ) && strlen( ip ) == strlen( szIP ) )
            {
                CallLocalFunction( "OnPlayerRconLoginAttempt", "isi", i, password, success );
            }

    #endif
   
    CallLocalFunction( "my_OnRconLoginAttempt", "ssi", ip, password, success );
   
    return 1;
}

#if defined _ALS_OnRconLoginAttempt
    #undef OnRconLoginAttempt
#else
    #define _ALS_OnRconLoginAttempt
#endif

#define OnRconLoginAttempt my_OnRconLoginAttempt

forward my_OnRconLoginAttempt( ip[ ], password[ ], success );

public OnPlayerRconLoginAttempt( playerid, password[ ], success )
{
    CallLocalFunction( "my_OnPlayerRconLoginAttempt", "isi", playerid, password, success );
   
    return 1;
}

#if defined _ALS_OnPlayerRconLoginAttempt
    #undef OnPlayerRconLoginAttempt
#else
    #define _ALS_OnPlayerRconLoginAttempt
#endif

#define OnPlayerRconLoginAttempt my_OnPlayerRconLoginAttempt

forward my_OnPlayerRconLoginAttempt( playerid, password[ ], success );
( Sorry for the crappy indentation, because when I copy it it happens like that. )

- It is tested?

I have tested it with

pawn Код:
#define FILTERSCRIPT

#include < a_samp >
#include < OnPlayerRconLoginAttempt >

public OnPlayerRconLoginAttempt( playerid, password[ ], success )
{
    if ( success )
    {
        printf( "%s has logged in as RCON with the password %s", getName( playerid ), password );
    }
   
    else if ( !success )
    {
        printf( "%s has failed to log in as RCON with the password %s", getName( playerid ), password );
    }
   
    return 1;
}

stock getName( playerid ) { new pName[ 24 ]; GetPlayerName( playerid, pName, sizeof pName ); return pName; }
With 2 players ( me and my brother ), it works. ( Not only for ID 0 )

- How to install ?

Simply save the script as "OnPlayerRconLoginAttempt.inc" at your "sampserv/pawno/includes", and add this
pawn Код:
#include < OnPlayerRconLoginAttempt >
AFTER a_samp.

I hope this include can be useful for some peoples.

Regards, Basicz.
Reply
#2

nice man......
9/10
Reply
#3

two words , FUCKIN AWESOME

im 100% sure im going to use this.
Reply
#4

Nice .... man is them useful 10/10
Reply
#5

Very good.
Reply
#6

I'm going to have to use it, generally when it comes to things like this (minor things for my server) I cannot be bothered. Thanks alot mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)