Scripting/Squirrel/Functions/Players/IsSpawned

From VC-MP Wiki

Jump to: navigation, search

This Player class variable returns whether the player has spawned.

Syntax

bool player.IsSpawned

Example

Command: /c spawned

function onPlayerCommand( player, cmd, text )
{
        if ( cmd == "spawned" )
     {
          if ( player.IsSpawned ) PrivMessage( "*** You are spawned. Congratulations!", player);
          else PrivMessage( "*** You are not spawned", player);
   }
}

Example2

Command: /c playerspawn <Nick/ID>

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "playerspawn" )
     {
          local plr = FindPlayer( text );
 
          if ( !plr ) PrivMessage( "Player: '" + text + "' is not online", player );
          else if ( plr.IsSpawned ) PrivMessage( plr.Name + " is spawned", player );
          else PrivMessage( plr.Name + " is not spawned", player );
   }
}

Notes

The functions PrivMessage, FindPlayer and call onPlayerCommand were used in in this example. More info about them in the corresponding pages.

Related Functions

Personal tools
squirrel scripting