Quote:
Originally Posted by Pedro_Miranda
Nгo testei meu cуdigo, mas teste-o.
pawn Код:
#include <a_samp> CountPlayersWithIP(ip[]) { new count, player_ip[16]; for(new i; i != GetMaxPlayers(); ++i) { if(IsPlayerConnected(i)) { GetPlayerIp(i, player_ip, sizeof player_ip); count += (!strcmp(player_ip, ip, true)) ? 1 : 0; } } return count; }
public OnPlayerConnect(playerid) { new count_ip, player_ip[16]; GetPlayerIp(playerid, player_ip, sizeof player_ip); count_ip = CountPlayersWithIP(player_ip); if(count_ip > 2) { return Ban(playerid); } return 1; }
|
count += (!strcmp(player_ip, ip, true)) ? 1 : 0;
??
count += (!strcmp(player_ip, ip, true);
strcmp retorna a 1 ou a 0 jб.
if(count_ip > 2)
{
return Ban(playerid);
}
return 1;
gosta de usar ? : ( ?? )
return ( count_ip > 2 ? Ban(playerid) : 1 );