new Float:health_a,Float:health_b, Float:health_c;
public OnPlayerUpdate(playerid)
{
GetPlayerHealth(playerid,health_a); //getting and saving players hp on health_a
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
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(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s(%d) tried to GOD-Mode in dm/minigun.", pname, playerid);
MessageToAdmins(-1,string);
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid,-1670.1058,1303.2300,7.1820);
SetCameraBehindPlayer(playerid);
SendClientMessage(playerid, -1 , "Health Cheat detected, you have been automaticly teleported to spawn.");
return 1;
}
}
}
return 1;
}
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;
}
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;
}
simple tip: i tried on my server making a health anti what i did is
pawn Код:
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 Код:
|
new Float:health_a,Float:health_b;
new timer1;
forward HealthUpdate();
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Anti Cheats - LOADED");
print("--------------------------------------\n");
timer1 = SetTimer("HealthUpdate", 1000, 1);
return 1;
}
public HealthUpdate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerHealth(i,health_a);
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
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(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s(%d) tried to GOD-Mode in dm/minigun.", pname, playerid);
MessageToAdmins(-1,string);
ResetPlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid,-1670.1058,1303.2300,7.1820);
SetCameraBehindPlayer(playerid);
SendClientMessage(playerid, -1 , "God-Mode detected, you have been automaticly teleported to spawn.");
return 1;
}
}
}
timer1 = SetTimer("HealthUpdate", 1000, 1);
return 1;
}
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;
}