Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Razor. on Jun 24, 2017, 08:40 PM

Title: Command to found pickup with meters like /loc
Post by: Razor. on Jun 24, 2017, 08:40 PM
Hey guys, who have command to found pickup with meters? Like /loc command.
Example: Pickup Location: Viceport 203 meters.
Title: Re: Command to found pickup with meters like /loc
Post by: Shadow on Jun 24, 2017, 10:04 PM
Pretty sure there is a method (Vector3::Distance). Use that and print the distance. Every entity in the game has a .Pos member which returns it's position as a tridimensional vector that is printable. All .Distance does is calculate the distance using the standard formula.
Title: Re: Command to found pickup with meters like /loc
Post by: Luis_Labarca on Jun 25, 2017, 12:28 AM
if ( cmd == "locp" )
{
if ( !text ) MessagePlayer( "Syntax: /"+cmd+" <Pickup ID>", player);
else if( !IsNum( text )) MessagePlayer( "Error - PickupID In Numbers.", player );
else{
local Pickup = FindPickup(text.tointeger());
if( !Pickup )MessagePlayer("Error - Unknown Pickup", player );
else{
MessagePlayer( "Pickup Location : "+GetDistrictName(Pickup.Pos.x, Pickup.Pos.y)+", Meters : "+DistanceFromPoint( player.Pos.x, player.Pos.y , Pickup.Pos.x, Pickup.Pos.y )+".", player );
}
}
}

Title: Re: Command to found pickup with meters like /loc
Post by: Mötley on Jun 27, 2017, 03:21 PM
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/DistanceFromPoint

Pretty sure that's what you are looking for
Title: Re: Command to found pickup with meters like /loc
Post by: DizzasTeR on Jun 27, 2017, 04:06 PM
local pickup_MyPickup = FindPickup( PICKUP_ID || 0 );

MessagePlayer( format( "* Pickup is located at: %s, %i meters",
    GetDistrictName( pickup_MyPickup.Pos.x pickup_MyPickup.Pos.y ),
    player.Pos.Distance( pickup_MyPickup.Pos ).tointeger() ),
player );
Title: Re: Command to found pickup with meters like /loc
Post by: Razor. on Jun 29, 2017, 12:16 AM
Thanks all. :) Solved.