01.02.2014, 16:23
Quote:
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! |
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;
}
By the way, good idea for an include!