My first project is based on thread for flood that i see Вы должны зарегистрироваться, чтобы видеть ссылки.. I start searching for common projects and found one-two-three but all for SourceMOD. Then i go MAD and decide to try to reverse it in metamod code. But nothing happen, becouse there are functions that the plugin need but are not really there and cannot build the project. ( I think so... )
Original plugin for SM is Вы должны зарегистрироваться, чтобы видеть ссылки.
This is my code for now. Please help me to fix & run it.
- Код: Выделить всё
#include "amxxmodule.h"
#include "protect_amxx.h"
#include "netadr.h"
// ===============================================================================================================
#define fClearTrieTime 12.4
#define iConnectionBanCount 6
#define iIPLength 17
// new Handle:g_hTrie;
// ===============================================================================================================
void OnMetaAttach() { printf("\n Enter on Meta\n\n"); } // g_hTrie = CreateTrie();
void OnMetaDetach() { printf("\n Exit on Meta\n\n"); }
// ===============================================================================================================
BOOL ClientConnect(edict_t *pEntity, const char *pszAddress, char szRejectReason[128]) {
// ==================================
int iPlayer = ENTINDEX(pEntity);
char sIP[IPLEN+1], *p;
const char *playerIP = netadr_t->ip[IPLEN+1]
// ==================================
if (IsFakeClient(client)) {
return true; // Why would we want to even check these clients?
}
decl String:sIP[iIPLength];
if (!GetClientIP(client, sIP, sizeof(sIP))) {
return true; // We don't want to reject them if we can't get their IP... Although this should never happen.
}
// ==================================
if (!GetTrieValue(g_hTrie, sIP, iConnectionCount))
{
new Handle:hPack = INVALID_HANDLE;
CreateDataTimer(fClearTrieTime, ClearValueFromTrie, hPack, TIMER_DATA_HNDL_CLOSE);
WritePackString(hPack, sIP);
ResetPack(hPack);
SetTrieValue(g_hTrie, sIP, 0);
return true; // We don't want to call the below code if this trap works.
}
if (iConnectionCount == iConnectionBanCount)
{
PrintToChatAll("\x04[CFP]\x03 Banning %N (%s) for flooding connections to the server.", client, sIP);
LogToGame("[CFP] Banning %N (%s) for flooding connections to the server.", client, sIP);
strcopy(rejectmsg, maxlen, "Banned for Connection Flooding.");
BanClient(client, 0, BANFLAG_IP, "Connection Flooding.", "Banned for Connection Flooding.", "sm_connectflood_protection");
ServerCommand("sm_banip \"%s\" 0 \"Connection Flooding.\"", sIP);
return false;
}
// ==================================
SetTrieValue(g_hTrie, sIP, (iConnectionCount + 1));
RETURN_META_VALUE(MRES_IGNORED, true);
// ==================================
}
And my protect_amxx.h
- Код: Выделить всё
#ifndef _INCLUDE_PROTECT_AMXX_H
#define _INCLUDE_PROTECT_AMXX_H
// SOME CUSTOM DEFFINITIONS!
#endif //_INCLUDE_PROTECT_AMXX_H