My anti cheat isnt working
#1

Everytime I log into the server I am immediatly being banned
Why is that?
pawn Код:
forward AntiCheat(playerid);
new Float:Armour;

public OnPlayerConnect(playerid)
{
    SetTimerEx("AntiCheat",500,true,"d",playerid);
    return 1; }


public AntiCheat(playerid) {
    if(!IsPlayerAdmin(playerid)) {
        if(GetPlayerVirtualWorld(playerid) != W_DeathMatchZones) {
            if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 46 ) Ban(playerid);
            if(GetPlayerArmour(playerid,Float:Armour) > 0) return Ban(playerid); } }
     return 1; }
Reply
#2

Because when you log in the server, you are not set as admin. Make it a saving admin system instead of Rcon and it will work.
Reply
#3

Let's take a closer look at what actually happens here;
pawn Код:
if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 46 ) Ban(playerid);
If the player is unarmed, the statement becomes this:

pawn Код:
if(0 != 0 || 0 != 46 ) Ban(playerid);
0 is equal to 0 so the first part is false. However, 0 isn't equal to 46 so that part becomes true!

pawn Код:
if(false || true) Ban(playerid);
The statement ultimately becomes true and the statement gets executed.


Edit: Your usage of GetPlayerArmour is wrong, as well. GetPlayerArmour in itself, like you use it, only returns 0 or 1 depending on whether the function succeeded. The actual health value gets saved in the 'Float:Armour' variable. This is the value you want to compare, not the return value of the function.
Reply
#4

No. He is getting banned, because when you login you always have to use /rcon login [password]. If he is NOT an admin, he will just be immidiately banned when he logs in. If he has a firearm, I mean.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Let's take a closer look at what actually happens here;
pawn Код:
if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 46 ) Ban(playerid);
If the player is unarmed, the statement becomes this:

pawn Код:
if(0 != 0 || 0 != 46 ) Ban(playerid);
0 is equal to 0 so the first part is false. However, 0 isn't equal to 46 so that part becomes true!

pawn Код:
if(false || true) Ban(playerid);
The statement ultimately becomes true and the statement gets executed.


Edit: Your usage of GetPlayerArmour is wrong, as well. GetPlayerArmour in itself, like you use it, only returns 0 or 1 depending on whether the function succeeded. The actual health value gets saved in the 'Float:Armour' variable. This is the value you want to compare, not the return value of the function.
So how do I change it so if the player weapon is neither 0 nor 46 he will be banned? Or I can check only 46 since the weapon is always 0

Quote:
Originally Posted by EmilLykke
Посмотреть сообщение
No. He is getting banned, because when you login you always have to use /rcon login [password]. If he is NOT an admin, he will just be immidiately banned when he logs in. If he has a firearm, I mean.
But I have to check if that player is a RCON admin,since they are the only players that are allowed to use those weapons / to have armour
Reply
#6

I just told you what to do? Make a proper admin system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)