Anti God-mode problem
#1

Hello everyone, i am trying these days to create an anti god-mode for my Server.
My problem is not comparing right, so it detects non god-mode users.

My Code:

PHP код:
new Float:health_a,Float:health_bFloat:health_c;
public 
OnPlayerUpdate(playerid)
{
    
GetPlayerHealth(playerid,health_a); //getting and saving players hp on health_a
    
return 1;
}
public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    
health_c health_a amount//minus the amount of damage from previous player health and saving it on health_c
    
GetPlayerHealth(playerid,health_b);//getting the current player health
    
if(health_c <= health_b)//checking if current health is equals or larger than the previous hp
    
{
        if (
GetPlayerVirtualWorld(playerid)==1)//checking the world (using different worlds from normal playing and deathmatch)
        
{
            if(!
IsPlayerLuxAdminLevel(playerid,10))//if player is not admin level 10
            
{
                new 
pname[MAX_PLAYER_NAME];
                new 
string[170];
                
GetPlayerName(playeridpnamesizeof(pname));
                
format(stringsizeof(string), "%s(%d) tried to GOD-Mode in dm/minigun."pnameplayerid);
                
MessageToAdmins(-1,string);
                
ResetPlayerWeapons(playerid);
                
SetPlayerHealth(playerid100);
                
SetPlayerVirtualWorld(playerid0);
                
SetPlayerPos(playerid,-1670.1058,1303.2300,7.1820);
                
SetCameraBehindPlayer(playerid);
                
SendClientMessage(playerid, -"Health Cheat detected, you have been automaticly teleported to spawn.");
                return 
1;
            }
        }
    }
    return 
1;

Can anyone help me?
Reply
#2

I don't know why you use GetPlayerHealth function below OnPlayerUpdate.
OnPlayerUpdate gets called 60 times in a second. That means if someone take your health damage, the server will save in the variable health_a, the current health, after you got damaged.
Reply
#3

Then how i can get and save the previous health so i can compare it??
Reply
#4

simple tip: i tried on my server making a health anti what i did is

pawn Код:
public OnPlayerConnect
{
SetPlayerHealth(playerid, 99.99);//just incase to avoid bug
return 1;
}
public OnPlayerSpawn
{
SetPlayerHealth(playerid, 99.99);// there is no any changes at your health bar
return 1;
}
if you still got all things that has SetPlayerHealth(playerid, 100); change it to SetPlayerHealth(playerid, 99.99);

and when you detect it as a hacker
GetPlayerHealth(playerid, 100);
hope you understand it

also you need to remove the things that gives you health on default samp here
Credits to Cessil
pawn Код:
public OnPlayerConnect
{
    RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 956, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1977, 0.0, 0.0, 0.0, 6000.0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
simple tip: i tried on my server making a health anti what i did is

pawn Код:
public OnPlayerConnect
{
SetPlayerHealth(playerid, 99.99);//just incase to avoid bug
return 1;
}
public OnPlayerSpawn
{
SetPlayerHealth(playerid, 99.99);// there is no any changes at your health bar
return 1;
}
if you still got all things that has SetPlayerHealth(playerid, 100); change it to SetPlayerHealth(playerid, 99.99);

and when you detect it as a hacker
GetPlayerHealth(playerid, 100);
hope you understand it

also you need to remove the things that gives you health on default samp here
Credits to Cessil
pawn Код:
public OnPlayerConnect
{
    RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 956, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0);
    RemoveBuildingForPlayer(playerid, 1977, 0.0, 0.0, 0.0, 6000.0);
    return 1;
}
I already did that, but s0.beit is lock on current hp, so if player use god on s0.beit, will have 99.

Thats why i am trying to compare health, so i can detect s0.beit users.
Reply
#6

you could try SetPlayerHealth(playerid,98.99); if it damage alot on health bar, i cant think any idea of how to detect it.
Reply
#7

Comparing is the only way to detect this types of god-mode...
Reply
#8

Hi again, due to MouseBreaker information about OnPlayerUpdate, i decided to add a timer, that will check each second player's HP.

so i did:

PHP код:
new Float:health_a,Float:health_b;
new 
timer1;
forward HealthUpdate();
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
" Anti Cheats - LOADED");
    print(
"--------------------------------------\n");
    
    
timer1 SetTimer("HealthUpdate"10001);
    return 
1;
}
public 
HealthUpdate()
{
    for(new 
0MAX_PLAYERSi++)
    {
        
GetPlayerHealth(i,health_a);
    }
    return 
1;
}
public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
    
KillTimer(timer1);
    
GetPlayerHealth(playerid,health_b);
    if(
health_a >= health_b)
    {
        if (
GetPlayerVirtualWorld(playerid)==1)
        {
            if(!
IsPlayerLuxAdminLevel(playerid,10))
            {
                new 
pname[MAX_PLAYER_NAME];
                new 
string[170];
                
GetPlayerName(playeridpnamesizeof(pname));
                
format(stringsizeof(string), "%s(%d) tried to GOD-Mode in dm/minigun."pnameplayerid);
                
MessageToAdmins(-1,string);
                
ResetPlayerWeapons(playerid);
                
SetPlayerHealth(playerid100);
                
SetPlayerVirtualWorld(playerid0);
                
SetPlayerPos(playerid,-1670.1058,1303.2300,7.1820);
                
SetCameraBehindPlayer(playerid);
                
SendClientMessage(playerid, -"God-Mode detected, you have been automaticly teleported to spawn.");
                return 
1;
            }
        }
    }
    
timer1 SetTimer("HealthUpdate"10001);
    return 
1;

But still the same problem. Please can anyone help me on this?
Reply
#9

This should work:

pawn Код:
new Float:health_a[MAX_PLAYERS];
new Float:health_b;
forward HealthUpdate();

public OnFilterScriptInit()
{
    SetTimer("HealthUpdate", 2000, 1);
    return 1;
}

public HealthUpdate()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerHealth(i, health_b);
            if(health_b > health_a[i])
            {
                if(GetPlayerVirtualWorld(i) == 1)
                {
                    if(!IsPlayerLuxAdminLevel(i,10))
                    {
                        new pname[MAX_PLAYER_NAME];
                        new string[65];
                        GetPlayerName(i, pname, sizeof(pname));
                        format(string, sizeof(string), "%s(%d) tried to GOD-Mode in dm/minigun.", pname, i);
                        MessageToAdmins(-1,string);
                        ResetPlayerWeapons(i);
                        SpawnPlayer(i);
                        SendClientMessage(i, -1 , "God-Mode detected, you have been automatically teleported to spawn.");
                        return 1;
                    }
                }
            }
            else
            {
                health_a[i] = health_b;
            }
        }
    }
    return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    GetPlayerHealth(playerid,health_b);
    health_a[playerid] = health_b;
    return 1;
}
You needed to save the health_a variable to a playerid.
Reply
#10

But i want to check when player take damage, anw i will try it and i will tell you!

EDIT: Is not working, when i shoot, it detects me for godmode... thanks anyway
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)