SA-MP Forums Archive
How to make a player invulnerable? - 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: How to make a player invulnerable? (/showthread.php?tid=353190)



How to make a player invulnerable? - MarinacMrcina - 22.06.2012

Hi,I want to make an admin invulnerable when hes on duty but i have no clue how.Can you please show me how can I script it?
Thanks!


Re: How to make a player invulnerable? - SupremeCommander - 22.06.2012

pawn Код:
CMD:inv(playerid, params[]) {
 #pragma unused params
 SetPlayerHealth(playerid,100000);
 return 1;
}



Respuesta: How to make a player invulnerable? - Chris1337 - 22.06.2012

pawn Код:
onduty[MAX_PLAYERS]; //Top of your script
forward god(playerid);

onduty[playerid] = 1; // On Your CMD
SetTimerEx("god", 500, true, "i", playerid); ///CMD Too

public god(playerid)
{
  if(onduty[playerid] == 1)
   {
      SetPlayerHealth(playerid, 90000);
    }
}
UNTESTED


Re: Respuesta: How to make a player invulnerable? - iggy1 - 22.06.2012

Quote:
Originally Posted by axxelac
Посмотреть сообщение
pawn Код:
onduty[MAX_PLAYERS]; //Top of your script
...
UNTESTED
Will not work the health gets taken before the callback is called. It's also scripted wrong.


Re: Respuesta: How to make a player invulnerable? - SupremeCommander - 22.06.2012

Quote:
Originally Posted by axxelac
Посмотреть сообщение
pawn Код:
onduty[MAX_PLAYERS]; //Top of your script

onduty[playerid] = 1; // On Your CMD

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID && onduty[playerid] == 1)
    {
      SetPlayerHealth(playerid, amount);
    }
    return 1;
}
UNTESTED
It wont work with for ex. minigun... Health will be set'd after you die.


Re: How to make a player invulnerable? - iggy1 - 22.06.2012

Also you are setting the players health to the amount that was taken.

EDIT: SupremeCommanders version will work.

pawn Код:
SetPlayerHealth(playerid,100000);



Re: How to make a player invulnerable? - MarinacMrcina - 22.06.2012

Thanks guys,it works well!+ rep iggy1 and SupremeCommander


Respuesta: Re: How to make a player invulnerable? - Chris1337 - 22.06.2012

Quote:
Originally Posted by SupremeCommander
Посмотреть сообщение
pawn Код:
CMD:inv(playerid, params[]) {
 #pragma unused params
 SetPlayerHealth(playerid,100000);
 return 1;
}
SetPlayerHealth(playerid,100000); but this health will be over with a minigun shots


Re: How to make a player invulnerable? - leonardo1434 - 22.06.2012

Here you go..
pawn Код:
new isplayeronduty[MAX_PLAYERS];

CMD:duty(playerid,params[])
{
   new name[MAX_PLAYER_NAME],lol[128];
   if(stats[playerid][admin]/*<<<put here your admin "system"*/ < 1 && !IsPlayerAdmin( playerid ) ) return SendClientMessage(playerid,-1,"not authorired");
   if(sscanf(params,"")) return SendClientMessage(playerid,-1,"/duty");
   if(isplayeronduty[playerid] == 1)
   {
    isplayeronduty[playerid] = 0;
    GetPlayerName(playerid,name,sizeof(name));
    format(lol,sizeof(lol),"%s is Off duty!",name);
    SendClientMessageToAll(-1,lol);
   }
   else{
   GetPlayerName(playerid,name,sizeof(name));
   format(lol,sizeof(lol),"%s is ON duty!",name);
   SendClientMessageToAll(-1,lol);
   isplayeronduty[playerid] = 1;
   return SetPlayerHealth(playerid,999999);
   }
   return 1;

}