PlayerFrags

From ZDoom Wiki
Jump to navigation Jump to search

int PlayerFrags (void)

Usage

Returns the current number of frags for the player who activated the script. This is only really useful in multiplayer games. Remember that the number returned may be negative if the player has commited suicide.

For scripts not activated by a player, PlayerFrags will return 0.

Examples

In this example, if the player gets a frag the player's frag count and name are displayed. It does this by assigning a script as the thing special for each player. The script is executed when the player dies and the activator is credited as the thing that killed the player. Script 3 checks the PlayerNumber to make to only print in the event that the activator was a player. Note that this will also activate if the player suicides.

script 1 enter
{
  SetThingSpecial(0, 226, 3, 0);
}

script 2 respawn
{
  SetThingSpecial(0, 226, 3, 0);
} 

script 3 (void)
{
  if (PlayerNumber() >= 0)
    printbold(n:0, s:" has ", i:PlayerFrags(), s:" frags");
}