How can i stop this spamming
#1

How can i stop this spamming every half a second that some one has been banned


pawn Код:
public OnPlayerUpdate(playerid)
{
    foreach(Player, i)
    {
        new weap = GetPlayerWeapon(i);
        if(weap > 0 && Weapon[i][weap] == false)
        {
            if(GetPlayerState(i) == 1 || GetPlayerState(i) == 2 || GetPlayerState(i) == 3) {
                new msg[128];
                new Nam[MAX_PLAYER_NAME];
                GetPlayerName(playerid,Nam,sizeof(Nam));
                format(msg,sizeof(msg),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
                SendClientMessageToAll(0xFF0000FF,msg);
                SendClientMessage(playerid, COLOR_RED, "No Hacking");
                //ban or warning code here
                //Ban or warning code here
                //ban or warning code here
                //Ban or warning code here
                //ban or warning code here

            }
        }
    }
    return 1;
}

Thank You


Please Help Me Please
Reply
#2

Ban them? You just send a message, you don't actually ban them.

Also, omit parachutes from checks as they can get them from aircraft:

if(weap > 0 && Weapon[i][weap] == false)

->

if(weap > 0 && weap != WEAPON_PARACHUTE && Weapon[i][weap] == false)

Also you should change

if(GetPlayerState(i) == 1 || GetPlayerState(i) == 2 || GetPlayerState(i) == 3) {

to

if(GetPlayerState(i) >= 1|| GetPlayerState(i) <= 3)
{

A. Move the bracket down to keep your code clean
B. Saved one check
Reply
#3

It helps if you use the ban function. Although careful with exactly what you do at OnPlayerUpdate. All players call that function, so just do a single check for that specific player, don't loop through all players at OPU. As all players will call it up multiple times a second anyway. So you're just causing lots of checks that just don't need to be done.
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Ban them? You just send a message, you don't actually ban them.

Also, omit parachutes from checks as they can get them from aircraft:

if(weap > 0 && Weapon[i][weap] == false)

->

if(weap > 0 && weap != WEAPON_PARACHUTE && Weapon[i][weap] == false)
But it will still spam


pawn Код:
format(msg,sizeof(msg),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);

Wont it


Thank You


Please Help Me Please
Reply
#5

ban or kick them then it will stop spamming because they are disconnected
Reply
#6

try this

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        new weap = GetPlayerWeapon(i);
        if(weap > 0 && Weapon[i][weap] == false && weap != 46 && weap != 40)
        {
            if(1 <= GetPlayerState(i) <= 3) {
                new msg[128];
                new Nam[MAX_PLAYER_NAME];
                GetPlayerName(playerid,Nam,sizeof(Nam));
                format(msg,sizeof(msg),"ANTI WEAPON HACK: %s has been banned from server for spawning a bad weapon!",Nam);
                SendClientMessageToAll(0xFF0000FF,msg);
                SendClientMessage(playerid, COLOR_RED, "No Hacking");
                SafeRemovePlayerWeapon(playerid, weap);
                //ban or warning code here

            }
        }
    }
    return 1;
}
stock SafeRemovePlayerWeapon(playerid, ...) {
    new iArgs = numargs(), idx, wList[13], wIter;
    while(--iArgs)
    {
        idx = getarg(iArgs);
        SetPlayerAmmo(playerid, idx, 0);
        wList[wIter] = idx;
        wIter++;
    }
    for(; wIter != 0; wIter--)
    {
        Weapon[playerid][wList[wIter]] = false;
        printf("[System: SafeRemovePlayerWeapon] - Removing Player Weapon: %d - Playerid: %d", wList[wIter], playerid);
        wList[wIter] = 0;
    }
    return 1;
}
Reply
#7

Anti-cheat stuff under OnPlayerUpdate is a silly thing to do. Just run a loop every 3 seconds or so.
Reply
#8

Quote:
Originally Posted by MP2
Посмотреть сообщение
Anti-cheat stuff under OnPlayerUpdate is a silly thing to do. Just run a loop every 3 seconds or so.
How would i do that


Thank You


Please Help Me Please
Reply
#9

Quote:
Originally Posted by Scripter12345
Посмотреть сообщение
How would i do that


Thank You


Please Help Me Please
check my post above.. should work else show errors


Quote:
Originally Posted by MP2
Посмотреть сообщение
Also, omit parachutes from checks as they can get them from aircraft:
Also omit denoter, since it's also given by the client.

TBH, I see no point of a timer or any of the sort with a weapon anti-cheat, it's a waste of cpu and what not.

KeyStateChange should work fine, if a player shoots the weapon, remove it. or if you have a OnPlayerWeaponChange or something.
Reply
#10

If you say

Thank You


Please Help Me Please

again I am going to STOP helping you. It's irritating.

pawn Код:
public OnGameModeInit()
{
    // blah
    SetTimer("AntiCheatLoop", 3256, true); // Looping timer every ~3 seconds
    // blah
    return 1;
}

forward AntiCheatLoop();
public AntiCheatLoop()
{
    foreach(new i : Player)
    {
        // check 'i' for cheats
    }
    return 1;
}
Download foreach here: https://sampforum.blast.hk/showthread.php?tid=92679
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)