SA-MP Forums Archive
evade damage - 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: evade damage (/showthread.php?tid=352401)



evade damage - jop9888 - 19.06.2012

Hee all,

i was wondering if it is possible to make that a player can't hit a specific player, but can kill others without the use of teams

i need this for a mini missions, but i don't want to use teams because i never use them in my script, and i don't want them to be of use after the mini mission!

Thanks in advance!

Jop9888


Re: evade damage - Revo - 19.06.2012

Perhaps take a look in OnPlayerTakeDamage

pawn Код:
new CantBeHarmed = INVALID_PLAYER_ID;

OnMiniMissionStart()
{
  CantBeHarmed = id;
  return 1;
}

OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
  if(playerid == CantBeHarmed) return 0;
  return 1;
}
I'm not sure in what context you need this to be, so this is the best I can suggest.


Re: evade damage - jop9888 - 19.06.2012

Thanks! that's what i wanted


Re: evade damage - SuperViper - 19.06.2012

Quote:
Originally Posted by BuuGhost
Посмотреть сообщение
Perhaps take a look in OnPlayerTakeDamage

pawn Код:
new CantBeHarmed = INVALID_PLAYER_ID;

OnMiniMissionStart()
{
  CantBeHarmed = id;
  return 1;
}

OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
  if(playerid == CantBeHarmed) return 0;
  return 1;
}
I'm not sure in what context you need this to be, so this is the best I can suggest.
Returning 0 in OnPlayerTakeDamage doesn't prevent the damage.

@Poster

Use teams and then set everyone's team to -1 when the other modes start.


Re: evade damage - Revo - 20.06.2012

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Returning 0 in OnPlayerTakeDamage doesn't prevent the damage.

@Poster

Use teams and then set everyone's team to -1 when the other modes start.
Aha, just setplayerhealth+difference then, never tested around.


Re: evade damage - [MM]RoXoR[FS] - 20.06.2012

pawn Код:
new CantBeHarmed = INVALID_PLAYER_ID;

OnMiniMissionStart()
{
  CantBeHarmed = id;
  return 1;
}

OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
  if(playerid == CantBeHarmed)
  {
  new Float:health;
  GetPlayerHealth(playerid,health);
  SetPlayerHealth(playerid,health + amount);
  }
  return 1;
}