Scripting/Squirrel/Functions/DistanceFromPoint: 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 "This function will get the distance from a point to another. == Syntax == <pre>DistanceFromPoint( x1, y1, x2, y2 )</pre> == Arguments == * ''float'' '''x1''' - The X coord...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 17: Line 17:


== Example ==
== Example ==
 
<source lang=squirrel>
{{Scripting/Needs_Example}}
function onPlayerCommand( player, cmd, text )
{
    if ( cmd == "distance" )
    {
        ClientMessage("[#ffffff]Your Distance to the point: " + DistanceFromPoint(player.Pos.x, player.Pos.y, -378.79, -537.962),player,255,255,255);
    }
    return 1;
}
</source>


=== Notes ===
=== Notes ===
 
Call [[onPlayerCommand]] were used in this example. More info about them in the corresponding pages.


== Related Functions ==
== Related Functions ==


{{Scripting/Squirrel/Functions/Game_Functions}}
{{Scripting/Squirrel/Functions/Game_Functions}}
[[Category:Scripting/Squirrel/Functions/Game_Functions]]

Latest revision as of 18:05, 30 January 2017

This function will get the distance from a point to another.

Syntax

DistanceFromPoint( x1, y1, x2, y2 )

Arguments

  • float x1 - The X coordinate
  • float y1 - The Y coordinate
  • float x2 - The X coordinate
  • float y2 - The Y coordinate

Return value

  • float distance - The distance between the two points

Example

function onPlayerCommand( player, cmd, text )
{
    if ( cmd == "distance" )
    {
        ClientMessage("[#ffffff]Your Distance to the point: " + DistanceFromPoint(player.Pos.x, player.Pos.y, -378.79, -537.962),player,255,255,255);
    }
    return 1;
}

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions