Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_CONNECT_IN_ROW 3
- #define MAX_REJOIN_TIME 4000
- enum IPConnectData
- {
- ip[25],
- lastConnectTime,
- connectTimes
- }
- new Connects[MAX_PLAYERS][IPConnectData];
- public OnPlayerConnect(playerid)
- {
- new pIP[25];
- new bool:ipFound = false;
- GetPlayerIp(playerid, pIP, 25);
- for (new i; i < MAX_PLAYERS; i++)
- {
- if(!strcmp(Connects[i][ip], pIP, false))
- {
- if (GetTickCount() - Connects[i][lastConnectTime] < MAX_REJOIN_TIME)
- {
- Connects[i][lastConnectTime] = GetTickCount();
- Connects[i][connectTimes]++;
- if (Connects[i][connectTimes] > MAX_CONNECT_IN_ROW)
- {
- new str[100];
- format(str, 100, "banip %s", pIP);
- SendRconCommand(str);
- Kick(playerid);
- return 1;
- }
- }
- else
- {
- Connects[i][lastConnectTime] = GetTickCount();
- Connects[i][connectTimes] = 1;
- }
- ipFound = true;
- break;
- }
- }
- if (!ipFound)
- {
- for (new i; i < MAX_PLAYERS; i++)
- {
- if (GetTickCount() - Connects[i][lastConnectTime] > MAX_REJOIN_TIME)
- {
- format(Connects[i][ip], 25, "%s", pIP);
- Connects[i][lastConnectTime] = GetTickCount();
- Connects[i][connectTimes] = 1;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement