Squirrel/Server/Events/Player/onPlayerCommand

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This is called when a player uses a command. == Syntax == <code>function onPlayerCommand( player, command, parameters )</code> == Parameters == * '''player''' - The pointer o...)
 
(Example)
Line 14: Line 14:
 
== Example ==
 
== Example ==
  
This example command slaps the player if they type '/c slap'.
+
This example command slaps the user if they type '/c slap'.
  
 
<code lang="squirrel">
 
<code lang="squirrel">

Revision as of 05:32, 9 January 2010

This is called when a player uses a command.

Syntax

  1. 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 user if they type '/c slap'.

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "slap" )
  5. {
  6. local pos = player.Pos;
  7. pos.z += 5;
  8. player.Pos = pos;
  9. MessagePlayer( "You slapped yourself! Now that wasn't very smart", player );
  10. }
  11. }
  12.  
Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox