26.01.2013, 08:48
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:
Can anyone help me?
My problem is not comparing right, so it detects non god-mode users.
My Code:
PHP код:
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;
}