22.10.2013, 01:36
Hello, I have noticed that some hackers try to attack my server by flooding some callbacks, like for example connecting and disconnecting from the server many times per second, switching between spawning and entering class selection screen, etc. I have already blocked those callback floods that I have detected, but I want to know if there are other callbacks they might be flooding without me having noticed it yet. For that reason, I'm trying to script a callback flood detector that tells me whenever a callback is flooded, and actually I have been able to compile it, but I'm getting warnings for tag mismatch that I shouldn't, as the variables I'm working with are integers. Here's the most relevant part of the code:
I'm calling the function checkcallbackflood in the callbacks listed in the enum. For example, in OnPlayerDisconnect the code is like this:
And the 2 lines where I'm getting the warning are the following, both of them in the function checkcallbackflood:
How can the compiler be giving me these warnings for INTEGERS??
pawn Код:
#define mintimebetweencallbacks 500 // In miliseconds.
enum cfd_callbacks
{
cfdOnDialogResponse,
cfdOnEnterExitModShop,
cfdOnPlayerClickMap,
cfdOnPlayerClickPlayer,
cfdOnPlayerClickPlayerTextDraw,
cfdOnPlayerClickTextDraw,
cfdOnPlayerDisconnect,
cfdOnPlayerEditAttachedObject,
cfdOnPlayerEditObject,
cfdOnPlayerEnterCheckpoint,
cfdOnPlayerEnterRaceCheckpoint,
cfdOnPlayerEnterVehicle,
cfdOnPlayerExitVehicle,
cfdOnPlayerExitedMenu,
cfdOnPlayerInteriorChange,
cfdOnPlayerLeaveCheckpoint,
cfdOnPlayerLeaveRaceCheckpoint,
cfdOnPlayerObjectMoved,
cfdOnPlayerPickUpPickup,
cfdOnPlayerRequestClass,
cfdOnPlayerRequestSpawn,
cfdOnPlayerSelectObject,
cfdOnPlayerSelectedMenuRow,
cfdOnPlayerStateChange,
cfdOnVehicleRespray,
};
new stock lastcallbacktime[MAX_PLAYERS][cfd_callbacks];
stock checkcallbackflood(playerid, callback)
{
new currenttime;
currenttime = GetTickCount();
if( (currenttime - lastcallbacktime[playerid][callback]) < mintimebetweencallbacks )
{
// The callback is being flooded. Here is some code that has nothing to do with the warnings...
}
lastcallbacktime[playerid][callback] = currenttime;
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
checkcallbackflood(playerid, cfdOnPlayerDisconnect);
return 1;
}
pawn Код:
if( (currenttime - lastcallbacktime[playerid][callback]) < mintimebetweencallbacks )
lastcallbacktime[playerid][callback] = currenttime;
