Player HP Infinite
#1

How do I set a player to have infinite life, or to never be able to die. Not SetPlayerHealth(playerid, 99999) .... But like actually infinite.

The problem is I have an include which makes the sniper a 1 shot death, but admins are never supposed to be able to die in my GM... So how do I set their health to infinite (or where they won't take damage)?


Thanks: jakejohnsonusa
Reply
#2

SetPlayerHealth() on a timer? like update 99999 every second for that player...
Reply
#3

Hmmm. I don't think that will fix my problem. Any other ways?
Reply
#4

Well if there is no other way, its better if you disable the sniper one shot die thing. And what mastermax7777 said, well its alright but there is no point if the sniper could kill him with one shot, injured positively he can regain the health but where could he update in a second?
Reply
#5

Either use OnPlayerUpdate

PHP код:
public OnPlayerUpdate(playerid)
{
     If(
IsPlayerAdmin(playerid)
     {
          
SetPlayerHealth(playerid9999);
     }
     return 
1;

Or use a timer (highly recommend y_timers include)
https://sampforum.blast.hk/showthread.php?tid=321092

PHP код:
#include <YSI\y_timers>
ptask healadmin[10000](playerid)
{
     If(
IsPlayerAdmin(playerid)
     {
          
SetPlayerHealth(playerid9999);
     }
     return 
1;

Reply
#6

IsPlayerAdmin and a timer with SetPlayerHealth is what you need.
Reply
#7

Ok without using YSI, how can I do a timer? (Sorry, but I don't use or have YSI). The exact code for this would be great.

Thanks guys
+1 Rep to everyone!
Reply
#8

You said sniper is 1 shot kill, so just make it if(PlayerInfo[playerid][admin] == 0) or whatever your enum is for admins, so if your not an admin, then it kills you, if you are an admin, nothing happens.
Reply
#9

Honestly the whole reason I use y_timers is because I'm horrible at using the regular timer
It usually doesn't work properly for me, so I better not try to teach others how to use it.

But, here is a simple alternative. This will set the admin's health to 9999 every time they push any key (ROFL).

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
     If(
IsPlayerAdmin(playerid
     { 
          
SetPlayerHealth(playerid9999); 
     } 
     return 
1

Also, there must be a line somewhere in that sniper include or filterscript that says
PHP код:
SetPlayerHealth(playerid0); 
you should add an "if" statement to that line
PHP код:
if(!IsPlayerAdmin(playerid)) //the ! means "not"
{
     
SetPlayerHealth(playerid0);

Reply
#10

PHP код:
If(IsPlayerAdmin(playerid)) 
Not
PHP код:
If(IsPlayerAdmin(playerid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)