Results 1 to 3 of 3

Thread: Anti aimbot

  1. #1
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Anti aimbot

    Guys, can anyone help me with anything?

    I want to do a headshot counter, to avoid aimbots on the server. As soon as the counter is greater than an X value, the server kicks the player. The value always zeroes when the round ends (sd) or when he dies (in the case of a dm)

    I don't know where to capture the death toll and validate whether it was a headshot or not.

  2. The Following User Says Thank You to caldas For This Useful Post:

    kung foo man (20th August 2020)

  3. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    426
    Thanks
    78
    Thanked 102 Times in 86 Posts
    example on default gametype scripts.

    new lines marked like suffix "//+new"

    sd.gsc
    PHP Code:
    Callback_PlayerKilled(eInflictorattackeriDamagesMeansOfDeathsWeaponvDirsHitLocpsOffsetTimedeathAnimDuration)
    {
        
    self endon("spawned");
        
    self notify("killed_player");

        if(
    self.sessionteam == "spectator")
            return;

        
    // If the player was killed by a head shot, let players know it was a head shot kill
        
    if(sHitLoc == "head" && sMeansOfDeath != "MOD_MELEE")
            
    sMeansOfDeath "MOD_HEAD_SHOT";

        if (!
    isDefined(attacker.Cheads)) //+new
            
    attacker.Cheads 0//+new
        
        
    self.Cheads 0//+new
        
        // send out an obituary message to all clients about the kill
        
    obituary(selfattackersWeaponsMeansOfDeath);

        
    self maps\mp\gametypes\_weapons::dropWeapon();
        
    self maps\mp\gametypes\_weapons::dropOffhand();

        
    self.sessionstate "dead";
        
    self.statusicon "hud_status_dead";

        if(!
    isdefined(self.switching_teams))
        {
            
    self.pers["deaths"]++;
            
    self.deaths self.pers["deaths"];
        }

        
    lpselfnum self getEntityNumber();
        
    lpselfguid self getGuid();
        
    lpselfname self.name;
        
    lpselfteam self.pers["team"];
        
    lpattackerteam "";

        
    attackerNum = -1;

        if(
    isPlayer(attacker))
        {
            if(
    attacker == self// killed himself
            
    {
                
    doKillcam false;

                
    // switching teams
                
    if(isdefined(self.switching_teams))
                {
                    if((
    self.leaving_team == "allies" && self.joining_team == "axis") || (self.leaving_team == "axis" && self.joining_team == "allies"))
                    {
                        
    players maps\mp\gametypes\_teams::CountPlayers();
                        
    players[self.leaving_team]--;
                        
    players[self.joining_team]++;

                        if((
    players[self.joining_team] - players[self.leaving_team]) > 1)
                        {
                            
    attacker.pers["score"]--;
                            
    attacker.score attacker.pers["score"];
                        }
                    }
                }

                if(
    isdefined(attacker.friendlydamage))
                    
    attacker iprintln(&"MP_FRIENDLY_FIRE_WILL_NOT");
            }
            else
            {
                
    attackerNum attacker getEntityNumber();
                
    doKillcam true;

                if(
    self.pers["team"] == attacker.pers["team"]) // killed by a friendly
                
    {
                    
    attacker.pers["score"]--;
                    
    attacker.score attacker.pers["score"];
                }
                else
                {
                    
    attacker.pers["score"]++;
                    
    attacker.score attacker.pers["score"];
                    
                    if (
    sMeansOfDeath == "MOD_HEAD_SHOT"//+new
                        
    attacker.Cheads++; //+new
                    
    attacker thread checkHeadShotNumber(); //+new
                
    }
            }

            
    lpattacknum attacker getEntityNumber();
            
    lpattackguid attacker getGuid();
            
    lpattackname attacker.name;
            
    lpattackerteam attacker.pers["team"];

            
    self notify("killed_player"attacker);
        }
        else 
    // If you weren't killed by a player, you were in the wrong place at the wrong time
        
    {
            
    doKillcam false;

            
    self.pers["score"]--;
            
    self.score self.pers["score"];

            
    lpattacknum = -1;
            
    lpattackguid "";
            
    lpattackname "";
            
    lpattackerteam "world";

            
    self notify("killed_player"self);
        }

        
    logPrint("K;" lpselfguid ";" lpselfnum ";" lpselfteam ";" lpselfname ";" lpattackguid ";" lpattacknum ";" lpattackerteam ";" lpattackname ";" sWeapon ";" iDamage ";" sMeansOfDeath ";" sHitLoc "\n");

        
    self.pers["weapon1"] = undefined;
        
    self.pers["weapon2"] = undefined;
        
    self.pers["spawnweapon"] = undefined;

        if(
    isdefined(self.bombtimer))
            
    self.bombtimer destroy();

        if(!
    isdefined(self.switching_teams))
        {
            
    body self cloneplayer(deathAnimDuration);
            
    thread maps\mp\gametypes\_deathicons::addDeathicon(bodyself.clientidself.pers["team"], 5);
        }
        
    self.switching_teams undefined;
        
    self.joining_team undefined;
        
    self.leaving_team undefined;

        
    level updateTeamStatus();

        if(!
    level.exist[self.pers["team"]]) // If the last player on a team was just killed, don't do killcam
        
    {
            
    doKillcam false;
            
    self.skip_setspectatepermissions true;

            if(
    level.bombplanted && level.planting_team == self.pers["team"])
            {
                
    players getentarray("player""classname");
                for(
    0players.sizei++)
                {
                    
    player players[i];

                    if(
    player.pers["team"] == self.pers["team"])
                    {
                        
    player allowSpectateTeam("allies"true);
                        
    player allowSpectateTeam("axis"true);
                        
    player allowSpectateTeam("freelook"true);
                        
    player allowSpectateTeam("none"false);
                    }
                }
            }
        }

        
    delay 2;    // Delay the player becoming a spectator till after he's done dying
        
    wait delay;    // ?? Also required for Callback_PlayerKilled to complete before killcam can execute

        
    if(doKillcam && level.killcam && !level.roundended)
            
    self maps\mp\gametypes\_killcam::killcam(attackerNumdelaypsOffsetTime);

        
    currentorigin self.origin;
        
    currentangles self.angles;
        
    self thread spawnSpectator(currentorigin + (0060), currentangles);

    dm.gsc
    PHP Code:
    Callback_PlayerKilled(eInflictorattackeriDamagesMeansOfDeathsWeaponvDirsHitLocpsOffsetTimedeathAnimDuration)
    {
        
    self endon("spawned");
        
    self notify("killed_player");

        if(
    self.sessionteam == "spectator")
            return;

        
    // If the player was killed by a head shot, let players know it was a head shot kill
        
    if(sHitLoc == "head" && sMeansOfDeath != "MOD_MELEE")
            
    sMeansOfDeath "MOD_HEAD_SHOT";
        
        if (!
    isDefined(attacker.Cheads)) //+new
            
    attacker.Cheads 0//+new
        
        
    self.Cheads 0//+new

        // send out an obituary message to all clients about the kill
        
    obituary(selfattackersWeaponsMeansOfDeath);

        
    self maps\mp\gametypes\_weapons::dropWeapon();
        
    self maps\mp\gametypes\_weapons::dropOffhand();

        
    self.sessionstate "dead";
        
    self.statusicon "hud_status_dead";

        if(!
    isdefined(self.switching_teams))
            
    self.deaths++;

        
    lpselfnum self getEntityNumber();
        
    lpselfname self.name;
        
    lpselfteam "";
        
    lpselfguid self getGuid();
        
    lpattackerteam "";

        
    attackerNum = -1;
        if(
    isPlayer(attacker))
        {
            if(
    attacker == self// killed himself
            
    {
                
    doKillcam false;

                if(!
    isdefined(self.switching_teams))
                    
    attacker.score--;
            }
            else
            {
                
    attackerNum attacker getEntityNumber();
                
    doKillcam true;

                
    attacker.score++;
                
    attacker checkScoreLimit();
                
                if (
    sMeansOfDeath == "MOD_HEAD_SHOT"//+new
                    
    attacker.Cheads++; //+new
                
    attacker thread checkHeadShotNumber(); //+new
            
    }

            
    lpattacknum attacker getEntityNumber();
            
    lpattackguid attacker getGuid();
            
    lpattackname attacker.name;

            
    attacker notify("update_playerscore_hud");
        }
        else 
    // If you weren't killed by a player, you were in the wrong place at the wrong time
        
    {
            
    doKillcam false;

            
    self.score--;

            
    lpattacknum = -1;
            
    lpattackguid "";
            
    lpattackname "";

            
    self notify("update_playerscore_hud");
        }

        
    logPrint("K;" lpselfguid ";" lpselfnum ";" lpselfteam ";" lpselfname ";" lpattackguid ";" lpattacknum ";" lpattackerteam ";" lpattackname ";" sWeapon ";" iDamage ";" sMeansOfDeath ";" sHitLoc "\n");

        
    // Stop thread if map ended on this death
        
    if(level.mapended)
            return;

        
    self.switching_teams undefined;
        
    self.joining_team undefined;
        
    self.leaving_team undefined;

        
    body self cloneplayer(deathAnimDuration);
        
    thread maps\mp\gametypes\_deathicons::addDeathicon(bodyself.clientidself.pers["team"]);

        
    delay 2;    // Delay the player becoming a spectator till after he's done dying
        
    wait delay;    // ?? Also required for Callback_PlayerKilled to complete before respawn/killcam can execute

        
    if(doKillcam && level.killcam)
            
    self maps\mp\gametypes\_killcam::killcam(attackerNumdelaypsOffsetTimetrue);

        
    self thread respawn();

    add in both scripts
    PHP Code:
    checkHeadShotNumber()
    {
        if (!
    isDefined(self.Cheads)) //?
            
    return;
            
        
    /* CFG */
        
    HS_LIMIT 10//value for kick    
        /* ... */

        
    if (self.Cheads HS_LIMIT)
        {
            
    /* 
            do some
            */
            
    kick(self getEntityNumber());
        }

    p.s: such a system is not very reliable for finding violators, but in general, the script above does what you want
    Last edited by maxdamage99; 20th August 2020 at 06:31.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  4. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (20th August 2020)

  5. #3
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Thank you very much maxdamage99 and serthy, needed a lot.

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •