Tag mismatch warning with integers!! WTF
#1

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:

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;
}
I'm calling the function checkcallbackflood in the callbacks listed in the enum. For example, in OnPlayerDisconnect the code is like this:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    checkcallbackflood(playerid, cfdOnPlayerDisconnect);
    return 1;
}
And the 2 lines where I'm getting the warning are the following, both of them in the function checkcallbackflood:

pawn Код:
if( (currenttime - lastcallbacktime[playerid][callback]) < mintimebetweencallbacks )

lastcallbacktime[playerid][callback] = currenttime;
How can the compiler be giving me these warnings for INTEGERS??
Reply
#2

Wich warning?
Reply
#3

remove the stock from this line

pawn Код:
new stock lastcallbacktime[MAX_PLAYERS][cfd_callbacks];
Reply
#4

Quote:
Originally Posted by cessil
Посмотреть сообщение
remove the stock from this line

pawn Код:
new stock lastcallbacktime[MAX_PLAYERS][cfd_callbacks];
Thanks for the tip but I'm still getting the warning 213: tag mismatch for the 2 lines I mentioned. I even removed the stock from the function checkcallbackflood yet nothing changes.
What happens if I just ignore those warnings and run the server with that script?
Reply
#5

Try defines instead of enums...
Reply
#6

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Try defines instead of enums...
If I do that I can compile normally, but I would like to be able to use enums as they are much more flexible than defines. For example if one day I add a new define, I will have to remember to also increase the number of cells in the array lastcallbacktime, something which is easy to forget about. With enums however, I only would have to add whichever lines I wanted and the rest would be automatic.
Reply
#7

I agree that enums are a tad more flexible but to be honest I just switched to using define's myself for another reason and it's not too cumbersome - the compiler will throw you an error if you forget and it will most likely fix your issue!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)