27.02.2012, 16:44
(
Last edited by T0pAz; 28/02/2012 at 07:35 AM.
)
Introduction
Get Nearest is a small library which get's the nearest object, player, vehicle and dynamic object.
Features
Installation
How to use
You can use it like this.
Documentation
Change Log
Download
v1.1 Pastebin.
v1.0 Pastebin.
Get Nearest is a small library which get's the nearest object, player, vehicle and dynamic object.
Features
- Object
- Player
- Vehicle
- Dynamic Object
Installation
- Download the file.
- Copy it on your includes directory.
- Include it on your script using this.
pawn Code:#include <getnearest>
How to use
You can use it like this.
pawn Code:
#include <a_samp>
#include <others/streamer>
#include <others/getnearest>
new Text:SomeTd;
new str[64];
public OnFilterScriptInit()
{
InitTextDraw();
return 1;
}
stock InitTextDraw()
{
SomeTd = TextDrawCreate(44 ,286 , "Object: N/A");
TextDrawFont(SomeTd , 1);
TextDrawLetterSize(SomeTd , 0.8, 5.6000000000000005);
TextDrawColor(SomeTd , 0xa84343FF);
TextDrawSetOutline(SomeTd , false);
TextDrawSetProportional(SomeTd , true);
TextDrawSetShadow(SomeTd , 1);
}
public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, SomeTd);
return 1;
}
public OnPlayerUpdate(playerid)
{
new nearobj = GetNearest(playerid, OBJECT, 1000.0);
if(nearobj)
{
format(str, sizeof(str), "Object: %d", nearobj);
TextDrawSetString(SomeTd, str);
}
return 1;
}
Documentation
pawn Code:
GetNearest(playerid, type, distance);
/*
playerid: The id of the playerid whom you want to get the nearest of.
type: OBJECT | PLAYER | VEHICLE | DYNAMIC_OBJECT.
distance: The highest distance to check.
Returns: Returns the thing's id and if not exist on the distance, returns -1.
*/
Change Log
Code:
v1.1 ++ Optimized Script(Thanks to wups and Lorenc for some tips). Added Distance as parameter(argument). Fixed Static Object Bug(Forgot to get the correct object coordinates). v1.0 ++ Initial Release
Download
v1.1 Pastebin.
v1.0 Pastebin.