Anticheat - structuring
#11

Quote:
Originally Posted by Y_Less
View Post
Anyway, I would still recommend using y_master - I used to do what you're doing here and developed that to prevent duplication (because I got royally frustrated with writing everything twice):

pawn Code:
#if defined AC_SLAVE
    AC_STOCK AC_GetPlayerMoney(playerid) {
        return CallRemoteFunction(#AC_GetPlayerMoney, "i", playerid);
    }
    #if defined _ALS_GetPlayerMoney
        #undef GetPlayerMoney
    #else
        #define _ALS_GetPlayerMoney
    #endif
    #define GetPlayerMoney AC_GetPlayerMoney
#else
    AC_PUBLIC AC_GetPlayerMoney(playerid) {
        if (IsPlayerConnected(playerid)) {
            new bad_money = U_GetPlayerMoney(playerid);
            return bad_money < AC_players[playerid][AC_pMoney] ? bad_money : AC_players[playerid][AC_pMoney];
        }
        return 0;
    }
    #if defined _ALS_GetPlayerMoney
        #undef GetPlayerMoney
    #else
        #define _ALS_GetPlayerMoney
    #endif
    #define GetPlayerMoney AC_GetPlayerMoney
#endif
Including y_master means I have to include whole YSI and that's not something I'd really like to do (increases the size of the project much more than needed). Writing code in that way I realised I can do it like this (which looks a little better):

pawn Code:
#if defined AC_SLAVE
    AC_STOCK AC_GetPlayerMoney(playerid) {
        return CallRemoteFunction(#AC_GetPlayerMoney, "i", playerid);
    }
#else
    AC_PUBLIC AC_GetPlayerMoney(playerid) {
        if (IsPlayerConnected(playerid)) {
            new bad_money = U_GetPlayerMoney(playerid);
            return bad_money < AC_players[playerid][AC_pMoney] ? bad_money : AC_players[playerid][AC_pMoney];
        }
        return 0;
    }
#endif
#if defined _ALS_GetPlayerMoney
    #undef GetPlayerMoney
#else
    #define _ALS_GetPlayerMoney
#endif
#define GetPlayerMoney AC_GetPlayerMoney
Quote:
Originally Posted by Y_Less
View Post
Also, I don't tend to rely on using the "FILTERSCRIPT" macro as people are rubbish at using it:

pawn Code:
new bool:AC_FILTERSCRIPT = false;

public OnFilterScriptInit()
{
    AC_FILTERSCRIPT = true;
    AC_OnScriptInit();
}

public OnGameModeInit()
{
    if (!AC_FILTERSCRIPT) AC_OnScriptInit();
}
Whoever uses it must declare AC_MASTER or AC_SLAVE since now. This way I'm sure everything is fine and they aren't confused by master and slave scripts.
Reply


Messages In This Thread
Anticheat - structuring - by Dan.. - 25.04.2013, 18:32
Re: Anticheat - structuring - by MP2 - 25.04.2013, 19:03
Re: Anticheat - structuring - by KiNG3 - 25.04.2013, 19:24
Re: Anticheat - structuring - by cessil - 25.04.2013, 19:25
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:09
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:19
Re: Anticheat - structuring - by cessil - 26.04.2013, 12:40
Re: Anticheat - structuring - by Dan.. - 26.04.2013, 12:53
Re: Anticheat - structuring - by Dan.. - 30.04.2013, 19:58
Re: Anticheat - structuring - by Y_Less - 30.04.2013, 20:34
Re: Anticheat - structuring - by Dan.. - 01.05.2013, 14:31
Re: Anticheat - structuring - by Y_Less - 01.05.2013, 15:03
Re: Anticheat - structuring - by Dan.. - 01.05.2013, 19:43
Re: Anticheat - structuring - by Y_Less - 01.05.2013, 20:44
Re: Anticheat - structuring - by Dan.. - 02.05.2013, 05:28
Re: Anticheat - structuring - by Edvin - 10.05.2013, 18:19
Re: Anticheat - structuring - by Lordzy - 10.05.2013, 18:21
Re: Anticheat - structuring - by Edvin - 10.05.2013, 18:24
Re: Anticheat - structuring - by Gigi-The-Beast - 10.05.2013, 18:53
Re: Anticheat - structuring - by Yiin - 10.05.2013, 18:56
Re: Anticheat - structuring - by Gigi-The-Beast - 10.05.2013, 19:26
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 02:13
Re: Anticheat - structuring - by Dan.. - 12.05.2013, 19:04
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 19:09
Re: Anticheat - structuring - by Gigi-The-Beast - 12.05.2013, 19:56
Re: Anticheat - structuring - by Y_Less - 12.05.2013, 20:10

Forum Jump:


Users browsing this thread: 11 Guest(s)