Getting player distance for a point
#1

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.
Reply
#2

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
Reply
#3

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,
Reply
#4

is it the path distance or shortest distance.
Reply
#5

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
Reply
#6

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 
Reply
#7

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 ).
Reply
#8

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 '';''
Reply
#9

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
Reply
#10

new float:distance (lowercase)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)