SA-MP Forums Archive
My anti cheat isnt working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: My anti cheat isnt working (/showthread.php?tid=487811)



My anti cheat isnt working - nuriel8833 - 15.01.2014

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; }



Re: My anti cheat isnt working - EmilLykke - 15.01.2014

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.


Re: My anti cheat isnt working - Vince - 15.01.2014

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.


Re: My anti cheat isnt working - EmilLykke - 15.01.2014

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.


Re: My anti cheat isnt working - nuriel8833 - 15.01.2014

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


Re: My anti cheat isnt working - EmilLykke - 15.01.2014

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