What's up here?
#1

Hello, i've been making an anticheat, and it kicks after getting 3 dections but it spams the screen when it kicks someone
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(hInfo[playerid][MoneyHackWarn] == 3)
    {
        new str[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "%s Has been kicked for Money Hacks", name);
        SendClientMessageToAll(-1, str);
        SetTimerEx("KickTimer", 1000, false, "d", playerid);
        return 1;
    }
    if(hInfo[playerid][WeaponHackWarn] == 3)
    {
        new str[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "%s Has been kicked for Weapon hacks", name);
        SendClientMessageToAll(-1, str);
        SetTimerEx("KickTimer", 1000, false, "d", playerid);
        return 1;
    }
    return 1;
}
Does anyone know how to fix it?
Reply
#2

OnPlayerUpdate is called very frequently per second per player.
That's why it sends many messages.
You can place your code somewhere else. Otherwise, remove the message.
Reply
#3

Hm, should i put it on a timer then? or would that course lag?
Reply
#4

You should use a timer or stock, as far as I know.
Reply
#5

Since the player will be kicked, just reset the variable to 0:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(hInfo[playerid][MoneyHackWarn] == 3)
    {
        new str[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "%s Has been kicked for Money Hacks", name);
        SendClientMessageToAll(-1, str);
        SetTimerEx("KickTimer", 1000, false, "d", playerid);
        hInfo[playerid][MoneyHackWarn] = 0; // Reset the variables
        return 1;
    }
    if(hInfo[playerid][WeaponHackWarn] == 3)
    {
        new str[128], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "%s Has been kicked for Weapon hacks", name);
        SendClientMessageToAll(-1, str);
        SetTimerEx("KickTimer", 1000, false, "d", playerid);
        hInfo[playerid][WeaponHackWarn] = 0; // Reset the variables
        return 1;
    }
    return 1;
}
Reply
#6

Ahh, thank you PowerPC! once again you've helped me
Reply
#7

Well, OnPlayerUpdate() it's very faster, and it's spamming all chat. You can try yourself.

pawn Код:
new Updates;

public OnPlayerUpdate(playerid)
{
    Updates++;
    return 1;
}

CMD:updates(playerid, params[])
{
    new string[50];
    format(string, sizeof(string), "Here are curently %d updates!", Updates);
    SendClientMessage(playerid, -1, string);
    return 1;
}
With this simple filescript, you will see how many updates are per second. More faster, I think it's 30 ms.

Anyway, you should use a timer wich checks every second how many warns it's having that player.

Edit: Again, I didn't saw the guy above me.
Reply
#8

That variable doesn't jut increment by itself! Don't use OnPlayerUpdate for stuff that is entirely within your control. Somewhere within your code you're doing

pawn Код:
hInfo[playerid][MoneyHackWarn]++
It is there you need to catch it, definitely not in OnPlayerUpdate.
Reply
#9

So It's better to use a timer?
Reply
#10

Ah, timer works perfectly, thank you guys!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)