AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Heres a challenge _special (https://forums.alliedmods.net/showthread.php?t=184057)

vamppa 04-30-2012 10:44

Heres a challenge _special
 
Heres a challenge
how to create a anti _special plugin using only amxmodx core module?
Code:

#include <amxmodx>
#include <amxmisc>
...etc


an example that in addition uses fakemeta.
important is, it doesn't need to do the same, as long as it is anti _special. (loop command used in scripts)
Code:

#include <amxmodx>
#include <fakemeta>

enum
{
        TYPE_JUMP,
        TYPE_DUCK,
       
        g_iMaxTypes
};

enum
{
        LOOP_SPECIAL,
       
        g_iMaxLoops
};

new g_iDetected[33][g_iMaxTypes];

const g_iCmdChars = 20;

new const g_sPunishments[][] =
{
        "slay",
        "kick",
};
new const g_iScriptKeys[g_iMaxTypes] =
{
        IN_JUMP,
        IN_DUCK
};
new const g_sScriptTypes[g_iMaxTypes][] =
{
        "Bhop",
        "Gstrafe"
};
new const g_sLoopTypes[g_iMaxLoops][] =
{
        "special"
};
new const g_sLoopCodes[g_iMaxLoops][] =
{
        "_special"
};
new const g_sLetters[26][] =
{
        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" ,"l", "m",
        "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
};

new gbsd_on[g_iMaxTypes];
new gbsd_punishment[g_iMaxTypes];
new gbsd_bantime[g_iMaxTypes];
new gbsd_bantype;

new g_iMsgSayText;
new g_iMaxPlayers;

public plugin_init()
{
        register_plugin("Anti _special", "1.2", "Exolent & Vamp");
       
        register_forward(FM_PlayerPreThink, "fwd_FM_PlayerPreThink");
       
        gbsd_on[TYPE_JUMP] =                register_cvar("gbsd_bhop_on", "1");
        gbsd_punishment[TYPE_JUMP] =        register_cvar("gbsd_bhop_punishment", "2");
        gbsd_bantime[TYPE_JUMP] =        register_cvar("gbsd_bhop_bantime", "5");
        gbsd_on[TYPE_DUCK] =                register_cvar("gbsd_gstrafe_on", "1");
        gbsd_punishment[TYPE_DUCK] =        register_cvar("gbsd_gstrafe_punishment", "2");
        gbsd_bantime[TYPE_DUCK] =        register_cvar("gbsd_gstrafe_bantime", "5");
        gbsd_bantype =                        register_cvar("gbsd_bantype", "1");
       
        g_iMaxPlayers = get_maxplayers();
        g_iMsgSayText = get_user_msgid("SayText");
}
public fwd_FM_PlayerPreThink(id)
{
        if(!is_user_alive(id))
        {
                return FMRES_IGNORED;
        }
       
        static iOn[g_iMaxTypes];
        iOn[TYPE_JUMP] = get_pcvar_num(gbsd_on[TYPE_JUMP]);
        iOn[TYPE_DUCK] = get_pcvar_num(gbsd_on[TYPE_DUCK]);
        if(!iOn[TYPE_JUMP] && !iOn[TYPE_DUCK])
        {
                return FMRES_IGNORED;
        }
       
        static iButton[33], iOldButtons[33];
        iButton[id] = pev(id, pev_button);
        iOldButtons[id] = pev(id, pev_oldbuttons);
       
        static sCommand[g_iMaxLoops][g_iCmdChars + 6];
        static sArgument[g_iMaxLoops][g_iCmdChars + 6];
        static const iLen = sizeof(sCommand[]) - 1;
        static i, j, k;
       
        for(i = 0; i < g_iMaxTypes; i++)
        {
                if(iOn[i] && (iButton[id] & g_iScriptKeys[i]) && !(iOldButtons[id] & g_iScriptKeys[i]))
                {
                        for(j = 0; j < g_iMaxLoops; j++)
                        {
                                formatex(sCommand[j], iLen, "gbsd_%c", g_sScriptTypes[i][0]);
                                formatex(sArgument[j], iLen, "gbsd_%c", g_sLoopTypes[j][0]);
                                for(k = strlen(sCommand[j]); k < g_iCmdChars; k++)
                                {
                                        add(sCommand[j], iLen, g_sLetters[random(26)]);
                                        add(sArgument[j], iLen, g_sLetters[random(26)]);
                                }
                                client_cmd(id, ";alias ^"%s^" ^"%s %s^"", g_sLoopCodes[j], sCommand[j], sArgument[j]);
                        }
                        return FMRES_IGNORED;
                }
        }
        return FMRES_IGNORED;
}

public client_command(id)
{
        if(!is_user_alive(id) || is_on_ground(id))
        {
                return PLUGIN_CONTINUE;
        }
       
        static sCommand[16];
        static const iCmdLen = sizeof(sCommand) - 1;
        read_argv(0, sCommand, iCmdLen);
       
        static i;
       
        static sArg[8];
        static const iArgLen = sizeof(sArg) - 1;
        read_argv(1, sArg, iArgLen);
       
        static j;
        if(equali(sCommand, "gbsd_", 5))
        {
                for(i = 0; i < g_iMaxTypes; i++)
                {
                        if(g_sScriptTypes[i][0] == sCommand[5])
                        {
                                if(equali(sArg, "gbsd_", 5))
                                {
                                        for(j = 0; j < g_iMaxLoops; j++)
                                        {
                                                if(g_sLoopTypes[j][0] == sArg[5])
                                                {
                                                        handle_punishment(id, i, j);
                                                        return PLUGIN_HANDLED;
                                                }
                                        }
                                }
                        }
                }
        }
        return PLUGIN_CONTINUE;
}

stock handle_punishment(id, iScriptType, iLoopType)
{
        if(iLoopType != LOOP_SPECIAL && ++g_iDetected[id][iScriptType] < 3)
        {
                gbsd_print(id, "Ehll - Do not use cl_%sbuy on this server!", iLoopType == LOOP_AUTOBUY ? "auto" : "re");
                console_print(id, "Ehll - Do not use cl_%sbuy on this server!", iLoopType == LOOP_AUTOBUY ? "auto" : "re");
                return;
        }
       
        static sName[32];
        get_user_name(id, sName, sizeof(sName) - 1);
       
        static iPunishment;
        iPunishment = get_pcvar_num(gbsd_punishment[iScriptType]);
       
        if(1 <= iPunishment <= 3)
        {
                gbsd_print(0, "Ehll - %s was %sed for using a _special Script.",\
                        sName, g_sPunishments[iPunishment]);
        }
       
        switch(iPunishment)
        {
                case 1:
                {
                        user_kill(id);
                }
                case 2:
                {
                        server_cmd("kick #%d ^"%s Script Detected (Loop:%s)^"", get_user_userid(id), g_sScriptTypes[iScriptType], g_sLoopTypes[iLoopType]);
                }
                case 3:
                {
                        static iBanType;
                        iBanType = get_pcvar_num(gbsd_bantype);
                       
                        static sInfo[64];
                        if(iBanType == 1)
                        {
                                get_user_authid(id, sInfo, sizeof(sInfo) - 1);
                        }
                        else
                        {
                                get_user_ip(id, sInfo, sizeof(sInfo) - 1, 1);
                                if(iBanType != 2)
                                {
                                        set_pcvar_num(gbsd_bantype, 2);
                                }
                        }
                        server_cmd("kick #%d ^"%s Script Detected (Loop:%s)^"; wait; %s %d ^"%s^"; wait; writei%c",\
                                get_user_userid(id), g_sScriptTypes[iScriptType], g_sLoopTypes[iLoopType], get_pcvar_num(gbsd_bantime[iScriptType]), iBanType == 1 ? "banid" : "addip", sInfo, iBanType == 1 ? 'd' : 'p');
                }
                default:
                {
                        if(iPunishment != 0)
                        {
                                set_pcvar_num(gbsd_punishment[iScriptType], 0);
                        }
                       
                        gbsd_print(0, "Ehll - %s is using a _special Script.",\
                                sName);
                }
        }
}

stock bool:is_on_ground(index)
{
        static iFlags;
        iFlags = pev(index, pev_flags);
        return ((iFlags & FL_ONGROUND) || (iFlags & FL_PARTIALGROUND) || (iFlags & FL_CONVEYOR) || (iFlags & FL_INWATER) || (iFlags & FL_FLOAT));
}


hleV 04-30-2012 10:46

Re: Heres a challenge _special
 
What's the purpose?

vamppa 04-30-2012 12:19

Re: Heres a challenge _special
 
to stop clients from using some nasty loops with _special.
can be used to crash and flood the server or for you movemental advantages.

Exolent[jNr] 04-30-2012 12:32

Re: Heres a challenge _special
 
What's wrong with using fakemeta?

vamppa 05-03-2012 12:53

Re: Heres a challenge _special
 
well basically im working on a project for a community.
one of the optimization rules ive set is to only use amxmodx core module.
if nothing would be possible otherwise this protection wont be added. (no fun,fakemeta,hamsandwhich,engine)

Exolent[jNr] 05-03-2012 12:54

Re: Heres a challenge _special
 
You're not going to be able to make much, then.

vamppa 05-03-2012 13:19

Re: Heres a challenge _special
 
yeah figured
im pretty newbie at pawn scripting and programming in general.
was hoping any of you guru's might know a way, thx for replying :)


All times are GMT -4. The time now is 07:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.