How to make a player invulnerable?
#1

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!
Reply
#2

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

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
Reply
#4

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.
Reply
#5

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.
Reply
#6

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

EDIT: SupremeCommanders version will work.

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

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

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
Reply
#9

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;

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)