Anti-Weapon Spawning
#1

Hi

Can someone please help me with this problem I am having. The weapons on my server are saving and loading, but now trying to see if players are spawning weapons by comparing the weapons in each slot against the ones on the server side. For some reason if I spawn myself a weapon it doesn't warn me that I have spawned a weapon. It does however ban me if I am using a minigun, just doesnt warn admins about weapon spawning
Please can someone help.

Code:
Код:
forward WepCheck();
public WepCheck()
{
	new weapons[13][2], count, cheat, str[128];
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		count = 0;
		cheat = 0;
		if(GetPlayerWeapon(i) == 38)
		{
			if(IsPlayerConnected(i))
			{
				new reason[56], string[235], Query[500], pIpAddress[15];
				format(reason, sizeof(reason), "Minigun");
				format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
				SendClientMessageToAll(COLOR_RED, string);
				GetPlayerIp(i, pIpAddress, sizeof(pIpAddress));
				strcat(Query,"INSERT INTO `bans`(`Name`,`Reason`,`BannedBy`,`IpAddress`,`Status`)");
				strcat(Query," VALUES ('%s', '%s', 'Anti-Hack', '%s', '%s', 1)");
				mysql_format(dbHandle, Query, sizeof(Query), Query, GetName(i), reason, pIpAddress);
				mysql_query(dbHandle, Query, false);
				Kick(i);
				format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
				Log("/logs/bans.txt", string);
			}
		}
		GetPlayerWeaponData(i, 0, weapons[0][0], weapons[0][1]);
		GetPlayerWeaponData(i, 0, weapons[1][0], weapons[1][1]);
		GetPlayerWeaponData(i, 0, weapons[2][0], weapons[2][1]);
		GetPlayerWeaponData(i, 0, weapons[3][0], weapons[3][1]);
		GetPlayerWeaponData(i, 0, weapons[4][0], weapons[4][1]);
		GetPlayerWeaponData(i, 0, weapons[5][0], weapons[5][1]);
		GetPlayerWeaponData(i, 0, weapons[6][0], weapons[6][1]);
		GetPlayerWeaponData(i, 0, weapons[7][0], weapons[7][1]);
		GetPlayerWeaponData(i, 0, weapons[8][0], weapons[8][1]);
		GetPlayerWeaponData(i, 0, weapons[9][0], weapons[9][1]);
		GetPlayerWeaponData(i, 0, weapons[10][0], weapons[10][1]);
		GetPlayerWeaponData(i, 0, weapons[11][0], weapons[11][1]);
		
		for(new c = 0; c <= 12; c++)
		{
			if(weapons[c][0] != gInfo[i][pGuns][c])
			{
				cheat++;
				printf("weapon slot: %i", c);
			}
			count = c;
		} 
		if(cheat >= 1)
		{
			format(str, sizeof(str), "%s [ID: %i] may possibly be weapon spawning", GetName(i), i);
			SendClientMessageToAdmins(COLOR_YELLOW, str, 1);
		}
	}
	return 1;
}
Reply
#2

Add a check to see if the player is not an admin. When i design things like this, I completely exclude admins from the anticheat ban procedure, instead I log what they do, but in your case, you're checking for weapons, so i wouldn't log admins spawning weapons.
Reply
#3

Yeah, every other anti -cheat is logged. But need to get this anti-weapon hack working, and cant see why its not working
Reply
#4

pawn Код:
if(GetPlayerWeapon(i) == 38)
        {
            if(IsPlayerConnected(i))
            {
                            if(!IsPlayerAdmin(i))
                            {
                new reason[56], string[235], Query[500], pIpAddress[15];
                format(reason, sizeof(reason), "Minigun");
                format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
                SendClientMessageToAll(COLOR_RED, string);
                GetPlayerIp(i, pIpAddress, sizeof(pIpAddress));
                strcat(Query,"INSERT INTO `bans`(`Name`,`Reason`,`BannedBy`,`IpAddress`,`Status`)");
                strcat(Query," VALUES ('%s', '%s', 'Anti-Hack', '%s', '%s', 1)");
                mysql_format(dbHandle, Query, sizeof(Query), Query, GetName(i), reason, pIpAddress);
                mysql_query(dbHandle, Query, false);
                Kick(i);
                format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
                Log("/logs/bans.txt", string);
            }
        }
         }
replace the IsPlayerAdmin with your admin variable.
the indentation is off as I just edited it inside of the box.
Reply
#5

That partworks perfectly fine though. I need this section to work:
Код:
		GetPlayerWeaponData(i, 0, weapons[0][0], weapons[0][1]);
		GetPlayerWeaponData(i, 0, weapons[1][0], weapons[1][1]);
		GetPlayerWeaponData(i, 0, weapons[2][0], weapons[2][1]);
		GetPlayerWeaponData(i, 0, weapons[3][0], weapons[3][1]);
		GetPlayerWeaponData(i, 0, weapons[4][0], weapons[4][1]);
		GetPlayerWeaponData(i, 0, weapons[5][0], weapons[5][1]);
		GetPlayerWeaponData(i, 0, weapons[6][0], weapons[6][1]);
		GetPlayerWeaponData(i, 0, weapons[7][0], weapons[7][1]);
		GetPlayerWeaponData(i, 0, weapons[8][0], weapons[8][1]);
		GetPlayerWeaponData(i, 0, weapons[9][0], weapons[9][1]);
		GetPlayerWeaponData(i, 0, weapons[10][0], weapons[10][1]);
		GetPlayerWeaponData(i, 0, weapons[11][0], weapons[11][1]);
		
		for(new c = 0; c <= 12; c++)
		{
			if(weapons[c][0] != gInfo[i][pGuns][c])
			{
				cheat++;
				printf("weapon slot: %i", c);
			}
			count = c;
		} 
		if(cheat >= 1)
		{
			format(str, sizeof(str), "%s [ID: %i] may possibly be weapon spawning", GetName(i), i);
			SendClientMessageToAdmins(COLOR_YELLOW, str, 1);
		}
Reply
#6

use this
pawn Код:
forward WepCheck();
public WepCheck()
{
    new weapons[13][2], count, cheat, str[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
                if(!IsPlayerConnected(playerid))continue;
        count = 0;
        cheat = 0;
       
        GetPlayerWeaponData(i, 0, weapons[0][0], weapons[0][1]);
        GetPlayerWeaponData(i, 0, weapons[1][0], weapons[1][1]);
        GetPlayerWeaponData(i, 0, weapons[2][0], weapons[2][1]);
        GetPlayerWeaponData(i, 0, weapons[3][0], weapons[3][1]);
        GetPlayerWeaponData(i, 0, weapons[4][0], weapons[4][1]);
        GetPlayerWeaponData(i, 0, weapons[5][0], weapons[5][1]);
        GetPlayerWeaponData(i, 0, weapons[6][0], weapons[6][1]);
        GetPlayerWeaponData(i, 0, weapons[7][0], weapons[7][1]);
        GetPlayerWeaponData(i, 0, weapons[8][0], weapons[8][1]);
        GetPlayerWeaponData(i, 0, weapons[9][0], weapons[9][1]);
        GetPlayerWeaponData(i, 0, weapons[10][0], weapons[10][1]);
        GetPlayerWeaponData(i, 0, weapons[11][0], weapons[11][1]);
       
        for(new c = 0; c <= 12; c++)
        {
            if(weapons[c][0] != gInfo[i][pGuns][c])
            {
                cheat++;
                printf("weapon slot: %i", c);
            }
            count = c;
        }
        if(cheat >= 1)
        {
            format(str, sizeof(str), "%s [ID: %i] may possibly be weapon spawning", GetName(i), i);
            SendClientMessageToAdmins(COLOR_YELLOW, str, 1);
        }
                if(GetPlayerWeapon(i) == 38)
        {
           
                new reason[56], string[235], Query[500], pIpAddress[15];
                format(reason, sizeof(reason), "Minigun");
                format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
                SendClientMessageToAll(COLOR_RED, string);
                GetPlayerIp(i, pIpAddress, sizeof(pIpAddress));
                strcat(Query,"INSERT INTO `bans`(`Name`,`Reason`,`BannedBy`,`IpAddress`,`Status`)");
                strcat(Query," VALUES ('%s', '%s', 'Anti-Hack', '%s', '%s', 1)");
                mysql_format(dbHandle, Query, sizeof(Query), Query, GetName(i), reason, pIpAddress);
                mysql_query(dbHandle, Query, false);
                Kick(i);
                format(string, sizeof(string), "ADMCMD: %s has been banned by Anti-Hack. Reason: %s", GetName(i), reason);
                Log("/logs/bans.txt", string);
           
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)