Weapon detection
#1

Hello,

I don't how but a guy with cheats can spawn sniper rifle without getting detected by anti-cheat.

This is my anti-cheat.

pawn Код:
public OnWeaponCheck(){ // Timer is set to 1 sec to check if someone has spawned some weps.
    new string[128], Ip[16], gun_name[30], day, month, year, query[200];
    foreach(Player, i){
        if(PlayerInfo[i][pLogged] != -1){
            if(PlayerInfo[i][pSpawned] != -1){
                GetPlayerName(i, pname, sizeof(pname));
                GetPlayerIp(i, Ip, sizeof(Ip));
                if(GetPlayerWeapon(i) >= 1 && GetPlayerWeapon(i) <= 45){
                GetWeaponName(GetPlayerWeapon(i), gun_name, sizeof(gun_name));
                format(string, sizeof(string), "Admin-Log: %s has been banned for weapon hack (Wep:%s)(%s).", pname, gun_name, Ip);
                SendAdminMessage(COLOR_RED, string);
                getdate(year, month, day);
                format(string, sizeof(string), "%02d/%02d/%d", day, month, year);
                format(query, sizeof(query), "INSERT INTO `player_ban` (`name` ,`banned_by` ,`time` , `date` ,`reason` ,`ip`) VALUES ('%s', 'Steve', %i, '%s', 'WEAPON HACK: %s', '%s')", pname, gettime(), string, gun_name, Ip);
                mysql_query(query);
                SendClientMessage(i, COLOR_GREY, "You are banned from this server for 'weapon hacking'.");
                TogglePlayerControllable(i,0);
                Kick(i);
                }
            }
        }
    }
    return 1;
}
It's kind of impossible to evade from weapon detection right?

Also this thing doesn't happen only on my server...
Reply
#2

Its hard to read this?

pawn Код:
if(GetPlayerWeapon(i) >= 1 && GetPlayerWeapon(i) <= 45)
Man, then you have a problem.
Reply
#3

I have a problem reading the indention because it's all over the place is the horrible style that, for some reason unbeknown to be, people decide to use.

That code doesn't make sense anyway, it bans them if they have ANY weapon. Do you not allow weapons on your server or something?
Reply
#4

Yes i don't allow weapons on my server.

EDIT: Anti-cheat works fine but that guy can evade it only with sniper rifle and i don't know how...
Reply
#5

I don't see what the problem with this code is, but a way to stop him from using it is to use the callback OnPlayerKeyStateChange

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
    new string[128], Ip[16], gun_name[30], day, month, year, query[200];
    if((newkeys & (KEY_FIRE) == KEY_FIRE) && (oldkeys & (KEY_FIRE) != KEY_FIRE)) {
        if(GetPlayerWeapon(playerid) >= 1 && GetPlayerWeapon(playerid) <= 45) {
            GetPlayerName(playerid, pname, sizeof(pname));
            GetPlayerIp(playerid, Ip, sizeof(Ip));
            GetWeaponName(GetPlayerWeapon(playerid), gun_name, sizeof(gun_name));
            format(string, sizeof(string), "Admin-Log: %s has been banned for weapon hack (Wep:%s)(%s).", pname, gun_name, Ip);
            SendAdminMessage(COLOR_RED, string);
            getdate(year, month, day);
            format(string, sizeof(string), "%02d/%02d/%d", day, month, year);
            format(query, sizeof(query), "INSERT INTO `player_ban` (`name` ,`banned_by` ,`time` , `date` ,`reason` ,`ip`) VALUES ('%s', 'Steve', %i, '%s', 'WEAPON HACK: %s', '%s')", pname, gettime(), string, gun_name, Ip);
            mysql_query(query);
            SendClientMessage(i, COLOR_GREY, "You are banned from this server for 'weapon hacking'.");
            TogglePlayerControllable(playerid,0);
            Kick(playerid);
        }
    }
}
Reply
#6

I'll give a shoot, thanks.
Reply
#7

pawn Код:
public OnPlayerUpdate(playerid)
{
    SetPlayerArmedWeapon(playerid, 0);
    return 1;
}
Done.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)