pawn Код:
#include <a_samp>
#include <YSI\y_commands>
new
PlayerText: txtdrw_coords [ MAX_PLAYERS ],
Float: flo_old_pos [ MAX_PLAYERS ] [ 3 ],
time_coords [ MAX_PLAYERS ];
forward UpdatePlayerCoords ( playerid );
public OnPlayerConnect ( playerid )
{
txtdrw_coords [ playerid ] = CreatePlayerTextDraw ( playerid, 357.000000, 359.000000, "--.------, --.-------, --.------" );
PlayerTextDrawAlignment ( playerid, txtdrw_coords [ playerid ], 2 );
PlayerTextDrawBackgroundColor ( playerid, txtdrw_coords [ playerid ], 255 );
PlayerTextDrawFont ( playerid, txtdrw_coords [ playerid ], 2 );
PlayerTextDrawLetterSize ( playerid, txtdrw_coords [ playerid ], 0.580000, 4.300000 );
PlayerTextDrawColor ( playerid, txtdrw_coords [ playerid ], -1 );
PlayerTextDrawSetOutline ( playerid, txtdrw_coords [ playerid ], 0 );
PlayerTextDrawSetProportional ( playerid, txtdrw_coords [ playerid ], 1 );
PlayerTextDrawSetShadow ( playerid, txtdrw_coords [ playerid ], 1 );
PlayerTextDrawSetSelectable ( playerid, txtdrw_coords [ playerid ], 0 );
return 1;
}
public UpdatePlayerCoords ( playerid )
{
new
Float: flo_new_pos [ MAX_PLAYERS ] [ 3 ];
if ( flo_new_pos [ playerid ] [ 0 ] != flo_old_pos [ playerid ] [ 0 ] &&
flo_new_pos [ playerid ] [ 1 ] != flo_old_pos [ playerid ] [ 1 ] &&
flo_new_pos [ playerid ] [ 2 ] != flo_old_pos [ playerid ] [ 2 ] )
{
new
str_text_formatted [ 128 ];
GetPlayerPos ( playerid, flo_old_pos [ playerid ] [ 0 ], flo_old_pos [ playerid ] [ 1 ], flo_old_pos [ playerid ] [ 2 ] );
format ( str_text_formatted, sizeof str_text_formatted, "%f, %f, %f", flo_old_pos [ playerid ] [ 0 ], flo_old_pos [ playerid ] [ 1 ], flo_old_pos [ playerid ] [ 2 ] );
PlayerTextDrawShow ( playerid, txtdrw_coords [ playerid ] );
PlayerTextDrawSetString ( playerid, txtdrw_coords [ playerid ], str_text_formatted );
}
return 1;
}
ShowPlayerCoords ( playerid )
{
new
str_text_formatted [ 128 ];
GetPlayerPos ( playerid, flo_old_pos [ playerid ] [ 0 ], flo_old_pos [ playerid ] [ 1 ], flo_old_pos [ playerid ] [ 2 ] );
format ( str_text_formatted, sizeof str_text_formatted, "%f, %f, %f", flo_old_pos [ playerid ] [ 0 ], flo_old_pos [ playerid ] [ 1 ], flo_old_pos [ playerid ] [ 2 ] );
PlayerTextDrawShow ( playerid, txtdrw_coords [ playerid ] );
PlayerTextDrawSetString ( playerid, txtdrw_coords [ playerid ], str_text_formatted );
time_coords [ playerid ] = SetTimerEx ( "UpdatePlayerCoords", 500, true, "i", playerid );
return 1;
}
HidePlayerCoords ( playerid )
{
PlayerTextDrawHide ( playerid, txtdrw_coords [ playerid ] );
KillTimer ( time_coords [ playerid ] );
return 1;
}
YCMD:mostrarcoords ( playerid, params [ ], help )
{
ShowPlayerCoords ( playerid );
return 1;
}
YCMD:escondercoords ( playerid, params [ ], help )
{
HidePlayerCoords ( playerid );
return 1;
}