SA-MP Forums Archive
Force player to have not more than definied hp - 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: Force player to have not more than definied hp (/showthread.php?tid=309198)



Force player to have not more than definied hp - Face9000 - 06.01.2012

Hello,since i'm making an anticheat i need to force player to NOT have HP/Armour MORE than 90.

Ex: If player buy a pizza from pizza stack and he fully restore his hp,the script will make automatically to 90.

Thanks (:


Re: Force player to have not more than definied hp - Jakku - 06.01.2012

Create a timer with a loop through all players and check their health, if it's above 90, set it to 90. Like this:

pawn Код:
forward HealthTimer();

//Under OnGameModeInit
SetTimer("HealthTimer",1000,1);

//Somewhere else
public HealthTimer()
{
     for (new i=0;i<MAX_PLAYERS;i++)
     {
          if (IsPlayerConnected(i))
          {
            new Float:health;
            GetPlayerHealth(i, health);
            if (health > 90) SetPlayerHealth(i, 90);
          }
     }
}



Re: Force player to have not more than definied hp - Scenario - 06.01.2012

A good way around a health cheat would be something like your own server-side health system. It would work just like server-side money.