SA-MP Forums Archive
Getting player distance for a point - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Getting player distance for a point (/showthread.php?tid=581309)



Getting player distance from a point - Rissam - 12.07.2015

I want to get the player distance from the following point and also want to show it in textdraw;

Quote:

93.6235,1921.1780,18.0469

please help.


Re: Getting player distance for a point - Roberto80 - 12.07.2015

New Float:distance,string[200];
distance = GetPlayerDistanceFromPoint(playerid,93.6235,1921.1 780,18.0469);
format(string,200,"Distance:%0.2f",distance);
PlayerTextDrawSetString(playerid,textdraw[playerid],string);
Enjoy


Re : Getting player distance for a point - KillerDVX - 12.07.2015

PHP код:
public OnGameModeInit()
{
    
Position TextDrawCreate(1.05.6"Welcome to the point"); 
    return 
1;
}
if(
IsPlayerInRangeOfPoint(playerid7.093.6235,1921.1 780,18.0469))
    {
        
TextDrawShowForPlayer(playerid,Position);
    } 
Hope it helps.

KillerDVX,



Re: Getting player distance for a point - Rissam - 13.07.2015

is it the path distance or shortest distance.


Re: Getting player distance for a point - Threshold - 13.07.2015

Good luck scripting a 'path distance'...

pawn Код:
new string[35];
format(string, sizeof(string), "You are %0.2fm from the point.", GetPlayerDistanceFromPoint(playerid,  93.6235, 1921.1780, 18.0469));
// Update textdraw with 'string'
https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint


Re: Getting player distance for a point - Rissam - 13.07.2015

Quote:
Originally Posted by Roberto80
Посмотреть сообщение
New Float:distance,string[200];
distance = GetPlayerDistanceFromPoint(playerid,93.6235,1921.1 780,18.0469);
format(string,200,"Distance:%0.2f",distance);
PlayerTextDrawSetString(playerid,textdraw[playerid],string);
Enjoy
I am using this in on under gamemodeinit
it shows me the following errors
PHP код:

(130) :error 017undefined symbol "playerid"
(130) : warning 215expression has no effect
(130) : warning 215expression has no effect
(130) : error 001expected token";"but found ")"
(130) : error 029invalid expressionassumed zero
(130) : fatal error 107too many error messages on one line 



Re: Getting player distance for a point - notime - 13.07.2015

Quote:
Originally Posted by Rissam
Посмотреть сообщение
I am using this in on under gamemodeinit
it shows me the following errors
PHP код:

(130) :error 017undefined symbol "playerid"
(130) : warning 215expression has no effect
(130) : warning 215expression has no effect
(130) : error 001expected token";"but found ")"
(130) : error 029invalid expressionassumed zero
(130) : fatal error 107too many error messages on one line 
I can help you with some errors/warnings.
OnGameModeInit there is no playerid defined, so you simply cannot use it. You can use:
[pawno]
for (new i = 0; i < MAX_PLAYERS; i++)
{
The stuff here
}
[/pawno]
Then for the expected token ";", you forgot the ";" where you closed a function with ).


Re: Getting player distance for a point - Rissam - 13.07.2015

Quote:
Originally Posted by notime
Посмотреть сообщение
I can help you with some errors/warnings.
OnGameModeInit there is no playerid defined, so you simply cannot use it. You can use:
[pawno]
for (new i = 0; i < MAX_PLAYERS; i++)
{
The stuff here
}
[/pawno]
Then for the expected token ";", you forgot the ";" where you closed a function with ).
i already have added this '';''


Re: Getting player distance for a point - Rissam - 14.07.2015

This is my code under ongamemodeint

PHP код:
for (new 0MAX_PLAYERSi++) 
new 
Float:distance,string[200]; //line 130
distance GetPlayerDistanceFromPoint(i,93.6235,1921.1 780,18.0469);
format(string,200,"Distance:%0.2f",distance);
PlayerTextDrawSetString(playerid,textdraw3d,string); 
Following are the errors and warning:

PHP код:

(130) : error 003declaration of a local variable must appear in a compound block
(130) : warning 221label name "Float" shadows tag name
(130) : error 017undefined symbol "distance"
(130) : warning 215expression has no effect
(130) : error 001expected token";"but found "]"
(130) : fatal error 107too many error messages on one line 
I need help


Re: Getting player distance for a point - Sime30 - 14.07.2015

new float:distance (lowercase)