Anti-cheat didn't work
#1

I have this anti-cheat and when i try to hack a wep i always get banned but today i saw a guy spawning weps killing around and he didnt get banned.
How should i get them easily.
PHP код:
public OnGameModeInit()
{
    
SetTimer("WeaponCheck",2000,1);
    return 
1;
}
public 
WeaponCheck()
{
    new 
playeridIP[16];
     if( 
PlayerInfo[playerid][pAdmin] >=) return 0;
     if( 
WeaponGiven[playerid] == ) return 0;
     if( 
Logged[playerid] == )
     {
        new 
weaponid GetPlayerWeaponplayerid );
        if( ( 
weaponid >= && weaponid <=45 ) )
        {
            
GetPlayerNameplayeridNamsizeof Nam );
            
GetPlayerIpplayeridIP16 );
            
formatmystringsizeof mystring"Admin-Log: %s has been banned for weapon hack(%s)."NamIP);
            
SendAdminMessageCOLOR_REDmystring );
            
BanEx(playerid"WEAPON HACK");
        }
    }
    return 
1;

Reply
#2

that won't work unless you are ID 0
You need a loop to check through all players..

try this:
pawn Код:
public WeaponCheck()
{
    new IP[16];
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        if(!IsPlayerConnected(playerid)) return 0;
        if( PlayerInfo[playerid][pAdmin] >=1 ) return 0;
        if( WeaponGiven[playerid] == 1 ) return 0;
        if( Logged[playerid] == 1 )
        {
           new weaponid = GetPlayerWeapon( playerid );
           if( ( weaponid >= 1 && weaponid <=45 ) )
           {
               GetPlayerName( playerid, Nam, sizeof Nam );
               GetPlayerIp( playerid, IP, 16 );
               format( mystring, sizeof mystring, "Admin-Log: %s has been banned for weapon hack(%s).", Nam, IP);
               SendAdminMessage( COLOR_RED, mystring );
               BanEx(playerid, "WEAPON HACK");
           }
       }
    }
    return 1;
}
Reply
#3

pawn Код:
public WeaponCheck()
{
   
    new IP[16];
    for(new i = 0 ; i <= MAX_PLAYERS ; i++ )
    if( PlayerInfo[i][pAdmin] >=1 ) return 0;
     if( WeaponGiven[i] == 1 ) return 0;
     if( Logged[i] == 1 )
     {
        new weaponid = GetPlayerWeapon( i );
        if( ( weaponid >= 1 && weaponid <=45 ) )
        {
            GetPlayerName( i, Nam, sizeof Nam );
            GetPlayerIp( i, IP, 16 );
            format( mystring, sizeof mystring, "Admin-Log: %s has been banned for weapon hack(%s).", Nam, IP);
            SendAdminMessage( COLOR_RED, mystring );
            BanEx(i, "WEAPON HACK");
        }
    }
    return 1;
}

EDIT: lol just same @above
Reply
#4

From Sascha works but still for id 0, and from Michael doesn't work...
Reply
#5

Use OnPlayerUpdate to check for hacks. It's better IMO than using a timer to loop through all the player's.
Reply
#6

I don't want to use OnPlayerUpdate.
Reply
#7

pawn Код:
public WeaponCheck()
{
    new
        IP[16]
    ;
   
    for ( new i = 0; i < MAX_PLAYERS; i++) { //Loop.
       
        if(PlayerInfo[i][pAdmin] >= 1) return 0;
        if(WeaponGiven[i] == 1) return 0;
        if( Logged[i] == 1 )
        {
            if(GetPlayerWeapon(i) >= 1 && GetPlayerWeapon(i) <= 45) { //Is this just to test your anti cheat? Cause this will ban for all weapons..
               
                new
                    p_Name[24],
                    mystring[128]
                ;
               
                GetPlayerName( i, p_Name, sizeof( p_Name ));
                GetPlayerIp( i, IP, 16 );
                format( mystring, sizeof mystring, "Admin-Log: %s has been banned for weapon hack(%s).", p_Name, IP);
                SendAdminMessage( COLOR_RED, mystring );
                BanEx(i, "WEAPON HACK");
            }
        }
       
    }
    return 1;
}
Try that.
Reply
#8

Replace return 0 with continue and you're set.
Reply
#9

Thanks everyone for helping me. Works perfect now.
Reply
#10

to make the public faster, use this in the loop

pawn Код:
if(!IsPlayerConnected(i)) continue;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)