OnPlayerMove: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "__NOTOC__ This is called when a player moves on foot or as a passenger. == Syntax == <code>function onPlayerMove( player, oldX, oldY, oldZ, newX, newY, newZ )</code> == Par...")
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
== Syntax ==
== Syntax ==


<code>function onPlayerMove( player, oldX, oldY, oldZ, newX, newY, newZ )</code>
<pre>function onPlayerMove( player, oldX, oldY, oldZ, newX, newY, newZ )</pre>


== Parameters ==
== Parameters ==
Line 20: Line 20:
This example will move the player back to point (0, 0, 0) if they move too far away from it.
This example will move the player back to point (0, 0, 0) if they move too far away from it.


<code lang="squirrel">
<source lang="squirrel">
function onPlayerMove( player, x1, y1, z1, x2, y2, z2 )
function onPlayerMove( player, x1, y1, z1, x2, y2, z2 )
{
{
     if ( sqrt( x2*x2 + y2*y2 + z2*z2 ) > 50 ) player.Pos = Vector( 0.0, 0.0, 0.0 );
     if ( sqrt( x2*x2 + y2*y2 + z2*z2 ) > 50 ) player.Pos = Vector( 0.0, 0.0, 0.0 );
}
}
</code>
</source>


=== Notes ===
=== Notes ===
Line 31: Line 31:
The function [[Scripting/Squirrel/Functions/Player.Pos|Player.Pos]] was used in in this example. More info about it in the corresponding page.
The function [[Scripting/Squirrel/Functions/Player.Pos|Player.Pos]] was used in in this example. More info about it in the corresponding page.


== Related Events ==
== Related Functions ==


{{Scripting/Squirrel/Events/Player_Events}}
{{Scripting/Squirrel/Events/Player_Events}}
[[Category:Scripting/Squirrel/Events/Player_Events]]

Latest revision as of 22:15, 30 January 2017

This is called when a player moves on foot or as a passenger.

Syntax

function onPlayerMove( player, oldX, oldY, oldZ, newX, newY, newZ )

Parameters

  • player - The pointer of the player
  • oldX - Old X coordinate
  • oldY - Old Y coordinate
  • oldZ - Old Z coordinate
  • newX - New X coordinate
  • newY - New Y coordinate
  • newZ - New Z coordinate

Example

This example will move the player back to point (0, 0, 0) if they move too far away from it.

function onPlayerMove( player, x1, y1, z1, x2, y2, z2 )
{
     if ( sqrt( x2*x2 + y2*y2 + z2*z2 ) > 50 ) player.Pos = Vector( 0.0, 0.0, 0.0 );
}

Notes

The function Player.Pos was used in in this example. More info about it in the corresponding page.

Related Functions