[Include] OPRL.inc - OnPlayerRconLogin : Calls out when a player logs in as RCON, not an IP.
#5

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
It may work, however not very well. What if there are members with same IP address who have already RCON logged in?

EDIT:
I've tested your code right now to confirm well and yes I was right. It don't work well in case if there's already admins logged in as RCON with same IP address.
Код:
[22:57:45] [join] yolo has joined the server (...)
[22:57:55] RCON (In-Game): Player #1 (yolo) has logged in.
[22:57:56] OnPlayerRconLogin -> playerid (1) has been RCON logged in!
[22:58:09] RCON (In-Game): Player #0 (blabla) has logged in.
[22:58:10] OnPlayerRconLogin -> playerid (0) has been RCON logged in!
[22:58:10] OnPlayerRconLogin -> playerid (1) has been RCON logged in!
Good thought! The use of the array is needed then but the repeated timer is a bit bad idea. OnRconLoginAttempt is called and if it's success, after 1 second it sends the message in the console that the player has been logged in as RCON.

Here's a better version:
pawn Код:
#include <a_samp>
#include <foreach>

static
    bool: Player_Rcon[MAX_PLAYERS char];

main() {}

public OnPlayerConnect(playerid)
{
    Player_Rcon{playerid} = false;
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    if (success) SetTimerEx("RetrieveRconPlayer", 1000, false, "s", ip);
    return 1;
}

forward OnPlayerRconLogin(playerid);
public OnPlayerRconLogin(playerid)
{
    printf("OnPlayerRconLogin -> playerid (%i) has been RCON logged in!", playerid);
    return 1;
}

forward RetrieveRconPlayer(ip[]);
public RetrieveRconPlayer(ip[])
{
    new
        ip2[16];

    foreach(new i : Player)
    {
        GetPlayerIp(i, ip2, 16);
        if (!strcmp(ip, ip2) && !Player_Rcon{i} && IsPlayerAdmin(i))
        {
            Player_Rcon{i} = true;
            CallRemoteFunction("OnPlayerRconLogin", "i", i);
        }
    }
    return 1;
}
Can you test it like before with a player already logged in with the same ip? It should work now.

By the way, good idea for an include!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)