Scripting/Squirrel/Events/Player/onPlayerCommand

From VC-MP Wiki
Jump to: navigation, search

This is called when a player uses a command.

Syntax

function onPlayerCommand( player, command, parameters )

Parameters

  • player - The pointer of the player
  • command - This is the command player used
  • parameters - This is the list of the parameters as a string

Example

This example command slaps the player if they type '/c slap'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "slap" )
     {
          local pos = player.Pos;
          pos.z += 5;
          
          player.Pos = pos;
          MessagePlayer( "You slapped yourself! What a fool!", player );
     }
}

Notes

The functions MessagePlayer and player.Pos were used in in this example. More info about them in corresponding pages.

Related Events

Personal tools
squirrel scripting